@@ -71,42 +71,51 @@ export interface TransactionStatus {
71
71
} ;
72
72
}
73
73
74
- export interface RelayData {
75
- from : {
76
- chain : string ;
77
- chainId : number ;
78
- txHash : string ;
79
- senderAddress : string ;
80
- symbol : string ;
81
- amountSent : number ;
82
- amountToSwap : number ;
83
- estimatedNativeAssetAmount : number ;
84
- } ;
85
- vaa : string ;
86
- status : string ;
87
- fee : {
88
- amount : number ;
89
- symbol : string ;
90
- } ;
91
- error : any ;
92
- to : {
93
- chain : string ;
94
- chainId : number ;
95
- recipientAddress : string ;
96
- txHash : string ;
97
- gasUsed : number ;
98
- nativeAssetSymbol : string ;
99
- nativeAssetReceived : number ;
100
- } ;
101
- metrics : {
102
- receivedAt : string ;
103
- completedAt : string ;
104
- failedAt : any ;
105
- attempts : number ;
74
+ export interface RelayStatus {
75
+ completedAt : string ;
76
+ data : {
77
+ delivery : {
78
+ budget : string ;
79
+ execution : {
80
+ detail : string ;
81
+ gasUsed : string ;
82
+ refundStatus : string ;
83
+ revertString : string ;
84
+ status : string ;
85
+ transactionHash : string ;
86
+ } ;
87
+ maxRefund : string ;
88
+ relayGasUsed : number ;
89
+ targetChainDecimals : number ;
90
+ } ;
91
+ fromTxHash : string ;
92
+ instructions : {
93
+ encodedExecutionInfo : string ;
94
+ extraReceiverValue : {
95
+ _hex : string ;
96
+ _isBigNumber : boolean ;
97
+ } ;
98
+ refundAddress : string ;
99
+ refundChainId : number ;
100
+ refundDeliveryProvider : string ;
101
+ requestedReceiverValue : {
102
+ _hex : string ;
103
+ _isBigNumber : boolean ;
104
+ } ;
105
+ senderAddress : string ;
106
+ sourceDeliveryProvider : string ;
107
+ targetAddress : string ;
108
+ targetChainId : number ;
109
+ vaaKeys : string [ ] ;
110
+ } ;
106
111
maxAttempts : number ;
107
- waitingForTxInMs : number ;
108
- waitingForWalletInMs : number ;
112
+ toTxHash : string ;
109
113
} ;
114
+ failedAt : string ;
115
+ id : string ;
116
+ receivedAt : string ;
117
+ relayer : string ;
118
+ status : string ;
110
119
}
111
120
112
121
export interface ApiVaa {
@@ -235,11 +244,17 @@ export async function getTransactionStatusWithRetry(
235
244
) ;
236
245
}
237
246
238
- export async function getRelayStatus ( rpcUrl : string , txid : TxHash ) : Promise < RelayData | null > {
239
- const url = `${ rpcUrl } /v1/relays?txHash=${ txid } ` ;
247
+ export async function getRelayStatus (
248
+ rpcUrl : string ,
249
+ whm : WormholeMessageId ,
250
+ ) : Promise < RelayStatus | null > {
251
+ const { chain, emitter, sequence } = whm ;
252
+ const chainId = toChainId ( chain ) ;
253
+ const emitterAddress = emitter . toUniversalAddress ( ) . toString ( ) ;
254
+ const url = `${ rpcUrl } /api/v1/relays/${ chainId } /${ emitterAddress } /${ sequence } ` ;
240
255
try {
241
- const response = await axios . get < { data : RelayData } > ( url ) ;
242
- if ( response . data . data . to . txHash ) return response . data . data ;
256
+ const response = await axios . get < RelayStatus > ( url ) ;
257
+ return response . data || null ;
243
258
} catch ( error ) {
244
259
if ( ! error ) return null ;
245
260
if ( typeof error === "object" ) {
@@ -250,16 +265,15 @@ export async function getRelayStatus(rpcUrl: string, txid: TxHash): Promise<Rela
250
265
}
251
266
throw error ;
252
267
}
253
- return null ;
254
268
}
255
269
256
270
export async function getRelayStatusWithRetry (
257
271
rpcUrl : string ,
258
- txid : TxHash ,
272
+ whm : WormholeMessageId ,
259
273
timeout : number ,
260
- ) : Promise < RelayData | null > {
261
- const task = ( ) => getRelayStatus ( rpcUrl , txid ) ;
262
- return retry < RelayData > ( task , WHSCAN_RETRY_INTERVAL , timeout , "Wormholescan:GetRelayStatus" ) ;
274
+ ) : Promise < RelayStatus | null > {
275
+ const task = ( ) => getRelayStatus ( rpcUrl , whm ) ;
276
+ return retry < RelayStatus > ( task , WHSCAN_RETRY_INTERVAL , timeout , "Wormholescan:GetRelayStatus" ) ;
263
277
}
264
278
265
279
export async function getVaaByTxHash ( rpcUrl : string , txid : string ) : Promise < ApiVaa | null > {
0 commit comments