Skip to content

Commit

Permalink
fix(contracts): ensure gasPrice has sufficient value
Browse files Browse the repository at this point in the history
  • Loading branch information
baumstern committed Jul 26, 2024
1 parent bd894d8 commit 62f9e8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 34 deletions.
13 changes: 4 additions & 9 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import type { HardhatUserConfig } from "hardhat/config";

// Don't forget to import new tasks here
import "./tasks/deploy";
import {
EChainId,
ESupportedChains,
NETWORKS_DEFAULT_GAS,
getEtherscanApiKeys,
getNetworkRpcUrls,
} from "./tasks/helpers/constants";
import { EChainId, ESupportedChains, getEtherscanApiKeys, getNetworkRpcUrls } from "./tasks/helpers/constants";
import "./tasks/runner/deployFull";
import "./tasks/runner/deployPoll";
import "./tasks/runner/merge";
Expand All @@ -28,13 +22,14 @@ 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 GAS_PRICE: number | "auto" = process.env.GAS_PRICE ? Number(process.env.GAS_PRICE) : "auto";
const ETHERSCAN_API_KEYS = getEtherscanApiKeys();

const getCommonNetworkConfig = (networkName: ESupportedChains, chainId: number, mnemonic?: string) => ({
url: NETWORKS_RPC_URL[networkName],
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: process.env.GAS_PRICE ? Number(process.env.GAS_PRICE) : NETWORKS_DEFAULT_GAS[networkName],
gasPrice: GAS_PRICE,
saveDeployments: true,
chainId,
accounts: {
Expand Down Expand Up @@ -72,7 +67,7 @@ const config: HardhatUserConfig = {
hardhat: {
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: NETWORKS_DEFAULT_GAS[ESupportedChains.Hardhat],
gasPrice: "auto",
chainId: EChainId.Hardhat,
accounts: {
mnemonic: TEST_MNEMONIC,
Expand Down
25 changes: 0 additions & 25 deletions contracts/tasks/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,8 @@ export enum EChainId {
Coverage = 1337,
}

const GWEI = 1e9;

export const STATE_TREE_ARITY = 5;

/**
* Convert gas price from gweguari to wei
*
* @param value - gas price in gwei
* @returns gas price in wei
*/
const gasPrice = (value: number) => value * GWEI;

/**
* Gas price settings for supported network
*/
export const NETWORKS_DEFAULT_GAS: Record<ESupportedChains, number | "auto"> = {
[ESupportedChains.Sepolia]: gasPrice(1),
[ESupportedChains.Optimism]: gasPrice(1),
[ESupportedChains.OptimismSepolia]: gasPrice(1),
[ESupportedChains.Scroll]: gasPrice(1),
[ESupportedChains.ScrollSepolia]: gasPrice(1),
[ESupportedChains.Coverage]: gasPrice(1),
[ESupportedChains.Hardhat]: gasPrice(1),
[ESupportedChains.Arbitrum]: gasPrice(1),
[ESupportedChains.ArbitrumSepolia]: gasPrice(1),
};

/**
* Get network rpc urls object
*
Expand Down

0 comments on commit 62f9e8c

Please sign in to comment.