Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 8 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ jobs:
- name: Install dependencies
run: yarn install --immutable

- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
run: yarn chain & yarn deploy
- name: Install foundry-toolchain
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run hardhat lint
run: yarn hardhat:lint --max-warnings=0
- name: Run foundry node, deploy contracts (& generate contracts typescript output)
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
run: yarn chain & yarn deploy

- name: Run nextjs lint
run: yarn next:lint --max-warnings=0
Expand Down
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "packages/foundry/lib/forge-std"]
path = packages/foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "packages/foundry/lib/openzeppelin-contracts"]
path = packages/foundry/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/foundry/lib/solidity-bytes-utils"]
path = packages/foundry/lib/solidity-bytes-utils
url = https://github.com/gnsps/solidity-bytes-utils
1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@
]
},
"scripts": {
"account": "yarn hardhat:account",
"account:generate": "yarn workspace @se-2/hardhat account:generate",
"account:import": "yarn workspace @se-2/hardhat account:import",
"account:reveal-pk": "yarn workspace @se-2/hardhat account:reveal-pk",
"chain": "yarn hardhat:chain",
"compile": "yarn hardhat:compile",
"deploy": "yarn hardhat:deploy",
"fork": "yarn hardhat:fork",
"format": "yarn next:format && yarn hardhat:format",
"generate": "yarn account:generate",
"hardhat:account": "yarn workspace @se-2/hardhat account",
"hardhat:chain": "yarn workspace @se-2/hardhat chain",
"hardhat:check-types": "yarn workspace @se-2/hardhat check-types",
"hardhat:clean": "yarn workspace @se-2/hardhat clean",
"hardhat:compile": "yarn workspace @se-2/hardhat compile",
"hardhat:deploy": "yarn workspace @se-2/hardhat deploy",
"hardhat:flatten": "yarn workspace @se-2/hardhat flatten",
"hardhat:fork": "yarn workspace @se-2/hardhat fork",
"hardhat:format": "yarn workspace @se-2/hardhat format",
"hardhat:generate": "yarn workspace @se-2/hardhat generate",
"hardhat:hardhat-verify": "yarn workspace @se-2/hardhat hardhat-verify",
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"hardhat:verify": "yarn workspace @se-2/hardhat verify",
"account": "yarn foundry:account",
"account:generate": "yarn foundry:generate",
"account:import": "yarn foundry:account-import",
"account:reveal-pk": "yarn workspace @se-2/foundry account:reveal-pk",
"chain": "yarn foundry:chain",
"compile": "yarn foundry:compile",
"deploy": "yarn foundry:deploy",
"flatten": "yarn foundry:flatten",
"fork": "yarn foundry:fork",
"format": "yarn next:format && yarn foundry:format",
"foundry:account": "yarn workspace @se-2/foundry account",
"foundry:account-import": "yarn workspace @se-2/foundry account:import",
"foundry:chain": "yarn workspace @se-2/foundry chain",
"foundry:clean": "yarn workspace @se-2/foundry clean",
"foundry:compile": "yarn workspace @se-2/foundry compile",
"foundry:deploy": "yarn workspace @se-2/foundry deploy",
"foundry:deploy-verify": "yarn workspace @se-2/foundry deploy:verify",
"foundry:flatten": "yarn workspace @se-2/foundry flatten",
"foundry:fork": "yarn workspace @se-2/foundry fork",
"foundry:format": "yarn workspace @se-2/foundry format",
"foundry:generate": "yarn workspace @se-2/foundry account:generate",
"foundry:lint": "yarn workspace @se-2/foundry lint",
"foundry:test": "yarn workspace @se-2/foundry test",
"foundry:verify": "yarn workspace @se-2/foundry verify",
"generate": "yarn foundry:generate",
"postinstall": "husky install",
"ipfs": "yarn workspace @se-2/nextjs ipfs",
"lint": "yarn next:lint && yarn hardhat:lint",
"lint": "yarn next:lint && yarn foundry:lint",
"next:build": "yarn workspace @se-2/nextjs build",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"next:format": "yarn workspace @se-2/nextjs format",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:serve": "yarn workspace @se-2/nextjs serve",
"precommit": "lint-staged",
"start": "yarn workspace @se-2/nextjs dev",
"test": "yarn hardhat:test",
"test": "yarn foundry:test",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:login": "yarn workspace @se-2/nextjs vercel:login",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo",
"verify": "yarn hardhat:verify"
"verify": "yarn foundry:verify"
},
"devDependencies": {
"husky": "~9.1.6",
Expand Down
19 changes: 19 additions & 0 deletions packages/foundry/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Template for foundry environment variables.

# For local development, copy this file, rename it to .env, and fill in the values.

# We provide default values so developers can start prototyping out of the box,
# but we recommend getting your own API Keys for Production Apps.

# DEPLOYER_PRIVATE_KEY is used while deploying contract.
# On anvil chain the value of it can be empty since we use the prefunded account
# which comes with anvil chain to deploy contract.
# NOTE: You don't need to manually change the value of DEPLOYER_PRIVATE_KEY, it should
# be auto filled when run `yarn generate`.

# Alchemy rpc URL is used while deploying the contracts to some testnets/mainnets, checkout `foundry.toml` for it's use.
ALCHEMY_API_KEY=oKxs-03sij-U_N0iOlrSsZFr29-IqbuF
# Etherscan API key is used to verify the contract on etherscan.
ETHERSCAN_API_KEY=DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW
# Default account for localhost / use "scaffold-eth-custom" if you wish to use a generated account or imported account
LOCALHOST_KEYSTORE_ACCOUNT=scaffold-eth-default
14 changes: 14 additions & 0 deletions packages/foundry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
localhost.json
6 changes: 6 additions & 0 deletions packages/foundry/.prettier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"tabWidth": 2,
"trailingComma": "all"
}
61 changes: 61 additions & 0 deletions packages/foundry/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.PHONY: build deploy generate-abis get-address account chain compile flatten fork format lint test verify

