Skip to content

Commit 8b8f057

Browse files
fix: review comments
1 parent 5601108 commit 8b8f057

12 files changed

+36
-62
lines changed

.env.example

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#global settings
22
NODE_ENV="production"
33
DOTENV_CONFIG_PATH=./.env
4-
DEPLOYMENT_MODE=dev
4+
DEPLOYMENT_MODE="dev | surge | prod"
55

6-
# deployment keys/mnmeonic/relayers
6+
# deployment keys/relayers
77
SOCKET_SIGNER_KEY=xxx
8-
MNEMONIC=xxx
98

109
RELAYER_URL_DEV=""
1110
RELAYER_URL_SURGE=""
@@ -29,9 +28,6 @@ BSC_TESTNET_RPC='https://data-seed-prebsc-1-s1.binance.org:8545'
2928
ETHEREUM_RPC='https://rpc.ankr.com/eth'
3029
GOERLI_RPC='https://rpc.ankr.com/eth_goerli'
3130

32-
# default rpc
33-
INFURA_API_KEY=xxx
34-
3531
# etherscan verification
3632
ETHERSCAN_API_KEY=xxx
3733
POLYGONSCAN_API_KEY=xxx

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ yarn install
4141
│ └── forge-std - forge dependencies installed as git submodules
4242
|
4343
└── scripts
44-
| └── contains different scripts needed for
44+
| └── contains different scripts needed for deployment, configuration and admin related transactions
4545
|
4646
└── test
4747
| └── Contract.t.sol - Tests for core contracts

hardhat.config.ts

+9-28
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import "hardhat-change-network";
99

1010
import { config as dotenvConfig } from "dotenv";
1111
import type { HardhatUserConfig } from "hardhat/config";
12-
import type { NetworkUserConfig } from "hardhat/types";
12+
import type {
13+
HardhatNetworkAccountUserConfig,
14+
NetworkUserConfig,
15+
} from "hardhat/types";
1316
import { resolve } from "path";
1417
import fs from "fs";
1518

@@ -19,24 +22,16 @@ import { ChainKey, chainKeyToSlug } from "./src";
1922

2023
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
2124
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });
22-
2325
const isProduction = process.env.NODE_ENV === "production";
2426

2527
// Ensure that we have all the environment variables we need.
26-
const mnemonic: string | undefined = process.env.MNEMONIC;
27-
28-
const infuraApiKey: string | undefined = process.env.INFURA_API_KEY;
29-
if (!infuraApiKey && isProduction) {
30-
throw new Error("Please set your INFURA_API_KEY in a .env file");
31-
}
28+
if (!process.env.SOCKET_SIGNER_KEY) throw new Error("No private key found");
29+
const privateKey: HardhatNetworkAccountUserConfig = process.env
30+
.SOCKET_SIGNER_KEY as unknown as HardhatNetworkAccountUserConfig;
3231

