Skip to content

Commit

Permalink
fix: ID-2791 Fix zero nonce issue for ejection transactions (#2373)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenfowler authored Nov 7, 2024
1 parent b09cd73 commit 26387ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/passport/sdk/src/mocks/zkEvm/msw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const relayerId = '0x745';
export const transactionHash = '0x867';

const mandatoryHandlers = [
rest.get('https://api.sandbox.immutable.com/v1/sdk/session-activity/check', async (req, res, ctx) => res(ctx.status(404))),
rest.post('https://rpc.testnet.immutable.com', async (req, res, ctx) => {
const body = await req.json<JsonRpcRequestPayload>();
switch (body.method) {
Expand Down
23 changes: 23 additions & 0 deletions packages/passport/sdk/src/zkEvm/transactionHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,28 @@ describe('transactionHelpers', () => {
flow,
})).rejects.toThrow('Transaction send failed');
});

describe('when the nonce is 0', () => {
it('prepares and signs transaction correctly', async () => {
const result = await prepareAndSignTransaction({
transactionRequest: {
...transactionRequest,
nonce: 0,
},
ethSigner,
rpcProvider,
guardianClient,
relayerClient,
zkEvmAddress,
flow,
});

expect(result).toEqual({
signedTransactions,
relayerId,
nonce,
});
});
});
});
});
2 changes: 1 addition & 1 deletion packages/passport/sdk/src/zkEvm/transactionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const buildMetaTransactionForEjection = async (
);
}

if (!transactionRequest.nonce) {
if (typeof transactionRequest.nonce === 'undefined') {
throw new JsonRpcError(
RpcErrorCode.INVALID_PARAMS,
'im_signEjectionTransaction requires a "nonce" field',
Expand Down

0 comments on commit 26387ba

Please sign in to comment.