Skip to content

Commit

Permalink
chore(contracts): support op sepolia deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Mar 12, 2024
1 parent 5cad314 commit 1dabd76
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion contracts/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MNEMONIC=
ETHERSCAN_API_KEY=
ETH_ETHERSCAN_API_KEY=
OPTIMISM_ETHERSCAN_API_KEY=
INFURA_KEY=
OP_RPC_URL=
GAS_PRICE=
Expand Down
25 changes: 23 additions & 2 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import type { HardhatUserConfig } from "hardhat/config";

// Don't forget to import new tasks here
import "./tasks/deploy";
import { EChainId, ESupportedChains, NETWORKS_DEFAULT_GAS, getNetworkRpcUrls } from "./tasks/helpers/constants";
import {
EChainId,
ESupportedChains,
NETWORKS_DEFAULT_GAS,
getEtherscanApiKeys,
getNetworkRpcUrls,
} from "./tasks/helpers/constants";
import "./tasks/runner/deployFull";
import "./tasks/runner/deployPoll";
import "./tasks/runner/merge";
Expand All @@ -22,6 +28,7 @@ const DEFAULT_BLOCK_GAS_LIMIT = 30_000_000;
const DEFAULT_GAS_MUL = 2;
const TEST_MNEMONIC = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
const NETWORKS_RPC_URL = getNetworkRpcUrls();
const ETHERSCAN_API_KEYS = getEtherscanApiKeys();

const getCommonNetworkConfig = (networkName: ESupportedChains, chainId: number, mnemonic?: string) => ({
url: NETWORKS_RPC_URL[networkName],
Expand Down Expand Up @@ -51,6 +58,7 @@ const config: HardhatUserConfig = {
defaultNetwork: "localhost",
networks: {
sepolia: getCommonNetworkConfig(ESupportedChains.Sepolia, EChainId.Sepolia),
optimism_sepolia: getCommonNetworkConfig(ESupportedChains.OptimismSepolia, EChainId.OptimismSepolia),
coverage: getCommonNetworkConfig(ESupportedChains.Coverage, EChainId.Coverage, TEST_MNEMONIC),
localhost: {
url: "http://localhost:8545",
Expand Down Expand Up @@ -90,7 +98,20 @@ const config: HardhatUserConfig = {
disambiguatePaths: false,
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
apiKey: {
[ESupportedChains.Sepolia]: ETHERSCAN_API_KEYS[ESupportedChains.Sepolia]!,
[ESupportedChains.OptimismSepolia]: ETHERSCAN_API_KEYS[ESupportedChains.OptimismSepolia]!,
},
customChains: [
{
network: ESupportedChains.OptimismSepolia,
chainId: EChainId.OptimismSepolia,
urls: {
apiURL: "https://api-sepolia-optimism.etherscan.io/api",
browserURL: "https://sepolia-optimism.etherscan.io",
},
},
],
},
sourcify: {
enabled: true,
Expand Down
7 changes: 6 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@
"prove": "hardhat prove",
"deploy:localhost": "pnpm run deploy",
"deploy:sepolia": "pnpm run deploy --network sepolia",
"deploy:optimism-sepolia": "pnpm run deploy --network optimism_sepolia",
"deploy-poll:localhost": "pnpm run deploy-poll",
"deploy-poll:sepolia": "pnpm run deploy-poll --network sepolia",
"deploy-poll:optimism-sepolia": "pnpm run deploy-poll --network optimism_sepolia",
"merge:localhost": "pnpm run merge",
"merge:sepolia": "pnpm run merge --network sepolia",
"merge:optimism-sepolia": "pnpm run merge --network optimism_sepolia",
"prove:localhost": "pnpm run prove",
"prove:sepolia": "pnpm run prove --network sepolia",
"verify:sepolia": "pnpm run verify --network sepolia"
"prove:optimism-sepolia": "pnpm run prove --network optimism_sepolia",
"verify:sepolia": "pnpm run verify --network sepolia",
"verify:optimism-sepolia": "pnpm run verify --network optimism_sepolia"
},
"dependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.5",
Expand Down
11 changes: 11 additions & 0 deletions contracts/tasks/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
export enum ESupportedChains {
Sepolia = "sepolia",
OptimismSepolia = "optimism_sepolia",
Coverage = "coverage",
Hardhat = "hardhat",
}
Expand All @@ -12,6 +13,7 @@ export enum ESupportedChains {
*/
export enum EChainId {
Hardhat = 31337,
OptimismSepolia = 11155420,
Sepolia = 11155111,
Coverage = 1337,
}
Expand All @@ -33,6 +35,7 @@ const gasPrice = (value: number) => value * GWEI;
*/
export const NETWORKS_DEFAULT_GAS: Record<ESupportedChains, number | "auto"> = {
[ESupportedChains.Sepolia]: gasPrice(1),
[ESupportedChains.OptimismSepolia]: gasPrice(1),
[ESupportedChains.Coverage]: gasPrice(1),
[ESupportedChains.Hardhat]: gasPrice(1),
};
Expand All @@ -47,7 +50,15 @@ export const getNetworkRpcUrls = (): Record<ESupportedChains, string> => {

return {
[ESupportedChains.Sepolia]: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
[ESupportedChains.OptimismSepolia]: `https://optimism-sepolia.infura.io/v3/${INFURA_KEY}`,
[ESupportedChains.Coverage]: "http://localhost:8555",
[ESupportedChains.Hardhat]: "http://localhost:8545",
};
};

export const getEtherscanApiKeys = (): Record<ESupportedChains, string | undefined> => ({
[ESupportedChains.Sepolia]: process.env.ETH_ETHERSCAN_API_KEY,
[ESupportedChains.OptimismSepolia]: process.env.OPTIMISM_ETHERSCAN_API_KEY,
[ESupportedChains.Coverage]: undefined,
[ESupportedChains.Hardhat]: undefined,
});

0 comments on commit 1dabd76

Please sign in to comment.