-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Onboarding updates #226
base: main
Are you sure you want to change the base?
Onboarding updates #226
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
stable | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,15 @@ $ cd contracts | |
$ forge install | ||
``` | ||
|
||
### Create .env.local file | ||
```sh | ||
$ cp .env.example .env.local | ||
``` | ||
|
||
### Obtain necessary API keys | ||
1. [Alchemy](https://www.alchemy.com) is used to resolve ENS domains. Copy the API key into `NEXT_PUBLIC_ALCHEMY_MAINNET_API_KEY` variable in `.env.local`. | ||
2. [Reown](https://cloud.reown.com) is used for WalletConnect functionality. Create an "Appkit" and copy the project id into `NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID` variable in `.env.local`. | ||
|
||
### Start local node | ||
|
||
[Anvil](https://book.getfoundry.sh/reference/anvil/) starts a local fork from the most recent block based on the rpc url provided. The chain id is used to identify the anvil network in the app config. Block time is 5 seconds to match gnosis chain. | ||
|
@@ -23,9 +32,11 @@ $ anvil --fork-url https://rpc.gnosis.gateway.fm --chain-id 31337 --block-time 5 | |
|
||
### Setup wallet | ||
|
||
We also need a wallet for working locally. To set this up take the private key for the first wallet in the list displayed when you start anvil and add this account to metamask. This is the `DEV_ACCOUNT` address in the setup script. | ||
1. We need a wallet for working locally. To set this up take the private key for the first wallet in the list displayed when you start anvil and add this account to metamask. This is the `DEV_ACCOUNT` address in the setup script. | ||
|
||
2. Add the Anvil RPC url to metamask: `http://127.0.0.1:8545` with chain id `31337` | ||
|
||
Because of how the distributor contract works the developer wallet needs to hold some bread before we deploy the contracts for us to be able to vote. The setup script takes care of this as well as funding the wallet with LP tokens which is needed for the LP locking feature. | ||
3. Because of how the distributor contract works the developer wallet needs to hold some bread before we deploy the contracts for us to be able to vote. The setup script takes care of this as well as funding the wallet with LP tokens which is needed for the LP locking feature. | ||
|
||
```sh | ||
$ pnpm run chain:setup | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i cloned your fork to try this whole setup from a fresh start and noticed this setup step fails if tsx is not installed globally. so a suggestion to add a note here or above in the list of general dependencies, for installing tsx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird that was happening for you as tsx is added as a dev dependency 🤔 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,12 @@ import { | |
walletActions, | ||
} from "viem"; | ||
import { foundry } from "viem/chains"; | ||
import { BREAD_ADDRESS, BUTTER_ADDRESS } from "../src/constants"; | ||
|
||
export const anvilConfig = getConfig(31337); | ||
|
||
export const anvilAccounts: Array<Hex> = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was unused. |
||
// mock wallet 2 | ||
// "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", | ||
"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc", | ||
"0x90f79bf6eb2c4f870365e785982e1f101e93b906", | ||
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65", | ||
"0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc", | ||
"0x976ea74026e726554db657fa54763abd0c3a0aa9", | ||
"0x14dc79964da2c08b23698b3d3cc7ca32193d9955", | ||
"0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", | ||
"0xa0ee7a142d267c1f36714e4a8f75612f20a79720", | ||
]; | ||
// Wrapped into a function so we do not initialize on import, before all contracts are deployed | ||
export function getAnvilConfig() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was running into a problem: importing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what was happening now 🙂 |
||
return getConfig(31337); | ||
} | ||
|
||
export const DEV_ACCOUNT = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; | ||
const BUTTER_WHALE = "0xc2fB4B3EA53E10c88D193E709A81C4dc7aEC902e" as Hex; | ||
|
@@ -62,7 +53,7 @@ export async function bakeBread( | |
try { | ||
const hash = await testClient.writeContract({ | ||
account: account, | ||
address: anvilConfig.BREAD.address, | ||
address: BREAD_ADDRESS, | ||
abi: BREAD_ABI, | ||
functionName: "mint", | ||
// mint is a payable function so we pass the value like this | ||
|
@@ -100,7 +91,7 @@ export async function fundLpTokens(account: Hex = DEV_ACCOUNT) { | |
|
||
await testClient.writeContract({ | ||
account: BUTTER_WHALE, | ||
address: anvilConfig.BUTTER.address, | ||
address: BUTTER_ADDRESS, | ||
abi: ERC20_ABI, | ||
functionName: "transfer", | ||
// this isn't a payable function so we pass the value as an argument | ||
|
@@ -114,7 +105,7 @@ export async function balanceOf(anvilAccount: Hex) { | |
}); | ||
|
||
const res = await publicClient.readContract({ | ||
address: anvilConfig.BREAD.address, | ||
address: getAnvilConfig().BREAD.address, | ||
abi: BREAD_ABI, | ||
functionName: "balanceOf", | ||
args: [anvilAccount], | ||
|
@@ -136,7 +127,7 @@ export async function castVote(account: Hex = DEV_ACCOUNT) { | |
|
||
try { | ||
const hash = await testClient.writeContract({ | ||
address: anvilConfig.DISBURSER.address, | ||
address: getAnvilConfig().DISBURSER.address, | ||
abi: DISTRIBUTOR_ABI, | ||
functionName: "castVote", | ||
account: account, | ||
|
@@ -171,7 +162,7 @@ export async function castVote(account: Hex = DEV_ACCOUNT) { | |
|
||
export async function getCurrentDistribution() { | ||
const res = await publicClient.readContract({ | ||
address: anvilConfig.DISBURSER.address, | ||
address: getAnvilConfig().DISBURSER.address, | ||
abi: DISTRIBUTOR_ABI, | ||
functionName: "getCurrentVotingDistribution", | ||
}); | ||
|
@@ -186,7 +177,7 @@ export async function setClaimer(newClaimer: Hex) { | |
|
||
try { | ||
const hash = await testClient.writeContract({ | ||
address: anvilConfig.BREAD.address, | ||
address: getAnvilConfig().BREAD.address, | ||
abi: BREAD_ABI, | ||
functionName: "setYieldClaimer", | ||
account: BREAD_OWNER, | ||
|
@@ -211,10 +202,10 @@ export async function lockLpTokens(account: Hex = DEV_ACCOUNT) { | |
try { | ||
const hash = await testClient.writeContract({ | ||
account: account, | ||
address: anvilConfig.BUTTER.address, | ||
address: getAnvilConfig().BUTTER.address, | ||
abi: ERC20_ABI, | ||
functionName: "approve", | ||
args: [anvilConfig.BUTTERED_BREAD.address, parseUnits("5000", 18)], | ||
args: [getAnvilConfig().BUTTERED_BREAD.address, parseUnits("5000", 18)], | ||
}); | ||
|
||
const receipt = await publicClient.waitForTransactionReceipt({ hash }); | ||
|
@@ -231,10 +222,10 @@ export async function lockLpTokens(account: Hex = DEV_ACCOUNT) { | |
try { | ||
const hash = await testClient.writeContract({ | ||
account: account, | ||
address: anvilConfig.BUTTERED_BREAD.address, | ||
address: getAnvilConfig().BUTTERED_BREAD.address, | ||
abi: BUTTERED_BREAD_ABI, | ||
functionName: "deposit", | ||
args: [anvilConfig.BUTTER.address, parseUnits("5000", 18)], | ||
args: [getAnvilConfig().BUTTER.address, parseUnits("5000", 18)], | ||
}); | ||
|
||
const receipt = await publicClient.waitForTransactionReceipt({ hash }); | ||
|
@@ -257,7 +248,7 @@ export async function distributeYield(account: Hex = DEV_ACCOUNT) { | |
try { | ||
const hash = await testClient.writeContract({ | ||
account: account, | ||
address: anvilConfig.DISBURSER.address, | ||
address: getAnvilConfig().DISBURSER.address, | ||
abi: DISTRIBUTOR_ABI, | ||
functionName: "distributeYield", | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a minimum version of node for NextJS and I was below minimum. With this file running
nvm use
fixes the situation and is generally safe.