Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ameeshaagrawal committed Jun 29, 2024
1 parent 6228654 commit a5362e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
52 changes: 31 additions & 21 deletions scripts/socket-helpers/main.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<BigNumber> => {
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);
};
10 changes: 5 additions & 5 deletions scripts/socket-helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,7 +18,7 @@ export type Inputs = {
export type ChainDetails = {
srcChainSlug: number;
dstChainSlug: number;
}
};

export const abiInterface = new utils.Interface(PlugABI);

Expand Down

0 comments on commit a5362e8

Please sign in to comment.