Skip to content

Commit

Permalink
Merge pull request #228 from pimlicolabs/fix/properly-parse-unknown-t…
Browse files Browse the repository at this point in the history
…ypes

Fix/properly parse unknown types
  • Loading branch information
plusminushalf authored Jul 2, 2024
2 parents 7415711 + 3e41a32 commit 1a29e31
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
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

0 comments on commit 1a29e31

Please sign in to comment.