@@ -24,7 +24,6 @@ import {
2424 type SendParam ,
2525 type MessagingFee ,
2626 type LayerZeroBridgeRoute ,
27- type LayerZeroScanResponse ,
2827} from './layerZeroUtils.js' ;
2928
3029type TronWebLike = {
@@ -453,28 +452,33 @@ export class LayerZeroBridge implements IExternalBridge {
453452 const response = await this . fetchWithRetry (
454453 LAYERZERO_SCAN_API_URL + normalizedHash ,
455454 ) ;
456- const data : LayerZeroScanResponse = await response . json ( ) ;
455+ const responseData = await response . json ( ) ;
457456
458- if ( ! data . messages || data . messages . length === 0 ) {
457+ // LZ Scan API returns { data: [...] } with status at data[].status.name
458+ // and destination tx at data[].destination.tx.txHash
459+ const messages = responseData . data ?? responseData . messages ?? [ ] ;
460+ if ( ! messages || messages . length === 0 ) {
459461 return { status : 'not_found' } ;
460462 }
461463
462- const msg = data . messages [ 0 ] ;
464+ const msg = messages [ 0 ] ;
465+ const statusName = msg . status ?. name ?? msg . status ;
466+ const dstTxHash = msg . destination ?. tx ?. txHash ?? msg . dstTxHash ?? '' ;
463467
464- switch ( msg . status ) {
468+ switch ( statusName ) {
465469 case 'INFLIGHT' :
466470 return { status : 'pending' , substatus : 'INFLIGHT' } ;
467471 case 'DELIVERED' :
468472 return {
469473 status : 'complete' ,
470- receivingTxHash : msg . dstTxHash ?? '' ,
474+ receivingTxHash : dstTxHash ,
471475 receivedAmount : 0n ,
472476 } ;
473477 case 'FAILED' :
474478 case 'BLOCKED' :
475- return { status : 'failed' , error : msg . status } ;
479+ return { status : 'failed' , error : statusName } ;
476480 default :
477- return { status : 'pending' , substatus : msg . status } ;
481+ return { status : 'pending' , substatus : statusName } ;
478482 }
479483 }
480484
0 commit comments