Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib/coinpayportal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createPayment,
createInvoice,
sendInvoice,
coinToPaymentCurrency,
getBusinessWalletCurrencies,
getSupportedCoins,
preferredCoinToPaymentCurrency,
Expand Down Expand Up @@ -196,6 +197,12 @@ describe("CoinPayPortal supported coins API", () => {
expect(preferredCoinToPaymentCurrency("USDC")).toBe("usdc_sol");
});

it("maps CoinPay OAuth wallet cryptocurrency and chain fields", () => {
expect(coinToPaymentCurrency({ cryptocurrency: "USDC", chain: "POL" })).toBe("usdc_pol");
expect(coinToPaymentCurrency({ cryptocurrency: "USDT", chain: "ETH" })).toBe("usdt_eth");
expect(coinToPaymentCurrency({ cryptocurrency: "SOL", chain: "SOL" })).toBe("sol");
});

it("rejects preferred coins CoinPayPortal payment creation cannot represent", async () => {
await expect(resolveSupportedPaymentCurrency("LN")).rejects.toThrow(
"CoinPayPortal payments do not support LN"
Expand Down
2 changes: 2 additions & 0 deletions src/lib/coinpayportal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface SupportedCoin {
symbol?: string;
code?: string;
currency?: string;
cryptocurrency?: string;
id?: string;
name?: string;
chain?: string;
Expand Down Expand Up @@ -281,6 +282,7 @@ export function coinToPaymentCurrency(coin: SupportedCoin): SupportedCurrency |
normalizeCoinSymbol(coin.symbol) ||
normalizeCoinSymbol(coin.code) ||
normalizeCoinSymbol(coin.currency) ||
normalizeCoinSymbol(coin.cryptocurrency) ||
normalizeCoinSymbol(coin.id);
const chain =
normalizeCoinSymbol(coin.chain) ||
Expand Down
Loading