Skip to content

Commit

Permalink
add DEV_CHAIN_ID var
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Oct 19, 2023
1 parent a0ccbe4 commit 5ba1fca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN apt-get clean && \
COPY ../ /app
WORKDIR /app

ENV DEV_CHAIN_ID=313371
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Expand All @@ -21,4 +22,4 @@ RUN pnpm hardhat compile

EXPOSE 8545/tcp

CMD ~/.foundry/bin/anvil --host 0.0.0.0 --chain-id 313371
CMD ./docker/start-chain.sh
1 change: 1 addition & 0 deletions docker/start-chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~/.foundry/bin/anvil --host 0.0.0.0 --chain-id $DEV_CHAIN_ID
11 changes: 10 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ import "solidity-coverage";

dotenv.config();

function getEnvVarNumber(name: string, defaultValue: number): number {
const value = process.env[name];
if (value !== undefined) {
return parseInt(value);
}

return defaultValue;
}

const chainIds = {
// local
localhost: 31337,
dev: 313371,
dev: getEnvVarNumber("DEV_CHAIN_ID", 313371),
// testnet
goerli: 5,
"optimism-goerli": 420,
Expand Down

0 comments on commit 5ba1fca

Please sign in to comment.