mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
Add edge case handling for tx utilities (#19907)
This commit is contained in:
parent
f829f0069d
commit
e0f99600a4
@ -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