Skip to content

Commit

Permalink
fix: getSignInput bug for zero maxPriorityFeePerGas
Browse files Browse the repository at this point in the history
Explicit zero value should not fallback to maxFeePerGas
  • Loading branch information
everdimension committed Dec 18, 2024
1 parent 6476368 commit 157620b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/signer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down

0 comments on commit 157620b

Please sign in to comment.