-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: keep provider original error (#100)
* fix: keep proxy provider original error * test: proxy provider originalError.data * chore: example decoding custom ABI error * chore: add changeset
- Loading branch information
Showing
5 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
"@gelatonetwork/web3-functions-sdk": patch | ||
--- | ||
|
||
fix: keep proxy provider original error |
This file contains 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 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 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,48 @@ | ||
import { | ||
Web3Function, | ||
Web3FunctionContext, | ||
} from "@gelatonetwork/web3-functions-sdk"; | ||
|
||
import { Contract } from "@ethersproject/contracts"; | ||
|
||
export const abi = [ | ||
{ | ||
inputs: [{ internalType: "uint256", name: "random", type: "uint256" }], | ||
name: "CustomError", | ||
type: "error", | ||
}, | ||
{ | ||
inputs: [{ internalType: "uint256", name: "_param", type: "uint256" }], | ||
name: "throwCustom", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
]; | ||
|
||
// To run against Arbitrum Sepolia: | ||
// yarn test src/web3-functions/custom-error/index.ts --logs --chain-id=421614 | ||
|
||
Web3Function.onRun(async (context: Web3FunctionContext) => { | ||
const ERRORS_CONTRACT = "0xac9f91277cCbb5d270e27246b203B221023A0e06"; | ||
|
||
const { multiChainProvider } = context; | ||
let provider = multiChainProvider.default(); | ||
|
||
const errorContract = new Contract(ERRORS_CONTRACT, abi, provider); | ||
|
||
try { | ||
const res = await errorContract.callStatic.throwCustom(10); | ||
} catch (error: any) { | ||
console.log("error message ", error.message); | ||
console.log("error data: ", error.data); | ||
const ei = errorContract.interface.parseError(error.data); | ||
console.log("error name: ", ei.name); | ||
console.log("error args: ", ei.args); | ||
} | ||
|
||
return { | ||
canExec: false, | ||
message: "executed", | ||
}; | ||
}); |
This file contains 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,8 @@ | ||
{ | ||
"web3FunctionVersion": "2.0.0", | ||
"runtime": "js-1.0", | ||
"memory": 128, | ||
"timeout": 30, | ||
"userArgs": {}, | ||
"executionMode": "sequential" | ||
} |