UNPKG

@hyperbridge/sdk

Version:

The hyperclient SDK provides utilities for querying proofs and statuses for cross-chain requests from HyperBridge.

2,143 lines (2,138 loc) 193 kB
import { createConsola, LogLevels } from 'consola'; import { flatten, zip, capitalize, maxBy, isNil } from 'lodash-es'; import { createPublicClient, http, hexToBytes, toHex, bytesToHex, encodeFunctionData, bytesToBigInt, pad, toBytes, keccak256, encodePacked, encodeAbiParameters, concatHex, parseUnits } from 'viem'; import mergeRace from '@async-generator/merge-race'; import { gnosisChiado, gnosis, bscTestnet, bsc, soneium, baseSepolia, base, optimismSepolia, optimism, arbitrumSepolia, arbitrum, mainnet } from 'viem/chains'; import { match } from 'ts-pattern'; import { WsProvider, ApiPromise } from '@polkadot/api'; import { RpcWebSocketClient } from 'rpc-websocket-client'; import { Vector, u8, Struct, Tuple, Enum, _void, u64, u32, Option, bool, u128 } from 'scale-ts'; import { keccakAsU8a, decodeAddress, xxhashAsU8a } from '@polkadot/util-crypto'; import { hasWindow, isNode, env } from 'std-env'; import { GraphQLClient } from 'graphql-request'; import { u8aToHex } from '@polkadot/util'; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // src/utils/ckb-mmr-wasm/dist/web/web.js var web_exports = {}; __export(web_exports, { KeccakMerge: () => KeccakMerge, default: () => web_default, generate_root_with_proof: () => generate_root_with_proof, initSync: () => initSync, verify_proof: () => verify_proof }); function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } function passStringToWasm0(arg, malloc, realloc) { if (realloc === void 0) { const buf = cachedTextEncoder.encode(arg); const ptr2 = malloc(buf.length, 1) >>> 0; getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr2; } let len = arg.length; let ptr = malloc(len, 1) >>> 0; const mem = getUint8ArrayMemory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 127) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; } function isLikeNone(x) { return x === void 0 || x === null; } function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) { cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } return cachedDataViewMemory0; } function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1, 1) >>> 0; getUint8ArrayMemory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } function takeFromExternrefTable0(idx) { const value = wasm.__wbindgen_export_0.get(idx); wasm.__externref_table_dealloc(idx); return value; } function generate_root_with_proof(calldata_bytes, tree_size) { let deferred3_0; let deferred3_1; try { const ptr0 = passArray8ToWasm0(calldata_bytes, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.generate_root_with_proof(ptr0, len0, tree_size); var ptr2 = ret[0]; var len2 = ret[1]; if (ret[3]) { ptr2 = 0; len2 = 0; throw takeFromExternrefTable0(ret[2]); } deferred3_0 = ptr2; deferred3_1 = len2; return getStringFromWasm0(ptr2, len2); } finally { wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); } } function addToExternrefTable0(obj) { const idx = wasm.__externref_table_alloc(); wasm.__wbindgen_export_0.set(idx, obj); return idx; } function passArrayJsValueToWasm0(array, malloc) { const ptr = malloc(array.length * 4, 4) >>> 0; for (let i = 0; i < array.length; i++) { const add = addToExternrefTable0(array[i]); getDataViewMemory0().setUint32(ptr + 4 * i, add, true); } WASM_VECTOR_LEN = array.length; return ptr; } function verify_proof(root_hex, proof_hex, mmr_size, leaf_position, calldata_bytes) { const ptr0 = passStringToWasm0(root_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; const ptr1 = passArrayJsValueToWasm0(proof_hex, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ptr2 = passArray8ToWasm0(calldata_bytes, wasm.__wbindgen_malloc); const len2 = WASM_VECTOR_LEN; const ret = wasm.verify_proof(ptr0, len0, ptr1, len1, mmr_size, leaf_position, ptr2, len2); if (ret[2]) { throw takeFromExternrefTable0(ret[1]); } return ret[0] !== 0; } async function __wbg_load(module, imports) { if (typeof Response === "function" && module instanceof Response) { if (typeof WebAssembly.instantiateStreaming === "function") { try { return await WebAssembly.instantiateStreaming(module, imports); } catch (e) { if (module.headers.get("Content-Type") != "application/wasm") { console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); } else { throw e; } } } const bytes = await module.arrayBuffer(); return await WebAssembly.instantiate(bytes, imports); } else { const instance = await WebAssembly.instantiate(module, imports); if (instance instanceof WebAssembly.Instance) { return { instance, module }; } else { return instance; } } } function __wbg_get_imports() { const imports = {}; imports.wbg = {}; imports.wbg.__wbindgen_error_new = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return ret; }; imports.wbg.__wbindgen_init_externref_table = function() { const table = wasm.__wbindgen_export_0; const offset = table.grow(4); table.set(0, void 0); table.set(offset + 0, void 0); table.set(offset + 1, null); table.set(offset + 2, true); table.set(offset + 3, false); }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { const obj = arg1; const ret = typeof obj === "string" ? obj : void 0; var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); var len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; return imports; } function __wbg_finalize_init(instance, module) { wasm = instance.exports; __wbg_init.__wbindgen_wasm_module = module; cachedDataViewMemory0 = null; cachedUint8ArrayMemory0 = null; wasm.__wbindgen_start(); return wasm; } function initSync(module) { if (wasm !== void 0) return wasm; if (typeof module !== "undefined") { if (Object.getPrototypeOf(module) === Object.prototype) { ({ module } = module); } else { console.warn("using deprecated parameters for `initSync()`; pass a single object instead"); } } const imports = __wbg_get_imports(); if (!(module instanceof WebAssembly.Module)) { module = new WebAssembly.Module(module); } const instance = new WebAssembly.Instance(module, imports); return __wbg_finalize_init(instance, module); } async function __wbg_init(module_or_path) { if (wasm !== void 0) return wasm; if (typeof module_or_path !== "undefined") { if (Object.getPrototypeOf(module_or_path) === Object.prototype) { ({ module_or_path } = module_or_path); } else { console.warn("using deprecated parameters for the initialization function; pass a single object instead"); } } if (typeof module_or_path === "undefined") { module_or_path = new URL("web_bg.wasm", import.meta.url); } const imports = __wbg_get_imports(); if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) { module_or_path = fetch(module_or_path); } const { instance, module } = await __wbg_load(await module_or_path, imports); return __wbg_finalize_init(instance, module); } var wasm, cachedTextDecoder, cachedUint8ArrayMemory0, WASM_VECTOR_LEN, cachedTextEncoder, encodeString, cachedDataViewMemory0, KeccakMergeFinalization, KeccakMerge, web_default; var init_web = __esm({ "src/utils/ckb-mmr-wasm/dist/web/web.js"() { cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error("TextDecoder not available"); } }; if (typeof TextDecoder !== "undefined") { cachedTextDecoder.decode(); } cachedUint8ArrayMemory0 = null; WASM_VECTOR_LEN = 0; cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => { throw Error("TextEncoder not available"); } }; encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function(arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }; cachedDataViewMemory0 = null; KeccakMergeFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { }, unregister: () => { } } : new FinalizationRegistry((ptr) => wasm.__wbg_keccakmerge_free(ptr >>> 0, 1)); KeccakMerge = class { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; KeccakMergeFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_keccakmerge_free(ptr, 0); } }; web_default = __wbg_init; } }); // src/queries.ts var POST_REQUEST_STATUS = ` query RequestStatusM($hash: String!) { requests( filter: { commitment: { equalTo: $hash } } ) { nodes { commitment timeoutTimestamp source dest to from nonce body statusMetadata { nodes { blockHash blockNumber timestamp chain status transactionHash } } } } } `; var GET_REQUEST_STATUS = ` query GetRequestDetails($commitment: String!) { getRequests( filter: { commitment: { equalTo: $commitment } } ) { nodes { id source dest from keys nonce height context timeoutTimestamp fee blockNumber blockHash transactionHash blockTimestamp status chain commitment statusMetadata { nodes { status chain timestamp blockNumber blockHash transactionHash } } } } }`; var STATE_MACHINE_UPDATES_BY_HEIGHT = ` query StateMachineUpdatesByHeight($statemachineId: String!, $height: Int!, $chain: String!) { stateMachineUpdateEvents( filter: { and: [ { stateMachineId: { equalTo: $statemachineId } } { height: { greaterThanOrEqualTo: $height } } { chain: { equalTo: $chain } } ] } orderBy: HEIGHT_ASC first: 1 ) { nodes { height stateMachineId chain blockHash blockNumber transactionHash createdAt } } } `; var STATE_MACHINE_UPDATES_BY_TIMESTAMP = ` query StateMachineUpdatesByTimestamp($statemachineId: String!, $commitmentTimestamp: BigFloat!, $chain: String!) { stateMachineUpdateEvents( filter: { and: [ { stateMachineId: { equalTo: $statemachineId } } { commitmentTimestamp: { greaterThanOrEqualTo: $commitmentTimestamp } } { chain: { equalTo: $chain } } ] } orderBy: COMMITMENT_TIMESTAMP_DESC first: 1 ) { nodes { height stateMachineId chain blockHash blockNumber transactionHash commitmentTimestamp createdAt } } } `; var ASSET_TELEPORTED_BY_PARAMS = ` query AssetTeleportedByParams($from: String!, $to: String!, $dest: String!, $blockNumber: Int!) { assetTeleporteds( filter: { and: [ { from: { equalTo: $from } } { to: { equalTo: $to } } { dest: { includes: $dest } } { blockNumber: { greaterThanOrEqualTo: $blockNumber } } ] } orderBy: CREATED_AT_DESC first: 1 ) { nodes { id from to amount dest commitment createdAt blockNumber } } } `; var GET_RESPONSE_BY_REQUEST_ID = ` query GetResponseByRequestId($requestId: String!) { getResponses(filter: {requestId: {equalTo: $requestId}}) { nodes { id commitment responseMessage } } } `; var ORDER_STATUS = ` query OrderStatus($commitment: String!) { orderPlaceds( filter: { commitment: { equalTo: $commitment } } ) { nodes { id user sourceChain destChain commitment deadline nonce fees inputTokens inputAmounts inputValuesUSD inputUSD outputTokens outputAmounts outputBeneficiaries calldata status createdAt blockNumber blockTimestamp transactionHash statusMetadata { nodes { status chain timestamp blockNumber transactionHash filler } } } } }`; var TOKEN_GATEWAY_ASSET_TELEPORTED_STATUS = ` query TokenGatewayAssetTeleportedStatus($commitment: String!) { tokenGatewayAssetTeleporteds( filter: { commitment: { equalTo: $commitment } } ) { nodes { id from to sourceChain destChain commitment amount usdValue assetId redeem status createdAt blockNumber blockTimestamp transactionHash statusMetadata { nodes { status chain timestamp blockNumber transactionHash } } } } }`; // src/types/index.ts var RequestStatus = Object.freeze({ SOURCE: "SOURCE", SOURCE_FINALIZED: "SOURCE_FINALIZED", HYPERBRIDGE_DELIVERED: "HYPERBRIDGE_DELIVERED", HYPERBRIDGE_FINALIZED: "HYPERBRIDGE_FINALIZED", DESTINATION: "DESTINATION", TIMED_OUT: "TIMED_OUT", HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT" }); var TimeoutStatus = Object.freeze({ PENDING_TIMEOUT: "PENDING_TIMEOUT", DESTINATION_FINALIZED_TIMEOUT: "DESTINATION_FINALIZED_TIMEOUT", HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT", HYPERBRIDGE_FINALIZED_TIMEOUT: "HYPERBRIDGE_FINALIZED_TIMEOUT", TIMED_OUT: "TIMED_OUT" }); var HyperClientStatus = /* @__PURE__ */ ((HyperClientStatus2) => { HyperClientStatus2["PENDING"] = "PENDING"; HyperClientStatus2["SOURCE_FINALIZED"] = "SOURCE_FINALIZED"; HyperClientStatus2["HYPERBRIDGE_FINALIZED"] = "HYPERBRIDGE_FINALIZED"; HyperClientStatus2["HYPERBRIDGE_VERIFIED"] = "HYPERBRIDGE_VERIFIED"; HyperClientStatus2["DESTINATION"] = "DESTINATION"; HyperClientStatus2["TIMED_OUT"] = "TIMED_OUT"; HyperClientStatus2["HYPERBRIDGE_TIMED_OUT"] = "HYPERBRIDGE_TIMED_OUT"; HyperClientStatus2["ERROR"] = "ERROR"; return HyperClientStatus2; })(HyperClientStatus || {}); var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => { OrderStatus2["PLACED"] = "PLACED"; OrderStatus2["FILLED"] = "FILLED"; OrderStatus2["REDEEMED"] = "REDEEMED"; OrderStatus2["REFUNDED"] = "REFUNDED"; return OrderStatus2; })(OrderStatus || {}); var TeleportStatus = /* @__PURE__ */ ((TeleportStatus2) => { TeleportStatus2["TELEPORTED"] = "TELEPORTED"; TeleportStatus2["RECEIVED"] = "RECEIVED"; TeleportStatus2["REFUNDED"] = "REFUNDED"; return TeleportStatus2; })(TeleportStatus || {}); var RequestKind = /* @__PURE__ */ ((RequestKind2) => { RequestKind2[RequestKind2["RedeemEscrow"] = 0] = "RedeemEscrow"; RequestKind2[RequestKind2["NewDeployment"] = 1] = "NewDeployment"; RequestKind2[RequestKind2["UpdateParams"] = 2] = "UpdateParams"; return RequestKind2; })(RequestKind || {}); var EvmLanguage = /* @__PURE__ */ ((EvmLanguage2) => { EvmLanguage2[EvmLanguage2["Solidity"] = 0] = "Solidity"; EvmLanguage2[EvmLanguage2["Vyper"] = 1] = "Vyper"; return EvmLanguage2; })(EvmLanguage || {}); var AbortSignalInternal = class _AbortSignalInternal extends Error { constructor(message) { super(); this.name = "AbortSignalInternal"; this.message = message; } static isError(error) { return error instanceof _AbortSignalInternal; } }; // src/abis/evmHost.ts var ABI = [ { inputs: [], name: "CannotChangeFeeToken", type: "error" }, { inputs: [], name: "DuplicateResponse", type: "error" }, { inputs: [], name: "FrozenHost", type: "error" }, { inputs: [], name: "InvalidAddressLength", type: "error" }, { inputs: [], name: "InvalidConsensusClient", type: "error" }, { inputs: [], name: "InvalidHandler", type: "error" }, { inputs: [], name: "InvalidHostManager", type: "error" }, { inputs: [], name: "InvalidHyperbridgeId", type: "error" }, { inputs: [], name: "InvalidStateMachinesLength", type: "error" }, { inputs: [], name: "InvalidUnstakingPeriod", type: "error" }, { inputs: [], name: "MaxFishermanCountExceeded", type: "error" }, { inputs: [], name: "UnauthorizedAccount", type: "error" }, { inputs: [], name: "UnauthorizedAction", type: "error" }, { inputs: [], name: "UnauthorizedResponse", type: "error" }, { inputs: [], name: "UnknownRequest", type: "error" }, { inputs: [], name: "UnknownResponse", type: "error" }, { inputs: [], name: "WithdrawalFailed", type: "error" }, { anonymous: false, inputs: [ { indexed: false, internalType: "string", name: "source", type: "string" }, { indexed: false, internalType: "string", name: "dest", type: "string" }, { indexed: true, internalType: "address", name: "from", type: "address" }, { indexed: false, internalType: "bytes[]", name: "keys", type: "bytes[]" }, { indexed: false, internalType: "uint256", name: "height", type: "uint256" }, { indexed: false, internalType: "uint256", name: "nonce", type: "uint256" }, { indexed: false, internalType: "uint256", name: "timeoutTimestamp", type: "uint256" }, { indexed: false, internalType: "bytes", name: "context", type: "bytes" }, { indexed: false, internalType: "uint256", name: "fee", type: "uint256" } ], name: "GetRequestEvent", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "address", name: "relayer", type: "address" } ], name: "GetRequestHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "string", name: "dest", type: "string" } ], name: "GetRequestTimeoutHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "enum FrozenStatus", name: "status", type: "uint8" } ], name: "HostFrozen", type: "event" }, { anonymous: false, inputs: [ { components: [ { internalType: "uint256", name: "defaultTimeout", type: "uint256" }, { internalType: "uint256", name: "perByteFee", type: "uint256" }, { internalType: "uint256", name: "stateCommitmentFee", type: "uint256" }, { internalType: "address", name: "feeToken", type: "address" }, { internalType: "address", name: "admin", type: "address" }, { internalType: "address", name: "handler", type: "address" }, { internalType: "address", name: "hostManager", type: "address" }, { internalType: "address", name: "uniswapV2", type: "address" }, { internalType: "uint256", name: "unStakingPeriod", type: "uint256" }, { internalType: "uint256", name: "challengePeriod", type: "uint256" }, { internalType: "address", name: "consensusClient", type: "address" }, { internalType: "uint256[]", name: "stateMachines", type: "uint256[]" }, { internalType: "address[]", name: "fishermen", type: "address[]" }, { internalType: "bytes", name: "hyperbridge", type: "bytes" } ], indexed: false, internalType: "struct HostParams", name: "oldParams", type: "tuple" }, { components: [ { internalType: "uint256", name: "defaultTimeout", type: "uint256" }, { internalType: "uint256", name: "perByteFee", type: "uint256" }, { internalType: "uint256", name: "stateCommitmentFee", type: "uint256" }, { internalType: "address", name: "feeToken", type: "address" }, { internalType: "address", name: "admin", type: "address" }, { internalType: "address", name: "handler", type: "address" }, { internalType: "address", name: "hostManager", type: "address" }, { internalType: "address", name: "uniswapV2", type: "address" }, { internalType: "uint256", name: "unStakingPeriod", type: "uint256" }, { internalType: "uint256", name: "challengePeriod", type: "uint256" }, { internalType: "address", name: "consensusClient", type: "address" }, { internalType: "uint256[]", name: "stateMachines", type: "uint256[]" }, { internalType: "address[]", name: "fishermen", type: "address[]" }, { internalType: "bytes", name: "hyperbridge", type: "bytes" } ], indexed: false, internalType: "struct HostParams", name: "newParams", type: "tuple" } ], name: "HostParamsUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "amount", type: "uint256" }, { indexed: false, internalType: "address", name: "beneficiary", type: "address" }, { indexed: false, internalType: "bool", name: "native", type: "bool" } ], name: "HostWithdrawal", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "string", name: "source", type: "string" }, { indexed: false, internalType: "string", name: "dest", type: "string" }, { indexed: true, internalType: "address", name: "from", type: "address" }, { indexed: false, internalType: "bytes", name: "to", type: "bytes" }, { indexed: false, internalType: "uint256", name: "nonce", type: "uint256" }, { indexed: false, internalType: "uint256", name: "timeoutTimestamp", type: "uint256" }, { indexed: false, internalType: "bytes", name: "body", type: "bytes" }, { indexed: false, internalType: "uint256", name: "fee", type: "uint256" } ], name: "PostRequestEvent", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "address", name: "relayer", type: "address" } ], name: "PostRequestHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "string", name: "dest", type: "string" } ], name: "PostRequestTimeoutHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "string", name: "source", type: "string" }, { indexed: false, internalType: "string", name: "dest", type: "string" }, { indexed: true, internalType: "address", name: "from", type: "address" }, { indexed: false, internalType: "bytes", name: "to", type: "bytes" }, { indexed: false, internalType: "uint256", name: "nonce", type: "uint256" }, { indexed: false, internalType: "uint256", name: "timeoutTimestamp", type: "uint256" }, { indexed: false, internalType: "bytes", name: "body", type: "bytes" }, { indexed: false, internalType: "bytes", name: "response", type: "bytes" }, { indexed: false, internalType: "uint256", name: "responseTimeoutTimestamp", type: "uint256" }, { indexed: false, internalType: "uint256", name: "fee", type: "uint256" } ], name: "PostResponseEvent", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "newFee", type: "uint256" } ], name: "PostResponseFunded", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "address", name: "relayer", type: "address" } ], name: "PostResponseHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "string", name: "dest", type: "string" } ], name: "PostResponseTimeoutHandled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "commitment", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "newFee", type: "uint256" } ], name: "RequestFunded", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "caller", type: "address" }, { indexed: false, internalType: "uint256", name: "fee", type: "uint256" } ], name: "StateCommitmentRead", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "string", name: "stateMachineId", type: "string" }, { indexed: false, internalType: "uint256", name: "height", type: "uint256" }, { components: [ { internalType: "uint256", name: "timestamp", type: "uint256" }, { internalType: "bytes32", name: "overlayRoot", type: "bytes32" }, { internalType: "bytes32", name: "stateRoot", type: "bytes32" } ], indexed: false, internalType: "struct StateCommitment", name: "stateCommitment", type: "tuple" }, { indexed: true, internalType: "address", name: "fisherman", type: "address" } ], name: "StateCommitmentVetoed", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "string", name: "stateMachineId", type: "string" }, { indexed: false, internalType: "uint256", name: "height", type: "uint256" } ], name: "StateMachineUpdated", type: "event" }, { inputs: [], name: "admin", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "chainId", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "challengePeriod", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "consensusClient", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "consensusState", outputs: [ { internalType: "bytes", name: "", type: "bytes" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "consensusUpdateTime", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { components: [ { internalType: "uint256", name: "stateMachineId", type: "uint256" }, { internalType: "uint256", name: "height", type: "uint256" } ], internalType: "struct StateMachineHeight", name: "height", type: "tuple" }, { internalType: "address", name: "fisherman", type: "address" } ], name: "deleteStateMachineCommitment", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "bytes", name: "from", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes", name: "body", type: "bytes" } ], internalType: "struct PostRequest", name: "request", type: "tuple" }, { internalType: "bytes", name: "response", type: "bytes" }, { internalType: "uint64", name: "timeout", type: "uint64" }, { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "address", name: "payer", type: "address" } ], internalType: "struct DispatchPostResponse", name: "post", type: "tuple" } ], name: "dispatch", outputs: [ { internalType: "bytes32", name: "commitment", type: "bytes32" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "bytes", name: "body", type: "bytes" }, { internalType: "uint64", name: "timeout", type: "uint64" }, { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "address", name: "payer", type: "address" } ], internalType: "struct DispatchPost", name: "post", type: "tuple" } ], name: "dispatch", outputs: [ { internalType: "bytes32", name: "commitment", type: "bytes32" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "height", type: "uint64" }, { internalType: "bytes[]", name: "keys", type: "bytes[]" }, { internalType: "uint64", name: "timeout", type: "uint64" }, { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "bytes", name: "context", type: "bytes" } ], internalType: "struct DispatchGet", name: "get", type: "tuple" } ], name: "dispatch", outputs: [ { internalType: "bytes32", name: "commitment", type: "bytes32" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "bytes", name: "from", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes", name: "body", type: "bytes" } ], internalType: "struct PostRequest", name: "request", type: "tuple" }, { internalType: "bytes", name: "response", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" } ], internalType: "struct PostResponse", name: "response", type: "tuple" }, { internalType: "address", name: "relayer", type: "address" } ], name: "dispatchIncoming", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "bytes", name: "from", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes", name: "body", type: "bytes" } ], internalType: "struct PostRequest", name: "request", type: "tuple" }, { internalType: "address", name: "relayer", type: "address" } ], name: "dispatchIncoming", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "address", name: "from", type: "address" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes[]", name: "keys", type: "bytes[]" }, { internalType: "uint64", name: "height", type: "uint64" }, { internalType: "bytes", name: "context", type: "bytes" } ], internalType: "struct GetRequest", name: "request", type: "tuple" }, { components: [ { internalType: "bytes", name: "key", type: "bytes" }, { internalType: "bytes", name: "value", type: "bytes" } ], internalType: "struct StorageValue[]", name: "values", type: "tuple[]" } ], internalType: "struct GetResponse", name: "response", type: "tuple" }, { internalType: "address", name: "relayer", type: "address" } ], name: "dispatchIncoming", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "bytes", name: "from", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes", name: "body", type: "bytes" } ], internalType: "struct PostRequest", name: "request", type: "tuple" }, { internalType: "bytes", name: "response", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" } ], internalType: "struct PostResponse", name: "response", type: "tuple" }, { components: [ { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "address", name: "sender", type: "address" } ], internalType: "struct FeeMetadata", name: "meta", type: "tuple" }, { internalType: "bytes32", name: "commitment", type: "bytes32" } ], name: "dispatchTimeOut", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "bytes", name: "from", type: "bytes" }, { internalType: "bytes", name: "to", type: "bytes" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes", name: "body", type: "bytes" } ], internalType: "struct PostRequest", name: "request", type: "tuple" }, { components: [ { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "address", name: "sender", type: "address" } ], internalType: "struct FeeMetadata", name: "meta", type: "tuple" }, { internalType: "bytes32", name: "commitment", type: "bytes32" } ], name: "dispatchTimeOut", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { internalType: "bytes", name: "source", type: "bytes" }, { internalType: "bytes", name: "dest", type: "bytes" }, { internalType: "uint64", name: "nonce", type: "uint64" }, { internalType: "address", name: "from", type: "address" }, { internalType: "uint64", name: "timeoutTimestamp", type: "uint64" }, { internalType: "bytes[]", name: "keys", type: "bytes[]" }, { internalType: "uint64", name: "height", type: "uint64" }, { internalType: "bytes", name: "context", type: "bytes" } ], internalType: "struct GetRequest", name: "request", type: "tuple" }, { components: [ { internalType: "uint256", name: "fee", type: "uint256" }, { internalType: "address", name: "sender", type: "address" } ], internalType: "struct FeeMetadata", name: "meta", type: "tuple" }, { internalType: "bytes32", name: "commitment", type: "bytes32" } ], name: "dispatchTimeOut", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "feeToken", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "frozen", outputs: [ { internalType: "enum FrozenStatus", name: "", type: "uint8" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes32", name: "commitment", type: "bytes32" }, { internalType: "uint256", name: "amount", type: "uint256" } ], name: "fundRequest", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "commitment", type: "bytes32" }, { internalType: "uint256", name: "amount", type: "uint256" } ], name: "fundResponse", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [], name: "host", outputs: [ { internalType: "bytes", name: "", type: "bytes" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "hostParams", outputs: [ { components: [ { internalType: "uint256", name: "defaultTimeout", type: "uint256" }, { internalType: "uint256", name: "perByteFee", type: "uint256" }, { internalType: "uint256", name: "stateCommitmentFee", type: "uint256" }, { internalType: "address", name: "feeToken", type: "address" }, { internalType: "address", name: "admin", type: "address" }, { internalType: "address", name: "handler", type: "address" }, { internalType: "address", name: "hostManager", type: "address" }, { internalType: "address", name: "uniswapV2", type: "