import {
Web3Function,
Web3FunctionContext,
Web3FunctionFailContext,
Web3FunctionSuccessContext,
} from "@gelatonetwork/web3-functions-sdk";
import { Contract } from "@ethersproject/contracts";
import ky from "ky"; // Using ky for HTTP requests
const ORACLE_ABI = [
"function lastUpdated() external view returns(uint256)",
"function updatePrice(uint256)",
];
// Callback for successful execution
Web3Function.onSuccess(async (context: Web3FunctionSuccessContext) => {
const { transactionHash } = context;
//onSuccess Logic goes here
});
// Callback for handling failures
Web3Function.onFail(async (context: Web3FunctionFailContext) => {
const { reason, transactionHash, callData } = context;
//onFail Logic goes here
});
// Main function logic
Web3Function.onRun(async (context: Web3FunctionContext) => {
const { userArgs, multiChainProvider } = context;
// Core logic goes here to prepare callData
return {
canExec: false,
message: "Nothing to execute yet"
};
});