Skip to content

Commit

Permalink
fix: ERC-7821 return type
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 3, 2025
1 parent f5736ce commit c822da1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-apes-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed ERC-7821 `getExecuteError` return type.
17 changes: 9 additions & 8 deletions src/experimental/erc7821/utils/getExecuteError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getExecuteError<const calls extends readonly unknown[]>(
| (BaseError & { data?: Hex | undefined })
| undefined

if (!error?.data) throw e
if (!error?.data) return e as never
if (
error.data ===
AbiError.getSelector(AbiError.from('error FnSelectorNotRecognized()'))
Expand All @@ -55,12 +55,13 @@ export function getExecuteError<const calls extends readonly unknown[]>(
matched = call
} catch {}
}
if (!matched) throw e
if (matched)
return getContractError(error as BaseError, {
abi: matched.abi as Abi,
address: matched.to,
args: matched.args,
functionName: matched.functionName,
})

return getContractError(error as BaseError, {
abi: matched.abi as Abi,
address: matched.to,
args: matched.args,
functionName: matched.functionName,
})
return e as never
}

0 comments on commit c822da1

Please sign in to comment.