mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix error that occurs when attempting to display transaction value for an approval transaction with no value argument in the transaction data (#15398)
This commit is contained in:
parent
f503a634f0
commit
d363bdbb21
@ -35,6 +35,8 @@ export function useTokenDisplayValue(
|
|||||||
isTokenTransaction = true,
|
isTokenTransaction = true,
|
||||||
) {
|
) {
|
||||||
const tokenData = useTokenData(transactionData, isTokenTransaction);
|
const tokenData = useTokenData(transactionData, isTokenTransaction);
|
||||||
|
const tokenValue = getTokenValueParam(tokenData);
|
||||||
|
|
||||||
const shouldCalculateTokenValue = Boolean(
|
const shouldCalculateTokenValue = Boolean(
|
||||||
// If we are currently processing a token transaction
|
// If we are currently processing a token transaction
|
||||||
isTokenTransaction &&
|
isTokenTransaction &&
|
||||||
@ -42,15 +44,17 @@ export function useTokenDisplayValue(
|
|||||||
transactionData &&
|
transactionData &&
|
||||||
// and a token object has been provided
|
// and a token object has been provided
|
||||||
token &&
|
token &&
|
||||||
// and we are able to parse the token details from the raw data
|
// and the provided token object contains a defined decimal value we need to calculate amount
|
||||||
tokenData?.args?.length,
|
token.decimals &&
|
||||||
|
// and we are able to parse the token detail we to calculate amount from the raw data
|
||||||
|
tokenValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
const displayValue = useMemo(() => {
|
const displayValue = useMemo(() => {
|
||||||
if (!shouldCalculateTokenValue) {
|
if (!shouldCalculateTokenValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const tokenValue = getTokenValueParam(tokenData);
|
|
||||||
return calcTokenAmount(tokenValue, token.decimals).toString(10);
|
return calcTokenAmount(tokenValue, token.decimals).toString(10);
|
||||||
}, [shouldCalculateTokenValue, tokenData, token]);
|
}, [shouldCalculateTokenValue, tokenData, token]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user