Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/demo/partners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export default {
type: 'fiat',
color: '#7214F5'
},
nexchange: {
type: 'swap',
color: '#1D31B6'
},
paybis: {
type: 'fiat',
color: '#FFB400'
Expand Down Expand Up @@ -152,5 +156,9 @@ export default {
xanpool: {
type: 'fiat',
color: '#46228B'
},
xgram: {
type: 'swap',
color: '#0FA7B1'
}
} as const
3 changes: 3 additions & 0 deletions src/partners/banxa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,10 @@ function getFiatPaymentType(tx: BanxaTx): FiatPaymentType {
case 'WorldPay ApplePay':
case 'Primer Apple Pay':
return 'applepay'
case 'Primer Paypal Pay':
return 'paypal'
case 'WorldPay GooglePay':
case 'Primer Google Pay':
return 'googlepay'
case 'iDEAL Transfer':
return 'ideal'
Expand Down
31 changes: 13 additions & 18 deletions src/partners/changenow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,24 +376,19 @@ function getAssetInfo(network: string, currencyCode: string): EdgeAssetInfo {
)
}

try {
const tokenId = createTokenId(
tokenType,
currencyCode.toUpperCase(),
contractAddress
)
return {
chainPluginId,
evmChainId,
tokenId
}
} catch (e) {
// If tokenId creation fails, treat as native (no log available in this sync function)
return {
chainPluginId,
evmChainId,
tokenId: null
}
// Let createTokenId throw if the contract address cannot be converted: a
// token must never be silently downgraded to a native (tokenId: null)
// mapping, which would price it with the chain's gas-token rate and
// overcount volume whenever the token is worth less than the gas token.
const tokenId = createTokenId(
tokenType,
currencyCode.toUpperCase(),
contractAddress
)
return {
chainPluginId,
evmChainId,
tokenId
}
}

Expand Down
71 changes: 65 additions & 6 deletions src/partners/letsexchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,68 @@ const LETSEXCHANGE_NETWORK_TO_PLUGIN_ID: Record<string, string> = {
ZKSYNC: 'zksync'
}

// When the API omits network fields, infer native chain from currency code.
// Only unambiguous 1:1 native-ticker cases (not USDT, USDC, BNB, etc.).
const LETSEXCHANGE_CURRENCY_TO_DEFAULT_NETWORK: Record<string, string> = {
ADA: 'ADA',
ALGO: 'ALGO',
ARRR: 'ARRR',
ATOM: 'ATOM',
AVAX: 'AVAXC',
BCH: 'BCH',
BSV: 'BSV',
BTC: 'BTC',
BTG: 'BTG',
CELO: 'CELO',
COREUM: 'COREUM',
DASH: 'DASH',
DGB: 'DGB',
DOGE: 'DOGE',
DOT: 'DOT',
EOS: 'EOS',
ETC: 'ETC',
ETH: 'ETH',
ETHW: 'ETHW',
FIL: 'FIL',
FIO: 'FIO',
FIRO: 'FIRO',
FTM: 'FTM',
GRS: 'GRS',
HBAR: 'HBAR',
LTC: 'LTC',
MATIC: 'MATIC',
PIVX: 'PIVX',
POL: 'POL',
PLS: 'PLS',
QTUM: 'QTUM',
RUNE: 'RUNE',
RVN: 'RVN',
SOL: 'SOL',
SONIC: 'SONIC',
SUI: 'SUI',
TLOS: 'TLOS',
TON: 'TON',
TRX: 'TRX',
XEC: 'XEC',
XLM: 'XLM',
XMR: 'XMR',
XRP: 'XRP',
XTZ: 'XTZ',
ZANO: 'ZANO',
ZEC: 'ZEC'
}

function resolveNetworkCode(
network: string | null,
currencyCode: string,
isoDate: string
): string | null {
if (network != null) return network
if (isoDate < NETWORK_FIELDS_AVAILABLE_DATE) return null
const currencyUpper = currencyCode.toUpperCase()
return LETSEXCHANGE_CURRENCY_TO_DEFAULT_NETWORK[currencyUpper] ?? null
}

// Native token placeholder addresses that should be treated as null (native coin)
// All values should be lowercase for case-insensitive matching
const NATIVE_TOKEN_ADDRESSES = new Set([
Expand Down Expand Up @@ -299,13 +361,10 @@ function getAssetInfo(
contractAddress: string | null,
isoDate: string
): AssetInfo | undefined {
if (initialNetwork == null) {
if (isoDate < NETWORK_FIELDS_AVAILABLE_DATE) {
return undefined
}
throw new Error(`Missing network for currency ${currencyCode}`)
const network = resolveNetworkCode(initialNetwork, currencyCode, isoDate)
if (network == null) {
return undefined
}
const network = initialNetwork

const networkUpper = network.toUpperCase()
const chainPluginId = LETSEXCHANGE_NETWORK_TO_PLUGIN_ID[networkUpper]
Expand Down
Loading
Loading