Skip to content

Commit 2706b41

Browse files
authored
Merge pull request #225 from SocketDotTech/fix/tx-overrides
add global overrides for tx
2 parents 0178990 + 825e8ec commit 2706b41

File tree

8 files changed

+85
-24
lines changed

8 files changed

+85
-24
lines changed

hardhat.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { resolve } from "path";
1717
import fs from "fs";
1818

1919
import "./tasks/accounts";
20-
import { gasPrice, getJsonRpcUrl } from "./scripts/constants/networks";
20+
import { getJsonRpcUrl } from "./scripts/constants/networks";
2121
import { ChainKey, chainKeyToSlug } from "./src";
2222

2323
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
@@ -33,7 +33,6 @@ function getChainConfig(chain: keyof typeof chainKeyToSlug): NetworkUserConfig {
3333
return {
3434
accounts: [`0x${privateKey}`],
3535
chainId: chainKeyToSlug[chain],
36-
gasPrice: gasPrice[chain] ? gasPrice[chain] : "auto",
3736
url: getJsonRpcUrl(chain),
3837
};
3938
}

scripts/constants/networks.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@ import { ChainKey, networkToChainSlug } from "../../src";
66
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
77
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });
88

9-
export const gasPrice: {
10-
[chainKEY in ChainKey]?: number | "auto" | undefined;
11-
} = {
12-
[ChainKey.ARBITRUM]: "auto",
13-
[ChainKey.ARBITRUM_GOERLI]: "auto",
14-
[ChainKey.OPTIMISM]: "auto",
15-
[ChainKey.OPTIMISM_GOERLI]: "auto",
16-
[ChainKey.AVALANCHE]: "auto",
17-
[ChainKey.BSC]: "auto",
18-
[ChainKey.BSC_TESTNET]: "auto",
19-
[ChainKey.MAINNET]: "auto",
20-
[ChainKey.GOERLI]: "auto",
21-
[ChainKey.POLYGON_MAINNET]: "auto",
22-
[ChainKey.POLYGON_MUMBAI]: "auto",
23-
[ChainKey.HARDHAT]: "auto",
24-
};
25-
269
export const chainSlugKeys: string[] = Object.values(networkToChainSlug);
2710

2811
export function getJsonRpcUrl(chain: ChainKey): string {

scripts/deploy/checkRoles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
transmitterAddresses,
3232
watcherAddresses,
3333
} from "./config";
34+
import { overrides } from "./config";
3435

3536
let roleStatus: any = {};
3637

