Skip to content

Commit

Permalink
fix: getUserOperationError for UserOp execution reverted 0x (#2879)
Browse files Browse the repository at this point in the history
* check calls from GetUserOperationErrorParameters before getting revert data

* Create rare-fishes-bow.md

---------

Co-authored-by: jxom <j@wevm.dev>
lwin-kyaw and jxom authored Oct 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9a9c2ad commit 8b34dd7
Showing 4 changed files with 55 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-fishes-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed `getUserOperationError` runtime error.
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions src/account-abstraction/utils/errors/getUserOperationError.test.ts
Original file line number Diff line number Diff line change
@@ -563,3 +563,50 @@ test('bundler error', () => {
Version: viem@x.y.z]
`)
})

test('bundler error (execution reverted without calls)', () => {
const error = new RpcRequestError({
body: {},
error: {
code: -32521,
message: 'UserOperation reverted during simulation with reason: 0x',
},
url: '',
})
const result = getUserOperationError(error, {
callData: '0xdeadbeef',
callGasLimit: 1n,
nonce: 1n,
preVerificationGas: 1n,
verificationGasLimit: 1n,
signature: '0xdeadbeef',
sender: '0xdeadbeef',
factory: '0x0000000000000000000000000000000000000000',
factoryData: '0xdeadbeef',
maxFeePerGas: 1n,
maxPriorityFeePerGas: 2n,
paymasterData: '0xdeadbeef',
paymaster: '0xffff',
})
expect(result).toMatchInlineSnapshot(`
[UserOperationExecutionError: Execution reverted with reason: UserOperation reverted during simulation with reason: 0x.
Request Arguments:
callData: 0xdeadbeef
callGasLimit: 1
factory: 0x0000000000000000000000000000000000000000
factoryData: 0xdeadbeef
maxFeePerGas: 0.000000001 gwei
maxPriorityFeePerGas: 0.000000002 gwei
nonce: 1
paymaster: 0xffff
paymasterData: 0xdeadbeef
preVerificationGas: 1
sender: 0xdeadbeef
signature: 0xdeadbeef
verificationGasLimit: 1
Details: UserOperation reverted during simulation with reason: 0x
Version: viem@x.y.z]
`)
})
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export function getUserOperationError<err extends ErrorType<string>>(
err as {} as BaseError,
args as GetBundlerErrorParameters,
)
if (cause instanceof ExecutionRevertedError) {
if (calls && cause instanceof ExecutionRevertedError) {
const revertData = getRevertData(cause)
const contractCalls = calls?.filter(
(call: any) => call.abi || call.data,

0 comments on commit 8b34dd7

Please sign in to comment.