Skip to content

Commit

Permalink
fix flag with env var (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam authored Nov 28, 2024
1 parent 4fc5f4c commit 3bf3be4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 4 additions & 3 deletions examples/tictactoe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ The forge script will log the deployed deterministic contract address.
...
Script ran successfully..
== Logs ==
Deployed at: 0x14eFE545C60FB3b65B9eeb23E22b8013908e48Bc

Deployed at: 0x14eFE545C60FB3b65B9eeb23E22b8013908e48Bc
...
```

### 2. Run The Frontend

Ensure the contract address matches the constant within `examples/tictactoe/src/constants/tictactoe.ts`
Supply the address as an environment variable when running the frontend.

```bash
cd examples/tictactoe

export VITE_TICTACTOE_ADDRESS=0x14eFE545C60FB3b65B9eeb23E22b8013908e48Bc
pnpn i && pnpm run dev
```

Expand Down
7 changes: 3 additions & 4 deletions examples/tictactoe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "test -n \"$npm_config_address\" && TICTACTOE_ADDRESS=$npm_config_address vite || (echo 'Error: --address parameter is required' && exit 1)",
"build": "test -n \"$npm_config_address\" && TICTACTOE_ADDRESS=$npm_config_address tsc -b && vite build || (echo 'Error: --address parameter is required' && exit 1)",
"lint": "eslint .",
"preview": "vite preview"
"dev": "if [ -z \"$VITE_TICTACTOE_ADDRESS\" ]; then echo 'Error: VITE_TICTACTOE_ADDRESS env is required' && exit 1; else vite; fi",
"build": "if [ -z \"$VITE_TICTACTOE_ADDRESS\" ]; then echo 'Error: VITE_TICTACTOE_ADDRESS env is required' && exit 1; else tsc -b && vite build; fi",
"lint": "eslint ."
},
"dependencies": {
"@eth-optimism/viem": "^0.0.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/tictactoe/src/constants/tictactoe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const address = import.meta.env.TICTACTOE_ADDRESS
export const address = import.meta.env.VITE_TICTACTOE_ADDRESS

export const abi = [
{
Expand Down

0 comments on commit 3bf3be4

Please sign in to comment.