@@ -154,6 +155,7 @@ const executeRoleTransactions = async (
154155
let tx = await wallet.sendTransaction({
155156
to: contractAddress,
156157
data,
158+
...overrides[chainId],
157159
});
158160
console.log(
159161
`chain: ${chainId}`,

scripts/deploy/config.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export const filterChains: number[] = chains;
3737
export const capacitorType = 1;
3838
export const maxPacketLength = 1;
3939

40+
export const gasLimit = 30_000_000;
41+
export const type = 0;
42+
export const gasMultiplier = 1;
43+
export const gasPrice = "auto";
44+
4045
export const transmitterAddresses = {
4146
[DeploymentMode.DEV]: "0x138e9840861C983DC0BB9b3e941FB7C0e9Ade320",
4247
[DeploymentMode.SURGE]: "0x22883bEF8302d50Ac76c6F6e048965Cd4413EBb7",
@@ -54,3 +59,66 @@ export const executorAddresses = {
5459
[DeploymentMode.SURGE]: "0x3051Aa7F267bF425A4e8bF766750D60391F014B4",
5560
[DeploymentMode.PROD]: "0x557E729E55d49E767c11982d026a63aBFD930Ac9",
5661
};
62+
63+
export const overrides = {
64+
[ChainSlug.ARBITRUM]: {
65+
type,
66+
gasPrice,
67+
gasLimit,
68+
gasMultiplier,
69+
},
70+
[ChainSlug.ARBITRUM_GOERLI]: {
71+
type,
72+
gasPrice,
73+
gasLimit,
74+
gasMultiplier,
75+
},
76+
[ChainSlug.OPTIMISM]: {
77+
type,
78+
gasPrice,
79+
gasLimit,
80+
gasMultiplier,
81+
},
82+
[ChainSlug.OPTIMISM_GOERLI]: {
83+
type,
84+
gasPrice,
85+
gasLimit,
86+
gasMultiplier,
87+
},
88+
[ChainSlug.BSC]: {
89+
type,
90+
gasPrice,
91+
gasLimit,
92+
gasMultiplier,
93+
},
94+
[ChainSlug.BSC_TESTNET]: {
95+
type,
96+
gasPrice,
97+
gasLimit,
98+
gasMultiplier,
99+
},
100+
[ChainSlug.MAINNET]: {
101+
type,
102+
gasPrice,
103+
gasLimit,
104+
gasMultiplier,
105+
},
106+
[ChainSlug.GOERLI]: {
107+
type,
108+
gasPrice,
109+
gasLimit,
110+
gasMultiplier,
111+
},
112+
[ChainSlug.POLYGON_MAINNET]: {
113+
type,
114+
gasPrice,
115+
gasLimit,
116+
gasMultiplier,
117+
},
118+
[ChainSlug.POLYGON_MUMBAI]: {
119+
type,
120+
gasPrice,
121+
gasLimit,
122+
gasMultiplier,
123+
},
124+
};

scripts/deploy/configure.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "../../src";
2222
import registerSwitchBoard from "./scripts/registerSwitchboard";
2323
import { capacitorType, chains, maxPacketLength, mode } from "./config";
24+
import { overrides } from "./config";
2425

2526
export const main = async () => {
2627
try {
@@ -185,7 +186,9 @@ const setRemoteSwitchboards = async (addresses) => {
185186

186187
const tx = await sbContract
187188
.connect(socketSigner)
188-
[functionName](dstSwitchboardAddress);
189+
[functionName](dstSwitchboardAddress, {
190+
...overrides[await socketSigner.getChainId()],
191+
});
189192
console.log(tx.hash);
190193
await tx.wait();
191194
}

scripts/deploy/connect.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { mode } from "./config";
1818
import { Contract, Wallet } from "ethers";
1919
import { getSwitchboardAddress } from "../../src";
20+
import { overrides } from "./config";
2021

2122
const chains = [...TestnetIds, ...MainnetIds];
2223

@@ -88,7 +89,8 @@ export const main = async () => {
8889
const tx = await counter.setSocketConfig(
8990
sibling,
9091
siblingCounter,
91-
switchboard
92+
switchboard,
93+
{ ...overrides[await socketSigner.getChainId()] }
9294
);
9395

9496
console.log(

scripts/deploy/scripts/registerSwitchboard.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
33

44
import { createObj, getInstance } from "../utils";
55
import { ChainSlug, ChainSocketAddresses } from "../../../src";
6+
import { overrides } from "../config";
67

78
export default async function registerSwitchBoard(
89
switchBoardAddress: string,
@@ -29,7 +30,8 @@ export default async function registerSwitchBoard(
2930
switchBoardAddress,
3031
maxPacketLength,
3132
remoteChainSlug,
32-
capacitorType
33+
capacitorType,
34+
{ ...overrides[await signer.getChainId()] }
3335
);
3436
console.log(
3537
`Registering Switchboard ${switchBoardAddress}: ${registerTx.hash}`

scripts/deploy/utils/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
DeploymentMode,
1313
} from "../../../src";
1414
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
15+
import { overrides } from "../config";
1516

1617
export const deploymentsPath = path.join(__dirname, `/../../../deployments/`);
1718

@@ -84,8 +85,9 @@ export async function deployContractWithArgs(
8485
const Contract: ContractFactory = await ethers.getContractFactory(
8586
contractName
8687
);
87-
88-
const contract: Contract = await Contract.connect(signer).deploy(...args);
88+
const contract: Contract = await Contract.connect(signer).deploy(...args, {
89+
...overrides[await signer.getChainId()],
90+
});
8991
await contract.deployed();
9092
return contract;
9193
} catch (error) {

0 commit comments

Comments
 (0)