File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -279,10 +279,9 @@ export function processBitrefillTx(
279279 const timestamp = tx . invoiceTime / 1000
280280
281281 const { paymentMethod } = tx
282- let depositAmountStr : string | undefined
283- if ( paymentMethod === 'bitcoin' ) {
284- depositAmountStr = tx . btcPrice
285- } else if ( tx . altcoinPrice != null ) {
282+ // Fallback to btcPrice when altcoinPrice is unexpectedly missing.
283+ let depositAmountStr : string | undefined = tx . btcPrice
284+ if ( paymentMethod !== 'bitcoin' && tx . altcoinPrice != null ) {
286285 depositAmountStr = tx . altcoinPrice
287286 }
288287 if ( depositAmountStr == null ) {
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ export const asLetsExchangePluginParams = asObject({
4040 latestIsoDate : asOptional ( asString , LETSEXCHANGE_START_DATE )
4141 } ) ,
4242 apiKeys : asObject ( {
43- affiliateId : asString ,
44- apiKey : asString
43+ affiliateId : asOptional ( asString ) ,
44+ apiKey : asOptional ( asString )
4545 } )
4646} )
4747
@@ -484,6 +484,10 @@ export async function processLetsExchangeTx(
484484 const { apiKey } = apiKeys
485485 const { log } = pluginParams
486486
487+ if ( apiKey == null ) {
488+ throw new Error ( 'Missing LetsExchange apiKey' )
489+ }
490+
487491 await fetchCoinCache ( apiKey , log )
488492
489493 const tx = asLetsExchangeTx ( rawTx )
Original file line number Diff line number Diff line change @@ -312,9 +312,14 @@ export function processTx(rawTx: unknown): StandardTx {
312312 // Map Moonpay status to Edge status
313313 const status : Status = statusMap [ tx . status ] ?? 'other'
314314
315- // Determine direction based on paymentMethod vs payoutMethod
316- // Buy transactions have paymentMethod, sell transactions have payoutMethod
317- const direction = tx . paymentMethod != null ? 'buy' : 'sell'
315+ // Determine direction based on sell-specific fields.
316+ // Sell transactions can also include paymentMethod, so that field alone is insufficient.
317+ const direction =
318+ tx . quoteCurrency != null ||
319+ tx . payoutMethod != null ||
320+ tx . depositHash != null
321+ ? 'sell'
322+ : 'buy'
318323
319324 // Get the payout currency - different field names for buy vs sell
320325 const payoutCurrency = direction === 'buy' ? tx . currency : tx . quoteCurrency
You can’t perform that action at this time.
0 commit comments