diff --git a/src/signer.ts b/src/signer.ts index af7018d..6db5b20 100644 --- a/src/signer.ts +++ b/src/signer.ts @@ -110,7 +110,7 @@ export class EIP712Signer { static getSignInput(transaction: TransactionRequest) { const maxFeePerGas = transaction.maxFeePerGas || transaction.gasPrice || 0n; const maxPriorityFeePerGas = - transaction.maxPriorityFeePerGas || maxFeePerGas; + transaction.maxPriorityFeePerGas ?? maxFeePerGas; const gasPerPubdataByteLimit = transaction.customData?.gasPerPubdata || DEFAULT_GAS_PER_PUBDATA_LIMIT; return { diff --git a/tests/unit/signer.test.ts b/tests/unit/signer.test.ts index c735084..0ae4c74 100644 --- a/tests/unit/signer.test.ts +++ b/tests/unit/signer.test.ts @@ -63,6 +63,33 @@ describe('EIP712Signer', () => { }); expect(result).to.be.deep.equal(tx); }); + + it('should correcly handle zero values', async () => { + const tx = { + txType: utils.EIP712_TX_TYPE, + from: ADDRESS1, + to: ADDRESS2, + gasLimit: 0n, + gasPerPubdataByteLimit: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, + maxFeePerGas: 250_000_000n, + maxPriorityFeePerGas: 0n, + paymaster: ethers.ZeroAddress, + nonce: 0, + value: 0n, + data: '0x', + factoryDeps: [], + paymasterInput: '0x', + }; + + const result = EIP712Signer.getSignInput({ + type: utils.EIP712_TX_TYPE, + to: ADDRESS2, + from: ADDRESS1, + maxFeePerGas: 250_000_000n, + maxPriorityFeePerGas: 0n, + }); + expect(result).to.be.deep.equal(tx); + }); }); describe('#getSignedDigest()', () => {