Skip to content

Commit 0d9b0e0

Browse files
committed
Fix error that occurs when attempting to display transaction value for an approval transaction with no value argument in the transaction data
1 parent bca9a61 commit 0d9b0e0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ui/hooks/useTokenDisplayValue.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,26 @@ export function useTokenDisplayValue(
3535
isTokenTransaction = true,
3636
) {
3737
const tokenData = useTokenData(transactionData, isTokenTransaction);
38+
const tokenValue = getTokenValueParam(tokenData);
39+
3840
const shouldCalculateTokenValue = Boolean(
3941
// If we are currently processing a token transaction
4042
isTokenTransaction &&
4143
// and raw transaction data string is provided
4244
transactionData &&
4345
// and a token object has been provided
4446
token &&
45-
// and we are able to parse the token details from the raw data
46-
tokenData?.args?.length,
47+
// and the provided token object contains a defined decimal value we need to calculate amount
48+
token.decimals &&
49+
// and we are able to parse the token detail we to calculate amount from the raw data
50+
tokenValue,
4751
);
4852

4953
const displayValue = useMemo(() => {
5054
if (!shouldCalculateTokenValue) {
5155
return null;
5256
}
53-
const tokenValue = getTokenValueParam(tokenData);
57+
5458
return calcTokenAmount(tokenValue, token.decimals).toString(10);
5559
}, [shouldCalculateTokenValue, tokenData, token]);
5660

0 commit comments

Comments
 (0)