Skip to content

Fix/properly parse unknown types #228

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 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gorgeous-pumpkins-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added support for parsing revert data from kakarot, rootstock-testnet & fuse to "getSenderAddress"
2 changes: 1 addition & 1 deletion .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name": "permissionless (esm)",
"path": "./packages/permissionless/_esm/index.js",
"limit": "40 kB",
"limit": "50 kB",
"import": "*"
},
{
Expand Down
34 changes: 28 additions & 6 deletions packages/permissionless/actions/public/getSenderAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,20 @@ export const getSenderAddress = async <
if (callExecutionError.cause.name === "RpcRequestError") {
const revertError =
callExecutionError.cause as RpcRequestErrorType
// biome-ignore lint/suspicious/noExplicitAny: fuse issues
const data = (revertError as unknown as any).cause.data.split(
" "
)[1]

const hexStringRegex = /0x[a-fA-F0-9]+/
// biome-ignore lint/suspicious/noExplicitAny:
const match = (revertError as unknown as any).cause.data.match(
hexStringRegex
)

if (!match) {
throw new Error(
"Failed to parse revert bytes from RPC response"
)
}

const data: Hex = match[0]

const error = decodeErrorResult({
abi: [
Expand All @@ -180,8 +190,20 @@ export const getSenderAddress = async <
//Ganache local testing returns "InvalidInputRpcError" with data in regular format
const revertError =
callExecutionError.cause as RpcRequestErrorType
// biome-ignore lint/suspicious/noExplicitAny: fuse issues
const data = (revertError as unknown as any).cause.data

const hexStringRegex = /0x[a-fA-F0-9]+/
// biome-ignore lint/suspicious/noExplicitAny:
const match = (revertError as unknown as any).cause.data.match(
hexStringRegex
)

if (!match) {
throw new Error(
"Failed to parse revert bytes from RPC response"
)
}

const data: Hex = match[0]

const error = decodeErrorResult({
abi: [
Expand Down
Loading