mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Add edge case handling for tx utilities (#19907)
This commit is contained in:
parent
5a0749a08c
commit
524ab017c7
@ -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,
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user