3332
function getChainConfig(chain: keyof typeof chainKeyToSlug): NetworkUserConfig {
3433
return {
35-
accounts: {
36-
count: 10,
37-
mnemonic,
38-
path: "m/44'/60'/0'/0",
39-
},
34+
accounts: [`0x${privateKey}`],
4035
chainId: chainKeyToSlug[chain],
4136
gasPrice: gasPrice[chain] ? gasPrice[chain] : "auto",
4237
url: getJsonRpcUrl(chain),
@@ -52,7 +47,7 @@ function getRemappings() {
5247
}
5348

5449
let liveNetworks = {};
55-
if (mnemonic && infuraApiKey && isProduction) {
50+
if (isProduction) {
5651
liveNetworks = {
5752
"arbitrum-goerli": getChainConfig(ChainKey.ARBITRUM_GOERLI),
5853
"optimism-goerli": getChainConfig(ChainKey.OPTIMISM_GOERLI),
@@ -113,20 +108,6 @@ const config: HardhatUserConfig = {
113108
},
114109
...liveNetworks,
115110
},
116-
namedAccounts: {
117-
socketOwner: {
118-
default: 0,
119-
},
120-
counterOwner: {
121-
default: 1,
122-
},
123-
pauser: {
124-
default: 2,
125-
},
126-
user: {
127-
default: 3,
128-
},
129-
},
130111
paths: {
131112
sources: "./contracts",
132113
cache: "./cache_hardhat",

scripts/constants/networks.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +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-
const infuraApiKey: string | undefined = process.env.INFURA_API_KEY;
10-
119
export const gasPrice: {
1210
[chainKEY in ChainKey]?: number | "auto" | undefined;
1311
} = {
@@ -79,7 +77,7 @@ export function getJsonRpcUrl(chain: ChainKey): string {
7977
break;
8078

8179
default:
82-
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
80+
throw new Error("JSON RPC URL not found!!");
8381
}
8482

8583
return jsonRpcUrl;

scripts/deploy/DEPLOY.md

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ To deploy the entire setup, follow these steps:
66
- [Grant Roles](#grant-roles): grant roles for different actions (watcher/transmitter/executor/governance, etc.)
77
- [Configure](#configure): configure chains for their siblings
88
- [Connect](#connect): configure example counters to send messages to siblings
9+
- [Verify setup](#verify-setup): queries contracts available in `${mode}_addresses.json` and checks if everything is set as expected.
910

1011
There are three different modes for deployment (prod, dev, and surge) which are used in naming address JSON and selecting configurations. All deploy scripts use [config.ts](./config.ts).
1112

@@ -59,3 +60,11 @@ This script:
5960
`npx hardhat run scripts/deploy/connect.ts`
6061

6162
This script connects the plugs to their siblings for all the chains that exist in the `integrations` object for that chain.
63+
64+
### Verify Setup
65+
66+
- To run this script, make sure the contract addresses exist in `${mode}_addresses.json`
67+
- Run the script with the command:
68+
`npx hardhat run scripts/deploy/verifyDeployments.ts`
69+
70+
The output will show if all the configurations are set properly.

scripts/deploy/scripts/deploy-gasprice-oracle.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import { mode, transmitterAddresses } from "../config";
1414
export const main = async () => {
1515
try {
1616
// assign deployers
17-
const { getNamedAccounts } = hre;
18-
const { socketOwner } = await getNamedAccounts();
19-
const socketSigner: SignerWithAddress = await ethers.getSigner(socketOwner);
20-
17+
const socketSigners: SignerWithAddress = await ethers.getSigners();
18+
const socketSigner = socketSigners[0];
2119
const network = hre.network.name;
2220

2321
const gasPriceOracle: Contract = await deployContractWithArgs(

scripts/deploy/scripts/outbound.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { config as dotenvConfig } from "dotenv";
22
dotenvConfig();
33

44
import fs from "fs";
5-
import { getNamedAccounts, ethers } from "hardhat";
5+
import { ethers } from "hardhat";
66
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
77

88
import { getInstance, getChainSlug, deployedAddressPath } from "../utils";
@@ -23,8 +23,8 @@ export const main = async () => {
2323
fs.readFileSync(deployedAddressPath(mode), "utf-8")
2424
);
2525

26-
const { counterOwner } = await getNamedAccounts();
27-
const signer: SignerWithAddress = await ethers.getSigner(counterOwner);
26+
const socketSigners: SignerWithAddress = await ethers.getSigners();
27+
const signer = socketSigners[0];
2828

2929
const counter: Contract = await getInstance(
3030
"Counter",

scripts/deploy/scripts/untrip-path-in-switchboard.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import {
88
} from "../../../src";
99
import { mode } from "../config";
1010

11+
const srcChainSlug = ChainSlug.GOERLI;
12+
const privateKey = process.env.SOCKET_SIGNER_KEY;
13+
14+
// update the inputs to the
1115
export const main = async () => {
1216
try {
1317
const chainSlug = await getChainSlug();
14-
const srcChainSlug = ChainSlug.GOERLI;
15-
const privateKey = "";
16-
1718
const signer = new ethers.Wallet(privateKey, ethers.provider);
1819

1920
const switchBoardAddress = getSwitchboardAddress(

scripts/deploy/scripts/upgradeSigVerifier.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { config as dotenvConfig } from "dotenv";
22
dotenvConfig();
33

44
import fs from "fs";
5-
import { getNamedAccounts, ethers } from "hardhat";
5+
import { ethers } from "hardhat";
66
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
77

88
import {
@@ -24,11 +24,11 @@ export const main = async () => {
2424
const config: any = JSON.parse(
2525
fs.readFileSync(deployedAddressPath(mode) + chainSlug + ".json", "utf-8")
2626
);
27-
const { socketOwner } = await getNamedAccounts();
2827

29-
const socketSigner: SignerWithAddress = await ethers.getSigner(socketOwner);
30-
const notary = await getInstance("AdminNotary", config["notary"]);
28+
const socketSigners: SignerWithAddress = await ethers.getSigners();
29+
const socketSigner = socketSigners[0];
3130

31+
const notary = await getInstance("AdminNotary", config["notary"]);
3232
const signatureVerifier: Contract = await deployContractWithArgs(
3333
"SignatureVerifier",
3434
[],

scripts/deploy/utils/signers.ts

-9
This file was deleted.
File renamed without changes.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "es2018",
44
"module": "commonjs",
5-
"strict": false,
5+
"strict": true,
66
"esModuleInterop": true,
77
"outDir": "dist",
88
"declaration": true,

0 commit comments

Comments
 (0)