1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Add edge case handling for tx utilities (#19907)

This commit is contained in:
Nicholas Ellul 2023-07-06 19:48:38 -04:00 committed by Dan J Miller
parent 5a0749a08c
commit 524ab017c7
2 changed files with 15 additions and 1 deletions

View File

@ -176,7 +176,7 @@ export async function determineTransactionType(txParams, query) {
contractCode = resultCode;
if (isContractAddress) {
const hasValue = txParams.value && txParams.value !== '0x0';
const hasValue = txParams.value && Number(txParams.value) !== 0;
const tokenMethodName = [
TransactionType.tokenMethodApprove,

View File

@ -186,6 +186,20 @@ describe('Transaction.utils', function () {
getCodeResponse: '0xab',
});
const resultWithEmptyValue2 = await determineTransactionType(
{
value: '0x0000',
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data: '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
},
new EthQuery(_provider),
);
expect(resultWithEmptyValue2).toMatchObject({
type: TransactionType.tokenMethodTransfer,
getCodeResponse: '0xab',
});
const resultWithValue = await determineTransactionType(
{
value: '0x12345',