Skip to content

Commit 5124c42

Browse files
Adds 'tokenMethodIncreaseAllowance'
1 parent eda6a6a commit 5124c42

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/transaction-controller/src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ export enum TransactionType {
566566
* spend on behalf of the user.
567567
*/
568568
tokenMethodSetApprovalForAll = 'setapprovalforall',
569+
570+
/**
571+
* Increase the allowance by a given increment
572+
*/
573+
tokenMethodIncreaseAllowance = 'increaseAllowance',
569574
}
570575

571576
/**

packages/transaction-controller/src/utils/transaction-type.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { TransactionDescription } from '@ethersproject/abi';
22
import { Interface } from '@ethersproject/abi';
33
import { query } from '@metamask/controller-utils';
44
import type EthQuery from '@metamask/eth-query';
5-
import { abiERC721, abiERC20, abiERC1155 } from '@metamask/metamask-eth-abis';
5+
import { abiERC721, abiERC20, abiERC1155, USDC_ABI } from '@metamask/metamask-eth-abis';
66

77
import type { InferTransactionTypeResult, TransactionParams } from '../types';
88
import { TransactionType } from '../types';
@@ -12,6 +12,7 @@ export const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';
1212
const ERC20Interface = new Interface(abiERC20);
1313
const ERC721Interface = new Interface(abiERC721);
1414
const ERC1155Interface = new Interface(abiERC1155);
15+
const USDCInterface = new Interface(USDC_ABI);
1516

1617
/**
1718
* Determines the type of the transaction by analyzing the txParams.
@@ -62,7 +63,8 @@ export async function determineTransactionType(
6263
TransactionType.tokenMethodTransfer,
6364
TransactionType.tokenMethodTransferFrom,
6465
TransactionType.tokenMethodSafeTransferFrom,
65-
].find((methodName) => methodName.toLowerCase() === name.toLowerCase());
66+
TransactionType.tokenMethodIncreaseAllowance,
67+
].find((methodName) => methodName.toLowerCase() === (name as string).toLowerCase());
6668

6769
if (tokenMethodName) {
6870
return { type: tokenMethodName, getCodeResponse };
@@ -104,6 +106,12 @@ function parseStandardTokenTransactionData(
104106
// ignore and return undefined
105107
}
106108

109+
try {
110+
return USDCInterface.parseTransaction({ data });
111+
} catch {
112+
// ignore and return undefined
113+
}
114+
107115
return undefined;
108116
}
109117

0 commit comments

Comments
 (0)