mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Change transaction type for send with approve transaction (#17777)
This commit is contained in:
parent
74ef8e4fa4
commit
41e2c2beff
@ -184,8 +184,13 @@ export async function determineTransactionType(txParams, query) {
|
||||
TransactionType.tokenMethodSafeTransferFrom,
|
||||
].find((methodName) => isEqualCaseInsensitive(methodName, name));
|
||||
|
||||
const isSendWithApprove =
|
||||
txParams.value &&
|
||||
txParams.value !== '0x0' &&
|
||||
tokenMethodName === TransactionType.tokenMethodApprove;
|
||||
|
||||
result =
|
||||
data && tokenMethodName
|
||||
data && tokenMethodName && !isSendWithApprove
|
||||
? tokenMethodName
|
||||
: TransactionType.contractInteraction;
|
||||
} else {
|
||||
|
@ -306,5 +306,30 @@ describe('Transaction.utils', function () {
|
||||
getCodeResponse: '0x0a',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return contractInteraction for send with approve', async function () {
|
||||
const _providerResultStub = {
|
||||
// 1 gwei
|
||||
eth_gasPrice: '0x0de0b6b3a7640000',
|
||||
// by default, all accounts are external accounts (not contracts)
|
||||
eth_getCode: '0xa',
|
||||
};
|
||||
const _provider = createTestProviderTools({
|
||||
scaffold: _providerResultStub,
|
||||
}).provider;
|
||||
|
||||
const result = await determineTransactionType(
|
||||
{
|
||||
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
|
||||
value: '0x5af3107a4000',
|
||||
data: '0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005',
|
||||
},
|
||||
new EthQuery(_provider),
|
||||
);
|
||||
expect(result).toMatchObject({
|
||||
type: TransactionType.contractInteraction,
|
||||
getCodeResponse: '0x0a',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user