-
Notifications
You must be signed in to change notification settings - Fork 16
fix: correct bundler JSON-RPC error mapping and getUserOperationByHash types #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4477253
fix: convert getUserOperationByHash userOperation fields to bigint
sherifahmed990 5d793f5
fix: stop mapping -32601 to INVALID_USEROPERATION_HASH
sherifahmed990 941ba26
fix: map -32508 to PAYMASTER_DEPOSIT_TOO_LOW and -32603 to INTERNAL_E…
sherifahmed990 e388fb6
Merge branch 'dev' into fix/bundler-error-mapping
sherifahmed990 f6341f5
fix: include V8/V9 in getUserOperationByHash result type
sherifahmed990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // getUserOperationByHash must convert the wire-format hex strings of the | ||
| // returned userOperation into the bigints its declared type promises, | ||
| // like getUserOperationReceipt and estimateUserOperationGas already do. | ||
|
|
||
| const ak = require("../../dist/index.cjs"); | ||
|
|
||
| const WIRE_V7_OP = { | ||
| sender: "0x1a02592A3484c2077d2E5D24482497F85e1980C6", | ||
| nonce: "0x0", | ||
| callData: "0x", | ||
| callGasLimit: "0x5208", | ||
| verificationGasLimit: "0x186a0", | ||
| preVerificationGas: "0xb3b0", | ||
| maxFeePerGas: "0x3b9aca00", | ||
| maxPriorityFeePerGas: "0x3b9aca00", | ||
| paymaster: "0x084f4dB6bae8fBb7fb9709c0A25532E21C7A097E", | ||
| paymasterVerificationGasLimit: "0x30d40", | ||
| paymasterPostOpGasLimit: "0xafc8", | ||
| paymasterData: "0x", | ||
| signature: "0x", | ||
| }; | ||
|
|
||
| describe("Bundler.getUserOperationByHash", () => { | ||
| function mockTransport(result) { | ||
| return { request: async () => result }; | ||
| } | ||
|
|
||
| test("converts numeric userOperation fields to bigint", async () => { | ||
| const b = new ak.Bundler( | ||
| mockTransport({ | ||
| userOperation: WIRE_V7_OP, | ||
| entryPoint: "0x0000000071727De22E5E9d8BAf0edAc6f37da032", | ||
| blockNumber: "0x10", | ||
| blockHash: "0x" + "ab".repeat(32), | ||
| transactionHash: "0x" + "cd".repeat(32), | ||
| }), | ||
| ); | ||
| const res = await b.getUserOperationByHash("0x" + "11".repeat(32)); | ||
| expect(res.blockNumber).toBe(16n); | ||
| expect(res.userOperation.nonce).toBe(0n); | ||
| expect(res.userOperation.callGasLimit).toBe(0x5208n); | ||
| expect(res.userOperation.verificationGasLimit).toBe(0x186a0n); | ||
| expect(res.userOperation.preVerificationGas).toBe(0xb3b0n); | ||
| expect(res.userOperation.maxFeePerGas).toBe(1000000000n); | ||
| expect(res.userOperation.maxPriorityFeePerGas).toBe(1000000000n); | ||
| expect(res.userOperation.paymasterVerificationGasLimit).toBe(0x30d40n); | ||
| expect(res.userOperation.paymasterPostOpGasLimit).toBe(0xafc8n); | ||
| // non-numeric fields untouched | ||
| expect(res.userOperation.sender).toBe(WIRE_V7_OP.sender); | ||
| expect(res.userOperation.signature).toBe("0x"); | ||
| }); | ||
|
|
||
| test("returns null for an unknown hash and keeps pending blockNumber null", async () => { | ||
| const bNull = new ak.Bundler(mockTransport(null)); | ||
| expect(await bNull.getUserOperationByHash("0x" + "22".repeat(32))).toBeNull(); | ||
|
|
||
| const bPending = new ak.Bundler( | ||
| mockTransport({ | ||
| userOperation: WIRE_V7_OP, | ||
| entryPoint: "0x0000000071727De22E5E9d8BAf0edAc6f37da032", | ||
| blockNumber: null, | ||
| blockHash: null, | ||
| transactionHash: null, | ||
| }), | ||
| ); | ||
| const res = await bPending.getUserOperationByHash("0x" + "33".repeat(32)); | ||
| expect(res.blockNumber).toBeNull(); | ||
| expect(res.userOperation.nonce).toBe(0n); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getUserOperationByHash()declares and casts its result as only V6/V7. See the types file as ell. should e include UserOperationV8 and UserOperationV9 in the result type?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done