@@ -45,22 +45,23 @@ export const asLetsExchangePluginParams = asObject({
4545 } )
4646} )
4747
48- const asLetsExchangeStatus = asValue (
49- 'wait' ,
50- 'confirmation' ,
51- 'confirmed' ,
52- 'exchanging' ,
53- 'overdue' ,
54- 'refund' ,
55- 'sending' ,
56- 'transferring' ,
57- 'sending_confirmation' ,
58- 'success' ,
59- 'aml_check_failed' ,
60- 'overdue' ,
61- 'error' ,
62- 'canceled' ,
63- 'refund'
48+ const asLetsExchangeStatus = asMaybe (
49+ asValue (
50+ 'wait' ,
51+ 'confirmation' ,
52+ 'confirmed' ,
53+ 'exchanging' ,
54+ 'overdue' ,
55+ 'refund' ,
56+ 'sending' ,
57+ 'transferring' ,
58+ 'sending_confirmation' ,
59+ 'success' ,
60+ 'aml_check_failed' ,
61+ 'error' ,
62+ 'canceled'
63+ ) ,
64+ 'other'
6465)
6566
6667// Cleaner for the new v2 API response
@@ -128,7 +129,8 @@ const statusMap: { [key in LetsExchangeStatus]: Status } = {
128129 success : 'complete' ,
129130 aml_check_failed : 'blocked' ,
130131 canceled : 'cancelled' ,
131- error : 'failed'
132+ error : 'failed' ,
133+ other : 'other'
132134}
133135
134136// Map LetsExchange network codes to Edge pluginIds
@@ -289,14 +291,15 @@ function getAssetInfo(
289291 initialNetwork : string | null ,
290292 currencyCode : string ,
291293 contractAddress : string | null ,
292- log : ScopedLog
294+ isoDate : string
293295) : AssetInfo | undefined {
294- let network = initialNetwork
295- if ( network == null ) {
296- // Try using the currencyCode as the network
297- network = currencyCode
298- log ( `Using currencyCode as network: ${ network } `)
296+ if ( initialNetwork == null ) {
297+ if ( isoDate < NETWORK_FIELDS_AVAILABLE_DATE ) {
298+ return undefined
299+ }
300+ throw new Error ( `Missing network for currency ${ currencyCode } `)
299301 }
302+ const network = initialNetwork
300303
301304 const networkUpper = network . toUpperCase ( )
302305 const chainPluginId = LETSEXCHANGE_NETWORK_TO_PLUGIN_ID [ networkUpper ]
@@ -500,14 +503,14 @@ export async function processLetsExchangeTx(
500503 tx . coin_from_network ?? tx . network_from_code ,
501504 tx . coin_from ,
502505 tx . coin_from_contract_address ,
503- log
506+ isoDate
504507 )
505508 // Get payout asset info using contract address from API response
506509 const payoutAsset = getAssetInfo (
507510 tx . coin_to_network ?? tx . network_to_code ,
508511 tx . coin_to ,
509512 tx . coin_to_contract_address ,
510- log
513+ isoDate
511514 )
512515
513516 const status = statusMap [ tx . status ]
0 commit comments