diff --git a/scripts/socket-helpers/main.ts b/scripts/socket-helpers/main.ts index a61202fd..d93ee5d8 100644 --- a/scripts/socket-helpers/main.ts +++ b/scripts/socket-helpers/main.ts @@ -1,6 +1,6 @@ require("dotenv").config(); import { BigNumber, providers, utils } from "ethers"; -import { DeploymentMode, } from "@socket.tech/dl-core"; +import { DeploymentMode } from "@socket.tech/dl-core"; import PlugABI from "@socket.tech/dl-core/artifacts/abi/IPlug.json"; import { ChainDetails, Inputs, getPayload } from "./utils"; @@ -10,28 +10,38 @@ import { getArbitrumGasLimitEstimate } from "./arb-estimate"; import { getOptimismGasLimitEstimate } from "./opt-estimate"; export const getEstimatedGasLimit = async ( - chainDetails: ChainDetails, - inputs: Inputs, - withoutHook?: boolean + chainDetails: ChainDetails, + inputs: Inputs, + withoutHook?: boolean ): Promise => { - const srcChainSlug = chainDetails.srcChainSlug as ChainSlug; - const dstChainSlug = chainDetails.dstChainSlug as ChainSlug; + const srcChainSlug = chainDetails.srcChainSlug as ChainSlug; + const dstChainSlug = chainDetails.dstChainSlug as ChainSlug; - const provider = new providers.StaticJsonRpcProvider(getJsonRpcUrl(dstChainSlug)); - const payload = getPayload(inputs, inputs.connectorPlug, provider, withoutHook); + const provider = new providers.StaticJsonRpcProvider( + getJsonRpcUrl(dstChainSlug) + ); + const payload = getPayload( + inputs, + inputs.connectorPlug, + provider, + withoutHook + ); - const abiInterface = new utils.Interface(PlugABI); - const data = abiInterface.encodeFunctionData("inbound", [ - srcChainSlug, - payload, - ]); + const abiInterface = new utils.Interface(PlugABI); + const data = abiInterface.encodeFunctionData("inbound", [ + srcChainSlug, + payload, + ]); - const txData = { - from: getAddresses(dstChainSlug, DeploymentMode.PROD).Socket, - to: inputs.connectorPlug, - data - } - if (arbChains.includes(chainDetails.dstChainSlug) || arbL3Chains.includes(chainDetails.dstChainSlug)) { - return await getArbitrumGasLimitEstimate(provider, txData) - } else return await getOptimismGasLimitEstimate(provider, txData) + const txData = { + from: getAddresses(dstChainSlug, DeploymentMode.PROD).Socket, + to: inputs.connectorPlug, + data, + }; + if ( + arbChains.includes(chainDetails.dstChainSlug) || + arbL3Chains.includes(chainDetails.dstChainSlug) + ) { + return await getArbitrumGasLimitEstimate(provider, txData); + } else return await getOptimismGasLimitEstimate(provider, txData); }; diff --git a/scripts/socket-helpers/utils.ts b/scripts/socket-helpers/utils.ts index 3716afd9..8ad23842 100644 --- a/scripts/socket-helpers/utils.ts +++ b/scripts/socket-helpers/utils.ts @@ -3,10 +3,10 @@ import { defaultAbiCoder } from "ethers/lib/utils"; import PlugABI from "@socket.tech/dl-core/artifacts/abi/IPlug.json"; export type TxData = { - from: string, - to: string, - data: string -} + from: string; + to: string; + data: string; +}; export type Inputs = { amount: string; @@ -18,7 +18,7 @@ export type Inputs = { export type ChainDetails = { srcChainSlug: number; dstChainSlug: number; -} +}; export const abiInterface = new utils.Interface(PlugABI);