-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why: * We prefer Foundry and its tooling for developing locally How: * Adding a `script/DevDeploy.s.sol` script to deploy the contracts locally * Setting up `wagmi` CLI and adding a config file to output the generated ABIs to the `web` package * Adding a `Justfile` for easier connection of tools * Updating `.gitignore`
- Loading branch information
1 parent
d7d94b2
commit 73522a0
Showing
7 changed files
with
825 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ src/types | |
deployments/localhost | ||
*.csv | ||
cache_forge | ||
broadcast/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
set positional-arguments | ||
set dotenv-load | ||
|
||
mnemonic := env_var_or_default("DEV_MNEMONIC", "test test test test test test test test test test test junk") | ||
sender := env_var_or_default("DEV_SENDER", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266") | ||
|
||
# | ||
# aliases | ||
# | ||
|
||
alias w := watch-test | ||
alias d := dev | ||
|
||
# | ||
# public commands | ||
# | ||
|
||
|
||
# full dev stack | ||
# 1. eth-watch (live-reloading anvil w/ deploy) | ||
# 2. next.js | ||
dev: | ||
#!/bin/bash -ue | ||
trap 'kill %1; kill %2' SIGINT | ||
just eth-watch | sed -e 's/^/\x1b[0;31m[node]\x1b[0m /' & | ||
just web 2>&1 | sed -e 's/^/\x1b[0;32m[next]\x1b[0m /' & | ||
wait | ||
|
||
watch-test: | ||
forge test --watch -vvv | ||
|
||
test: | ||
forge test | ||
|
||
# | ||
# private commands | ||
# | ||
|
||
# 1. build contracts | ||
# 2. run test suite | ||
# 3. re-gen wagmi asynchronously | ||
# 4. wait a bit for anvil to boot, then run deploy script asynchronously | ||
eth: | ||
#!/bin/bash | ||
killall -9 anvil | ||
just build-contracts | ||
# just test | ||
sleep 0.2 && just eth-deploy & | ||
just wagmi & | ||
anvil --host 0.0.0.0 | ||
|
||
build-contracts: | ||
forge build | ||
|
||
# start next.js dev server | ||
web: | ||
yarn dev | ||
|
||
# generate wagmi | ||
wagmi: | ||
yarn run wagmi generate | ||
|
||
# restart `just eth` when contracts change | ||
eth-watch: | ||
watchexec \ | ||
--watch contracts \ | ||
--watch test \ | ||
--watch foundry.toml \ | ||
--restart \ | ||
--exts sol,toml \ | ||
just eth | ||
|
||
# deploy contracts for development | ||
eth-deploy: | ||
just forge-script script/DevDeploy.s.sol | ||
|
||
# run a forge script from the appropriate sender | ||
forge-script script: | ||
forge script \ | ||
$1 \ | ||
--fork-url http://localhost:8545 \ | ||
--broadcast \ | ||
--mnemonics "{{ mnemonic }}" \ | ||
--sender "{{ sender }}" \ | ||
--json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.12; | ||
|
||
import {Script} from "lib/forge-std/src/Script.sol"; | ||
|
||
import {Citizend} from "contracts/token/Citizend.sol"; | ||
import {Staking} from "contracts/discovery/Staking.sol"; | ||
|
||
contract DevDeployScript is Script { | ||
address alice = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); | ||
address bob = address(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); | ||
address carol = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); | ||
|
||
address[] testAccounts; | ||
|
||
function setUp() public { | ||
testAccounts = new address[](3); | ||
testAccounts[0] = alice; | ||
testAccounts[1] = bob; | ||
testAccounts[2] = carol; | ||
} | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
Citizend citizend = new Citizend(alice); | ||
Staking staking = new Staking(address(citizend)); | ||
|
||
for (uint256 i; i < testAccounts.length; i++) { | ||
address addr = testAccounts[i]; | ||
(bool success,) = addr.call{value: 10 ether}(""); | ||
require(success, "transfer failed"); | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineConfig } from '@wagmi/cli' | ||
import { foundry, react } from "@wagmi/cli/plugins"; | ||
|
||
export default defineConfig({ | ||
out: '../web/wagmi.generated.ts', | ||
contracts: [], | ||
plugins: [ | ||
foundry({ | ||
exclude: [ | ||
'MockERC20.sol', | ||
], | ||
project: "./", | ||
deployments: { | ||
Citizend: { | ||
31337: "0x5fbdb2315678afecb367f032d93f642f64180aa3", | ||
}, | ||
Staking: { | ||
31337: "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512", | ||
}, | ||
}, | ||
}) | ||
], | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Contracts | ||
contracts/localhost | ||
|
||
wagmi.generated.ts |
Oops, something went wrong.