Skip to content

Commit 3952b49

Browse files
committed
fix: getSignInput bug for zero maxPriorityFeePerGas
Explicit zero value should not fallback to maxFeePerGas
1 parent 6476368 commit 3952b49

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class EIP712Signer {
110110
static getSignInput(transaction: TransactionRequest) {
111111
const maxFeePerGas = transaction.maxFeePerGas || transaction.gasPrice || 0n;
112112
const maxPriorityFeePerGas =
113-
transaction.maxPriorityFeePerGas || maxFeePerGas;
113+
transaction.maxPriorityFeePerGas ?? maxFeePerGas;
114114
const gasPerPubdataByteLimit =
115115
transaction.customData?.gasPerPubdata || DEFAULT_GAS_PER_PUBDATA_LIMIT;
116116
return {

tests/unit/signer.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,35 @@ describe('EIP712Signer', () => {
6363
});
6464
expect(result).to.be.deep.equal(tx);
6565
});
66+
67+
it('should correcly handle zero values', async () => {
68+
const tx = {
69+
txType: utils.EIP712_TX_TYPE,
70+
from: ADDRESS1,
71+
to: ADDRESS2,
72+
gasLimit: 0n,
73+
gasPerPubdataByteLimit: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
74+
maxFeePerGas: 250_000_000n,
75+
maxPriorityFeePerGas: 0n,
76+
paymaster: ethers.ZeroAddress,
77+
nonce: 0,
78+
value: 0n,
79+
data: '0x',
80+
factoryDeps: [],
81+
paymasterInput: '0x',
82+
};
83+
84+
const result = EIP712Signer.getSignInput({
85+
type: utils.EIP712_TX_TYPE,
86+
to: ADDRESS2,
87+
from: ADDRESS1,
88+
maxFeePerGas: 250_000_000n,
89+
maxPriorityFeePerGas: 0n,
90+
});
91+
expect(result).to.be.deep.equal(tx);
92+
});
6693
});
94+
});
6795

6896
describe('#getSignedDigest()', () => {
6997
it('should throw an error when chain ID is not specified', async () => {

0 commit comments

Comments
 (0)