UNPKG

@bnb-chain/canonical-bridge-sdk

Version:
2,289 lines (2,279 loc) 276 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const viem = require('viem'); const oftV2SolanaSdk = require('@layerzerolabs/oft-v2-solana-sdk'); const umiBundleDefaults = require('@metaplex-foundation/umi-bundle-defaults'); const web3_js = require('@solana/web3.js'); const lzV2Utilities = require('@layerzerolabs/lz-v2-utilities'); const umiWeb3jsAdapters = require('@metaplex-foundation/umi-web3js-adapters'); const umiSignerWalletAdapters = require('@metaplex-foundation/umi-signer-wallet-adapters'); const mplToolbox = require('@metaplex-foundation/mpl-toolbox'); const umi = require('@metaplex-foundation/umi'); const bs58 = require('bs58'); const axios = require('axios'); const swapSdk = require('@mayanfinance/swap-sdk'); const CLIENT_TIME_OUT = 60 * 1e3; const ESTIMATE_AMOUNT_DATA_RELOAD = 3e4; const EXPLORER_URL = { cBridge: "https://celerscan.com/tx/", deBridge: "https://app.debridge.finance/orders?s=" }; const VALIDATION_API_TIMEOUT = 10 * 1e3; const EVM_NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000"; const SOLANA_NATIVE_TOKEN_ADDRESS = "11111111111111111111111111111111"; const TRON_CHAIN_ID = 728126428; const SOLANA_CHAIN_ID = 7565164; const SOLANA_CHAIN_EID = 30168; const DEFAULT_SOLANA_ADDRESS = "J7JYXS8PMMBgfFKP1bqUu7mGgWyWUDL9xqfYujznc61r"; function isSameAddress(A, B) { if (!A || !B) return false; if (isEvmAddress(A) && isEvmAddress(B)) { return A.toLowerCase() === B.toLowerCase(); } return A === B; } function isEvmAddress(address) { return !!address && /^0x[a-f0-9]{40}$/i.test(address); } function isNativeToken(tokenAddress = EVM_NATIVE_TOKEN_ADDRESS, chainType = "evm") { if (chainType === "solana") { return [SOLANA_NATIVE_TOKEN_ADDRESS, EVM_NATIVE_TOKEN_ADDRESS].includes(tokenAddress); } return tokenAddress === EVM_NATIVE_TOKEN_ADDRESS; } function isSolanaAddress(address) { return !!address && /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address); } function isTronAddress(address) { return !!address && /^T[a-zA-Z0-9]{33}$/.test(address); } const isValidTokenAddress = ({ contractAddress, chainType, isSourceChain }) => { const fromOrTo = isSourceChain ? "from" : "to"; if (chainType === "evm") { if (!isEvmAddress(contractAddress)) { console.log( `Invalid evm ${fromOrTo} contract address`, chainType, contractAddress ); return false; } } else if (chainType === "solana") { if (!isSolanaAddress(contractAddress)) { console.log( `Invalid solana ${fromOrTo} contract address`, chainType, contractAddress ); return false; } } else { console.log(`Invalid ${fromOrTo} chain type`, chainType, contractAddress); return false; } return true; }; function isEmpty(obj) { return !obj || Object.entries(obj).length === 0; } function uniqueArr(arr) { const map = /* @__PURE__ */ new Map(); return arr.filter((item) => { if (map.get(item)) { return false; } map.set(item, true); return true; }); } class BaseAdapter { options; config; excludedChains = []; excludedTokens = {}; assetPrefix = ""; nativeCurrencies = {}; brandChains = []; externalChains = []; displayTokenSymbols = {}; chainConfigs = []; chains = []; chainMap = /* @__PURE__ */ new Map(); tokenMap = /* @__PURE__ */ new Map(); symbolMap = /* @__PURE__ */ new Map(); transferMap = /* @__PURE__ */ new Map(); constructor(options) { this.options = options; this.config = options.config ?? {}; this.excludedChains = options.excludedChains ?? []; this.excludedTokens = options.excludedTokens ?? {}; this.assetPrefix = options?.assetPrefix ?? ""; this.brandChains = options?.brandChains ?? []; this.externalChains = options?.externalChains ?? []; this.displayTokenSymbols = options?.displayTokenSymbols ?? {}; this.chainConfigs = options?.chainConfigs ?? []; this.nativeCurrencies = options?.nativeCurrencies ?? {}; } init() { this.initChains(); this.initTokens(); this.initTransferMap(); this.filterTransferMap(); return this; } filterTransferMap() { if (!this.brandChains.length) { return; } const filteredTransferMap = /* @__PURE__ */ new Map(); this.transferMap.forEach((toMap, fromChainId) => { if (this.brandChains.includes(fromChainId)) { filteredTransferMap.set(fromChainId, toMap); } else { toMap.forEach((tokenPairMap, toChainId) => { if (this.brandChains.includes(toChainId)) { if (!filteredTransferMap.has(fromChainId)) { filteredTransferMap.set( fromChainId, /* @__PURE__ */ new Map() ); } filteredTransferMap.get(fromChainId)?.set(toChainId, tokenPairMap); } }); } }); this.transferMap = filteredTransferMap; } getChainBaseInfo(chainId) { const chainConfig = this.chainConfigs.find((e) => e.id === chainId); const explorerConfig = chainConfig?.blockExplorers?.default ?? {}; const explorerUrl = explorerConfig?.url?.replace(/\/$/, "") ?? ""; const tmpUrlPattern = explorerUrl ? `${explorerUrl}/token/{0}` : ""; const tokenUrlPattern = explorerConfig?.tokenUrlPattern || tmpUrlPattern; const externalConfig = this.externalChains?.find( (item) => item.chainId === chainId ); const chainType = externalConfig ? "link" : chainConfig?.chainType ?? "evm"; const externalBridgeUrl = externalConfig?.bridgeUrl; return { id: chainId, name: chainConfig?.name ?? "", icon: `${this.assetPrefix}/images/chains/${chainId}.png?v=${1754446442795}`, explorerUrl, tokenUrlPattern, chainType, externalBridgeUrl }; } getTokenDisplaySymbolAndIcon({ chainId, defaultSymbol, tokenAddress, icon }) { const symbolMap = this.displayTokenSymbols[chainId] ?? {}; const target = Object.entries(symbolMap).find( ([address]) => isSameAddress(address, tokenAddress) ); const displaySymbol = target?.[1] ?? defaultSymbol; const iconSymbol = displaySymbol?.toUpperCase(); const commonTokenIcon = `${this.assetPrefix}/images/tokens/${iconSymbol}.png?v=${1754446442795}`; return { displaySymbol, icon: icon || commonTokenIcon }; } getToTokensForPair({ fromChainId, toChainId, fromTokenSymbol }) { const fromNativeSymbol = this.nativeCurrencies[fromChainId].symbol.toUpperCase(); const toNativeSymbol = this.nativeCurrencies[toChainId].symbol.toUpperCase(); const tokenMap = this.symbolMap.get(toChainId); const toTokens = [...tokenMap?.get(fromTokenSymbol) ?? []]; if (["ETH", "WETH"].includes(fromTokenSymbol) && (fromNativeSymbol === "ETH" || toNativeSymbol === "ETH") && this.id === "deBridge") { const ethTokens = tokenMap?.get("ETH") ?? []; const wethTokens = tokenMap?.get("WETH") ?? []; toTokens.push(...ethTokens); toTokens.push(...wethTokens); } const bridgedGroup = this.bridgedTokenGroups.find( (e) => e.includes(fromTokenSymbol) ); bridgedGroup?.forEach((anotherTokenSymbol) => { const anotherToTokens = tokenMap?.get(anotherTokenSymbol.toUpperCase()); if (anotherToTokens?.length) { toTokens.push(...anotherToTokens); } }); return uniqueArr(toTokens); } getTokenSymbolByTokenAddress({ chainId, tokenAddress }) { const tokens = this.tokenMap.get(chainId); let baseInfo; const token = tokens?.find((t) => { baseInfo = this.getTokenBaseInfo({ chainId, token: t }); return isSameAddress(baseInfo.address, tokenAddress); }); if (token) { return baseInfo?.symbol?.toUpperCase(); } } getChainById(chainId) { return this.chainMap.get(chainId); } getFromChains() { const fromChainIds = new Set(this.transferMap.keys()); const fromChains = this.chains.filter( (chain) => fromChainIds.has(this.getChainId(chain)) ); return fromChains; } getToChains({ fromChainId }) { const toChainIds = new Set(this.transferMap.get(fromChainId)?.keys()); const toChains = this.chains.filter( (chain) => toChainIds.has(this.getChainId(chain)) ); return toChains; } getAllTokenPairsOnFromChain({ fromChainId, toChainId }) { const all = /* @__PURE__ */ new Map(); this.transferMap.get(fromChainId)?.forEach((toMap) => { toMap.forEach((tokenPairs, tokenAddress) => { all.set(tokenAddress, tokenPairs); }); }); this.transferMap.get(fromChainId)?.get(toChainId)?.forEach((tokenPairs, tokenAddress) => { all.set(tokenAddress, tokenPairs); }); return Array.from(all.values()); } getTokenPairs({ fromChainId, toChainId, tokenAddress }) { return this.transferMap.get(fromChainId)?.get(toChainId)?.get(tokenAddress?.toLowerCase()); } getTokenPair({ fromChainId, toChainId, fromTokenAddress, toTokenAddress }) { const tokenPairs = this.getTokenPairs({ fromChainId, toChainId, tokenAddress: fromTokenAddress }); return tokenPairs?.find( (e) => isSameAddress(e.toTokenAddress, toTokenAddress) ); } isExcludedToken({ chainId, tokenSymbol, tokenAddress }) { const excludedTokens = this.excludedTokens[chainId] ?? []; return excludedTokens?.some( (e) => e.toUpperCase() === tokenSymbol.toUpperCase() || isSameAddress(e, tokenAddress) ); } isToChainCompatible({ fromChainId, toChainId }) { return !!this.transferMap.get(fromChainId)?.get(toChainId); } isTokenCompatible(params) { return !!this.getTokenPairs(params); } } class CBridgeAdapter extends BaseAdapter { id = "cBridge"; bridgedTokenGroups = []; peggedPairConfigs = []; burnPairConfigs = []; init() { this.initChains(); this.initTokens(); this.initPeggedPairConfigs(); this.initBurnPairConfigs(); this.initTransferMap(); this.filterTransferMap(); return this; } initChains() { const { chains, chain_token, pegged_pair_configs } = this.config; const filteredChains = chains.filter((chain) => { const hasChainConfig = !!this.chainConfigs.find((e) => e.id === chain.id); const isExcludedChain = this.excludedChains.includes(chain.id); const hasEnabledToken = chain_token[chain.id]?.token?.some( (e) => !e.token.xfer_disabled ); const hasPeggedToken = pegged_pair_configs.some( (e) => (e.org_chain_id === chain.id || e.pegged_chain_id === chain.id) && !e.org_token.token.xfer_disabled && !e.pegged_token.token.xfer_disabled ); return hasChainConfig && !isExcludedChain && (hasEnabledToken || hasPeggedToken); }); const chainMap = /* @__PURE__ */ new Map(); filteredChains.forEach((chain) => { chainMap.set(chain.id, chain); }); this.chains = filteredChains; this.chainMap = chainMap; } initTokens() { const { chain_token } = this.config; const tokenMap = /* @__PURE__ */ new Map(); const symbolMap = /* @__PURE__ */ new Map(); Object.entries(chain_token).forEach(([id, { token: chainTokens }]) => { const chainId = Number(id); const filteredTokens = chainTokens.filter((token) => { const isEnabledToken = !token.token.xfer_disabled; const isExcludedToken = this.isExcludedToken({ chainId, tokenSymbol: token.token.symbol?.toUpperCase(), tokenAddress: token.token.address }); return isEnabledToken && !isExcludedToken; }); if (filteredTokens.length > 0 && this.chainMap.has(chainId)) { symbolMap.set(chainId, /* @__PURE__ */ new Map()); filteredTokens.forEach((token) => { const tokenSymbol = token.token.symbol?.toUpperCase(); if (!symbolMap.get(chainId)?.get(tokenSymbol)) { symbolMap.get(chainId)?.set(tokenSymbol, []); } symbolMap.get(chainId)?.get(tokenSymbol)?.push(token); }); tokenMap.set(chainId, filteredTokens); } }); this.tokenMap = tokenMap; this.symbolMap = symbolMap; } initTransferMap() { const transferMap = /* @__PURE__ */ new Map(); this.chains.forEach((fromChain) => { this.chains.forEach((toChain) => { if (fromChain.id !== toChain.id) { const fromTokens = this.tokenMap.get(fromChain.id) ?? []; const tokenPairsMap = /* @__PURE__ */ new Map(); fromTokens.forEach((fromToken) => { const fromTokenSymbol = fromToken.token.symbol?.toUpperCase(); const isBlocked = this.isBlockedPair({ fromChainId: fromChain.id, toChainId: toChain.id, tokenSymbol: fromTokenSymbol }); if (isBlocked) { return; } const toTokens = this.getToTokensForPair({ fromChainId: fromChain.id, toChainId: toChain.id, fromTokenSymbol }); if (toTokens?.length) { const tokenPairs = []; toTokens.forEach((toToken) => { tokenPairs.push({ fromChainId: fromChain.id, toChainId: toChain.id, fromTokenAddress: fromToken.token.address, toTokenAddress: toToken.token.address, fromToken, toToken }); }); tokenPairsMap.set( fromToken.token.address?.toLowerCase(), tokenPairs ); } }); if (tokenPairsMap.size > 0) { if (!transferMap.has(fromChain.id)) { transferMap.set( fromChain.id, /* @__PURE__ */ new Map() ); } transferMap.get(fromChain.id)?.set(toChain.id, tokenPairsMap); } } }); }); const addPeggedTokenPair = (fromChainId, fromToken, toChainId, toToken, item) => { const isBlocked = this.isBlockedPair({ fromChainId, toChainId, tokenSymbol: fromToken.token.symbol }); if (isBlocked) { return; } const addressKey = fromToken.token.address?.toLowerCase(); if (!transferMap.get(fromChainId)?.get(toChainId)?.get(addressKey)) { const peggedTokenPair = { fromChainId, toChainId, fromTokenAddress: fromToken.token.address, toTokenAddress: toToken.token.address, fromToken, toToken, isPegged: true, peggedConfig: item }; if (!transferMap.has(fromChainId)) { transferMap.set( fromChainId, /* @__PURE__ */ new Map() ); } if (!transferMap.get(fromChainId)?.get(toChainId)) { transferMap.get(fromChainId)?.set(toChainId, /* @__PURE__ */ new Map()); } if (!transferMap.get(fromChainId)?.get(toChainId)?.get(addressKey)) { transferMap.get(fromChainId)?.get(toChainId)?.set(addressKey, []); } transferMap.get(fromChainId)?.get(toChainId)?.get(addressKey)?.push(peggedTokenPair); } }; this.peggedPairConfigs.forEach((item) => { const fromChainId = item.org_chain_id; const fromToken = item.org_token; const toChainId = item.pegged_chain_id; const toToken = item.pegged_token; addPeggedTokenPair(fromChainId, fromToken, toChainId, toToken, item); addPeggedTokenPair(toChainId, toToken, fromChainId, fromToken, item); }); this.transferMap = transferMap; } initPeggedPairConfigs() { const peggedPairConfigs = this.config.pegged_pair_configs; const isAvailablePair = (chainId, token) => { const hasChain = this.chainMap.has(chainId); const isEnabledToken = !token.token.xfer_disabled; const isExcludedToken = this.isExcludedToken({ chainId, tokenSymbol: token.token.symbol, tokenAddress: token.token.address }); return hasChain && isEnabledToken && !isExcludedToken; }; const filteredPeggedPairConfigs = peggedPairConfigs.filter( (item) => isAvailablePair(item.org_chain_id, item.org_token) && isAvailablePair(item.pegged_chain_id, item.pegged_token) ); this.peggedPairConfigs = filteredPeggedPairConfigs; } initBurnPairConfigs() { const burnPairConfigs = []; for (let i = 0; i < this.peggedPairConfigs.length; i++) { for (let j = i + 1; j < this.peggedPairConfigs.length; j++) { const A = this.peggedPairConfigs[i]; const B = this.peggedPairConfigs[j]; if (A.org_chain_id === B.org_chain_id && A.org_token.token.symbol === B.org_token.token.symbol) { if (A.bridge_version === 2 && B.bridge_version === 2) { burnPairConfigs.push({ burn_config_as_org: { chain_id: A.pegged_chain_id, token: A.pegged_token, burn_contract_addr: A.pegged_burn_contract_addr, canonical_token_contract_addr: A.canonical_token_contract_addr, burn_contract_version: A.bridge_version }, burn_config_as_dst: { chain_id: B.pegged_chain_id, token: B.pegged_token, burn_contract_addr: B.pegged_burn_contract_addr, canonical_token_contract_addr: B.canonical_token_contract_addr, burn_contract_version: B.bridge_version } }); burnPairConfigs.push({ burn_config_as_org: { chain_id: B.pegged_chain_id, token: B.pegged_token, burn_contract_addr: B.pegged_burn_contract_addr, canonical_token_contract_addr: B.canonical_token_contract_addr, burn_contract_version: B.bridge_version }, burn_config_as_dst: { chain_id: A.pegged_chain_id, token: A.pegged_token, burn_contract_addr: A.pegged_burn_contract_addr, canonical_token_contract_addr: A.canonical_token_contract_addr, burn_contract_version: A.bridge_version } }); } } } } this.burnPairConfigs = burnPairConfigs; } getChainId(chain) { return chain.id; } getTokenBaseInfo({ chainId, token }) { return { name: token.name, symbol: token.token.symbol, address: token.token.address, decimals: token.token.decimal, ...this.getTokenDisplaySymbolAndIcon({ chainId, tokenAddress: token.token.address, defaultSymbol: token.token.symbol, icon: token.icon }) }; } getPeggedPairConfigs() { return this.burnPairConfigs; } getBurnPairConfigs() { return this.peggedPairConfigs; } isBlockedPair({ fromChainId, toChainId, tokenSymbol }) { const blockedList = this.config.blocked_bridge_direct ?? []; const isBlocked = blockedList.find((e) => { return Number(e.src_chain_id) === fromChainId && Number(e.dst_chain_id) === toChainId && e.symbol.toUpperCase() === tokenSymbol.toUpperCase(); }); return isBlocked; } } function cBridge(params) { return { id: "cBridge", ...params }; } const POOL_TRANSFER_BRIDGE = [ { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "period", type: "uint256" } ], name: "DelayPeriodUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "threshold", type: "uint256" } ], name: "DelayThresholdUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "id", type: "bytes32" } ], name: "DelayedTransferAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "id", type: "bytes32" }, { indexed: false, internalType: "address", name: "receiver", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "DelayedTransferExecuted", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "length", type: "uint256" } ], name: "EpochLengthUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "cap", type: "uint256" } ], name: "EpochVolumeUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "GovernorAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "GovernorRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint64", name: "seqnum", type: "uint64" }, { indexed: false, internalType: "address", name: "provider", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "LiquidityAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "MaxSendUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "MinAddUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "MinSendUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "previousOwner", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" } ], name: "OwnershipTransferred", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "Paused", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "PauserAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "PauserRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "transferId", type: "bytes32" }, { indexed: false, internalType: "address", name: "sender", type: "address" }, { indexed: false, internalType: "address", name: "receiver", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" }, { indexed: false, internalType: "uint64", name: "srcChainId", type: "uint64" }, { indexed: false, internalType: "bytes32", name: "srcTransferId", type: "bytes32" } ], name: "Relay", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "resetTime", type: "uint256" } ], name: "ResetNotification", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "transferId", type: "bytes32" }, { indexed: false, internalType: "address", name: "sender", type: "address" }, { indexed: false, internalType: "address", name: "receiver", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" }, { indexed: false, internalType: "uint64", name: "dstChainId", type: "uint64" }, { indexed: false, internalType: "uint64", name: "nonce", type: "uint64" }, { indexed: false, internalType: "uint32", name: "maxSlippage", type: "uint32" } ], name: "Send", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address[]", name: "_signers", type: "address[]" }, { indexed: false, internalType: "uint256[]", name: "_powers", type: "uint256[]" } ], name: "SignersUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "Unpaused", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "withdrawId", type: "bytes32" }, { indexed: false, internalType: "uint64", name: "seqnum", type: "uint64" }, { indexed: false, internalType: "address", name: "receiver", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" }, { indexed: false, internalType: "bytes32", name: "refid", type: "bytes32" } ], name: "WithdrawDone", type: "event" }, { inputs: [ { internalType: "address", name: "_account", type: "address" } ], name: "addGovernor", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_token", type: "address" }, { internalType: "uint256", name: "_amount", type: "uint256" } ], name: "addLiquidity", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint256", name: "_amount", type: "uint256" } ], name: "addNativeLiquidity", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "addPauser", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "addseq", outputs: [ { internalType: "uint64", name: "", type: "uint64" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "delayPeriod", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "delayThresholds", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], name: "delayedTransfers", outputs: [ { internalType: "address", name: "receiver", type: "address" }, { internalType: "address", name: "token", type: "address" }, { internalType: "uint256", name: "amount", type: "uint256" }, { internalType: "uint256", name: "timestamp", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "epochLength", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "epochVolumeCaps", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "epochVolumes", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes32", name: "id", type: "bytes32" } ], name: "executeDelayedTransfer", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "governors", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "period", type: "uint256" } ], name: "increaseNoticePeriod", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_account", type: "address" } ], name: "isGovernor", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "isPauser", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "lastOpTimestamps", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "maxSend", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "minAdd", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "minSend", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "minimalMaxSlippage", outputs: [ { internalType: "uint32", name: "", type: "uint32" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "nativeWrap", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "noticePeriod", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "notifyResetSigners", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "owner", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "pause", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "paused", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" } ], name: "pausers", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes", name: "_relayRequest", type: "bytes" }, { internalType: "bytes[]", name: "_sigs", type: "bytes[]" }, { internalType: "address[]", name: "_signers", type: "address[]" }, { internalType: "uint256[]", name: "_powers", type: "uint256[]" } ], name: "relay", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_account", type: "address" } ], name: "removeGovernor", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "removePauser", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "renounceGovernor", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "renouncePauser", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_signers", type: "address[]" }, { internalType: "uint256[]", name: "_powers", type: "uint256[]" } ], name: "resetSigners", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "resetTime", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "_receiver", type: "address" }, { internalType: "address", name: "_token", type: "address" }, { internalType: "uint256", name: "_amount", type: "uint256" }, { internalType: "uint64", name: "_dstChainId", type: "uint64" }, { internalType: "uint64", name: "_nonce", type: "uint64" }, { internalType: "uint32", name: "_maxSlippage", type: "uint32" } ], name: "send", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_receiver", type: "address" }, { internalType: "uint256", name: "_amount", type: "uint256" }, { internalType: "uint64", name: "_dstChainId", type: "uint64" }, { internalType: "uint64", name: "_nonce", type: "uint64" }, { internalType: "uint32", name: "_maxSlippage", type: "uint32" } ], name: "sendNative", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "uint256", name: "_period", type: "uint256" } ], name: "setDelayPeriod", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_tokens", type: "address[]" }, { internalType: "uint256[]", name: "_thresholds", type: "uint256[]" } ], name: "setDelayThresholds", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint256", name: "_length", type: "uint256" } ], name: "setEpochLength", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_tokens", type: "address[]" }, { internalType: "uint256[]", name: "_caps", type: "uint256[]" } ], name: "setEpochVolumeCaps", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_tokens", type: "address[]" }, { internalType: "uint256[]", name: "_amounts", type: "uint256[]" } ], name: "setMaxSend", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_tokens", type: "address[]" }, { internalType: "uint256[]", name: "_amounts", type: "uint256[]" } ], name: "setMinAdd", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_tokens", type: "address[]" }, { internalType: "uint256[]", name: "_amounts", type: "uint256[]" } ], name: "setMinSend", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint32", name: "_minimalMaxSlippage", type: "uint32" } ], name: "setMinimalMaxSlippage", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_weth", type: "address" } ], name: "setWrap", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "ssHash", outputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "newOwner", type: "address" } ], name: "transferOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], name: "transfers", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "triggerTime", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "unpause", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint256", name: "_triggerTime", type: "uint256" }, { internalType: "address[]", name: "_newSigners", type: "address[]" }, { internalType: "uint256[]", name: "_newPowers", type: "uint256[]" }, { internalType: "bytes[]", name: "_sigs", type: "bytes[]" }, { internalType: "address[]", name: "_curSigners", type: "address[]" }, { internalType: "uint256[]", name: "_curPowers", type: "uint256[]" } ], name: "updateSigners", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes", name: "_msg", type: "bytes" }, { internalType: "bytes[]", name: "_sigs", type: "bytes[]" }, { internalType: "address[]", name: "_signers", type: "address[]" }, { internalType: "uint256[]", name: "_powers", type: "uint256[]" } ], name: "verifySigs", outputs: [], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes", name: "_wdmsg", type: "bytes" }, { internalType: "bytes[]", name: "_sigs", type: "bytes[]" }, { internalType: "address[]", name: "_signers", type: "address[]" }, { internalType: "uint256[]", name: "_powers", type: "uint256[]" } ], name: "withdraw", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], name: "withdraws", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { stateMutability: "payable", type: "receive" } ]; const ORIGINAL_TOKEN_VAULT = [ { inputs: [ { internalType: "contract ISigsVerifier", name: "_sigsVerifier", type: "address" } ], stateMutability: "nonpayable", type: "constructor" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "period", type: "uint256" } ], name: "DelayPeriodUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "threshold", type: "uint256" } ], name: "DelayThresholdUpdated", type: "event" }, { anonymous: false, inputs: [{ indexed: false, internalType: "bytes32", name: "id", type: "bytes32" }], name: "DelayedTransferAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "id", type: "bytes32" }, { indexed: false, internalType: "address", name: "receiver", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "DelayedTransferExecuted", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "depositId", type: "bytes32" }, { indexed: false, internalType: "address", name: "depositor", type: "address" }, { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" }, { indexed: false, internalType: "uint64", name: "mintChainId", type: "uint64" }, { indexed: false, internalType: "address", name: "mintAccount", type: "address" } ], name: "Deposited", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "length", type: "uint256" } ], name: "EpochLengthUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "cap", type: "uint256" } ], name: "EpochVolumeUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "GovernorAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "GovernorRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "MaxDepositUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "token", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "MinDepositUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "previousOwner", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" } ], name: "OwnershipTransferred", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "Paused", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "PauserAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "PauserRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "account", type: "address" } ], name: "Unpaused", type: "event" }, { anonymous: false, inp