From 2f0908b67c0068385fe399e67ed2d44790588a5c Mon Sep 17 00:00:00 2001 From: yu-zhen Date: Mon, 4 Mar 2024 20:34:34 +0900 Subject: [PATCH] chore: add forking options --- cli/ts/utils/defaults.ts | 2 +- contracts/.env.example | 3 +++ contracts/hardhat.config.ts | 8 +++++++- contracts/package.json | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cli/ts/utils/defaults.ts b/cli/ts/utils/defaults.ts index e61037ac52..502ad4a60d 100644 --- a/cli/ts/utils/defaults.ts +++ b/cli/ts/utils/defaults.ts @@ -1,5 +1,5 @@ // the default URL of the EVM provider -export const DEFAULT_ETH_PROVIDER = "http://localhost:8545"; +export const DEFAULT_ETH_PROVIDER = "http://127.0.0.1:8545"; // the default EVM private key export const DEFAULT_ETH_SK = "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"; // the default initial voice credits assigned to users diff --git a/contracts/.env.example b/contracts/.env.example index beb0e8ceac..4b803b3e29 100644 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -3,3 +3,6 @@ ETHERSCAN_API_KEY= INFURA_KEY= OP_RPC_URL= GAS_PRICE= +FORKING_URL= +FORKING_BLOCK_NUM= +HARDHAT_LOGGING= diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 82a634f19f..e0b7d07b07 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -68,7 +68,7 @@ const config: HardhatUserConfig = { count: 20, }, gas: DEFAULT_BLOCK_GAS_LIMIT, - loggingEnabled: false, + loggingEnabled: process.env.HARDHAT_LOGGING === "true", allowUnlimitedContractSize: true, throwOnTransactionFailures: true, throwOnCallFailures: true, @@ -76,6 +76,12 @@ const config: HardhatUserConfig = { auto: true, interval: 100, }, + forking: process.env.FORKING_URL + ? { + url: process.env.FORKING_URL, + blockNumber: process.env.FORKING_BLOCK_NUM ? parseInt(process.env.FORKING_BLOCK_NUM, 10) : 0, + } + : undefined, }, }, contractSizer: { diff --git a/contracts/package.json b/contracts/package.json index cfbe1ad9ff..130b39c846 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -24,7 +24,7 @@ ], "scripts": { "watch": "tsc --watch", - "hardhat": "hardhat node --hostname 0.0.0.0 --port 8545", + "hardhat": "hardhat node", "compileSol": "./scripts/compileSol.sh $1", "moveIntegrationArtifacts": "cp -r artifacts/ ../integrationTests/artifacts", "prebuild": "pnpm run compileSol",