@@ -21,10 +21,12 @@ interface WormholeScanTransaction {
21
21
content : {
22
22
payload : {
23
23
amount : string ;
24
+ fee ?: string ;
24
25
callerAppId : string ;
25
26
fromAddress : string ;
26
27
parsedPayload : {
27
- feeAmount : string ;
28
+ feeAmount ?: string ;
29
+ relayerFee ?: string ;
28
30
recipientWallet : string ;
29
31
toNativeAmount : string ;
30
32
} ;
@@ -127,7 +129,7 @@ const useTransactionHistoryWHScan = (
127
129
const parseSingleTx = useCallback (
128
130
async ( tx : WormholeScanTransaction ) => {
129
131
const { content, data, sourceChain, targetChain } = tx ;
130
- const { standarizedProperties } = content || { } ;
132
+ const { standarizedProperties, payload } = content || { } ;
131
133
132
134
const fromChainId =
133
135
standarizedProperties . fromChain || sourceChain ?. chainId ;
@@ -193,10 +195,21 @@ const useTransactionHistoryWHScan = (
193
195
) ;
194
196
}
195
197
196
- if ( standarizedProperties . amount && standarizedProperties . fee ) {
198
+ if ( standarizedProperties . amount ) {
199
+ // Parse fee to calculate receive amount
200
+ // WHScan API should parse the payload and set it under standarizedProperties, but that's not the case.
201
+ // There are multiple props that can persist the fee value depending on the protocol.
202
+ // There is no clear documentation around the set of props specific to protocols, therefore we need to check them all.
203
+ const fee =
204
+ standarizedProperties . fee ||
205
+ payload . fee ||
206
+ payload . parsedPayload ?. feeAmount ||
207
+ payload . parsedPayload ?. relayerFee ||
208
+ '0' ;
209
+
197
210
const receiveAmountValue =
198
- BigInt ( standarizedProperties . amount ) -
199
- BigInt ( standarizedProperties . fee ) ;
211
+ BigInt ( standarizedProperties . amount ) - BigInt ( fee ) ;
212
+
200
213
// It's unlikely, but in case the above subtraction returns a non-positive number,
201
214
// we should not show that at all.
202
215
if ( receiveAmountValue > 0 ) {
0 commit comments