DEPLOY_SCRIPT ?= script/Deploy.s.sol

# setup wallet for anvil
setup-anvil-wallet:
shx rm ~/.foundry/keystores/scaffold-eth-default 2>/dev/null; shx rm -rf broadcast/Deploy.s.sol/31337
cast wallet import --private-key 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 --unsafe-password 'localhost' scaffold-eth-default

# Start local chain
chain: setup-anvil-wallet
anvil

# Start a fork
fork: setup-anvil-wallet
anvil --fork-url ${FORK_URL} --chain-id 31337

# Deploy the contracts
deploy:
@if [ ! -f "$(DEPLOY_SCRIPT)" ]; then echo "Error: Deploy script '$(DEPLOY_SCRIPT)' not found"; exit 1; fi
@if [ "$(RPC_URL)" = "localhost" ]; then if [ "$(ETH_KEYSTORE_ACCOUNT)" = "scaffold-eth-default" ]; then forge script $(DEPLOY_SCRIPT) --rpc-url localhost --password localhost --broadcast --ffi; else forge script $(DEPLOY_SCRIPT) --rpc-url localhost --broadcast --ffi; fi else forge script $(DEPLOY_SCRIPT) --rpc-url $(RPC_URL) --broadcast --ffi; fi

# Deploy and generate ABIs
deploy-and-generate-abis: deploy generate-abis

# Generate TypeScript ABIs
generate-abis:
node scripts-js/generateTsAbis.js

# List account
account:
@node scripts-js/checkAccountBalance.js

# Get address of a keystore
get-address:
@cast wallet address --account $(ACCOUNT_NAME)

# Compile contracts
compile:
forge compile

# Flatten contracts
flatten:
forge flatten

# Format code
format:
forge fmt && prettier --write ./scripts-js/**/*.js

# Lint code
lint:
forge fmt --check && prettier --check ./scripts-js/**/*.js

# Run tests
test:
forge test

# Verify contracts
verify:
forge script script/VerifyAll.s.sol --ffi --rpc-url $(RPC_URL)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions packages/foundry/broadcast/Deploy.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/foundry/deployments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore 31337 deployments
31337.json
3 changes: 3 additions & 0 deletions packages/foundry/deployments/11155111.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"networkName": "sepolia"
}
20 changes: 20 additions & 0 deletions packages/foundry/foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lib/forge-std": {
"tag": {
"name": "v1.14.0",
"rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6"
}
},
"lib/openzeppelin-contracts": {
"tag": {
"name": "v5.5.0",
"rev": "fcbae5394ae8ad52d8e580a3477db99814b9d565"
}
},
"lib/solidity-bytes-utils": {
"tag": {
"name": "v0.8.4",
"rev": "f4413cd6137b78403e3a1156bee6aceab46b46fa"
}
}
}
49 changes: 49 additions & 0 deletions packages/foundry/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[profile.default]
src = 'contracts'
out = 'out'
libs = ['lib', 'node_modules']
fs_permissions = [{ access = "read-write", path = "./"}]


[rpc_endpoints]
default_network = "http://127.0.0.1:8545"

mainnet = "https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_API_KEY}"
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
arbitrumSepolia = "https://arb-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
optimismSepolia = "https://opt-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygon = "https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygonMumbai = "https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygonZkEvm = "https://zkevm-rpc.com"
polygonZkEvmTestnet = "https://rpc.public.zkevm-test.net"
gnosis = "https://rpc.gnosischain.com"
chiado = "https://rpc.chiadochain.net"
base = "https://mainnet.base.org"
baseSepolia = "https://sepolia.base.org"
scrollSepolia = "https://sepolia-rpc.scroll.io"
scroll = "https://rpc.scroll.io"
pgn = "https://rpc.publicgoods.network"
pgnTestnet = "https://sepolia.publicgoods.network"


localhost = "http://127.0.0.1:8545"

[etherscan]
polygonMumbai = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }



[fmt]
line_length = 120
tab_width = 4
quote_style = "double"
bracket_spacing = true
int_types = "long"




# See more config options https://book.getfoundry.sh/reference/config/overview
1 change: 1 addition & 0 deletions packages/foundry/lib/forge-std/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/Vm.sol linguist-generated
1 change: 1 addition & 0 deletions packages/foundry/lib/forge-std/.github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @danipopes @klkvr @mattsse @grandizzy @yash-atreya @zerosnacks @onbjerg @0xrusowsky
6 changes: 6 additions & 0 deletions packages/foundry/lib/forge-std/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
Loading
Loading