Bug Description
validateGasFeeParams in @metamask/transaction-controller throws when a transaction includes both gasPrice and maxFeePerGas/maxPriorityFeePerGas, even when the transaction type is explicitly 0x2 (EIP-1559). Instead of stripping the redundant gasPrice and proceeding, MetaMask rejects the transaction entirely.
Steps to Reproduce
Some RPCs return gasPrice alongside EIP-1559 fee fields. For example, Arbitrum's eth_fillTransaction:
curl -s -X POST https://arbitrum-one.publicnode.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_fillTransaction",
"params": [{
"from": "0x0000000000000000000000000000000000000001",
"to": "0x0000000000000000000000000000000000000001",
"value": "0x0",
"type": "0x2"
}]
}'
Response:
{
"result": {
"tx": {
"type": "0x2",
"gasPrice": "0x0",
"maxFeePerGas": "0x2e28680",
"maxPriorityFeePerGas": "0x0",
"gas": "0x5f12",
"chainId": "0xa4b1"
}
}
}
When a dapp submits a transaction containing these fields to MetaMask, it rejects with:
Invalid transaction envelope type: specified type "0x2" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas
Expected Behavior
When a transaction includes both gasPrice and maxFeePerGas/maxPriorityFeePerGas with a fee-market type (0x2 or 0x4), MetaMask should gracefully prefer the EIP-1559 fields and strip the redundant gasPrice, rather than rejecting the transaction.
Additional Context
- Originally filed as wevm/viem#4323
- The relevant validation is in
packages/transaction-controller/src/utils/validation.ts, in validateGasFeeParams which calls ensureMutuallyExclusiveFieldsNotProvided
Bug Description
validateGasFeeParamsin@metamask/transaction-controllerthrows when a transaction includes bothgasPriceandmaxFeePerGas/maxPriorityFeePerGas, even when the transactiontypeis explicitly0x2(EIP-1559). Instead of stripping the redundantgasPriceand proceeding, MetaMask rejects the transaction entirely.Steps to Reproduce
Some RPCs return
gasPricealongside EIP-1559 fee fields. For example, Arbitrum'seth_fillTransaction:Response:
{ "result": { "tx": { "type": "0x2", "gasPrice": "0x0", "maxFeePerGas": "0x2e28680", "maxPriorityFeePerGas": "0x0", "gas": "0x5f12", "chainId": "0xa4b1" } } }When a dapp submits a transaction containing these fields to MetaMask, it rejects with:
Expected Behavior
When a transaction includes both
gasPriceandmaxFeePerGas/maxPriorityFeePerGaswith a fee-market type (0x2or0x4), MetaMask should gracefully prefer the EIP-1559 fields and strip the redundantgasPrice, rather than rejecting the transaction.Additional Context
packages/transaction-controller/src/utils/validation.ts, invalidateGasFeeParamswhich callsensureMutuallyExclusiveFieldsNotProvided