Skip to content

Commit 2c3b740

Browse files
committed
Sets up periphery base scaffolding and adds protocol-core as a dependency
1 parent cde5699 commit 2c3b740

17 files changed

+18753
-0
lines changed

.env.example

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# MAINNET
2+
MAINNET_URL = https://eth-mainnet.g.alchemy.com/v2/1234123412341234
3+
MAINNET_PRIVATEKEY= 12341234123412341234123412341234
4+
5+
# GOERLI
6+
GOERLI_URL = https://eth-goerli.g.alchemy.com/v2/1234123412341234
7+
GOERLI_PRIVATEKEY = 12341234123412341234123412341234
8+
9+
# ETHSCAN
10+
ETHERSCAN_API_KEY = ETHERSCANAPIKEYETHERSCANAPIKEY

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.openzeppelin
3+
.eslintrc.js

.github/workflows/test.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
FOUNDRY_PROFILE: ci
7+
8+
jobs:
9+
check:
10+
strategy:
11+
fail-fast: true
12+
13+
name: Foundry project
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
with:
23+
version: nightly
24+
25+
- name: Run Forge build
26+
run: |
27+
forge --version
28+
forge build --sizes
29+
id: build
30+
31+
- name: Run Forge tests
32+
run: |
33+
forge test -vvv
34+
id: test

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
artifacts/
5+
forge-cache/
6+
7+
# Ignores development broadcast logs
8+
# !/broadcast
9+
deployments
10+
broadcast
11+
!/broadcast/*/1/
12+
13+
# Docs
14+
docs/
15+
16+
# Dotenv file
17+
.env
18+
19+
.idea/
20+
.github/
21+
node_modules/
22+
23+
.vscode
24+
.DS_Store
25+
pnpm-lock.yaml
26+
27+
coverage
28+
29+
# contracts
30+
abi
31+
typechain
32+
!./script/out
33+
34+
# converage
35+
lcov.info

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

.prettierignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
coverage
3+
out
4+
/lib
5+
assets
6+
node_modules
7+
.next
8+
.idea
9+
.github

.prettierrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"useTabs": false,
3+
"printWidth": 120,
4+
"trailingComma": "es5",
5+
"tabWidth": 4,
6+
"semi": false,
7+
"singleQuote": false,
8+
"bracketSpacing": true,
9+
"overrides": [
10+
{
11+
"files": ["*.ts", "*.js"],
12+
"options": {
13+
"tabWidth": 2
14+
}
15+
}
16+
]
17+
}

.solhint.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"code-complexity": ["error", 8],
6+
"compiler-version": ["error", ">=0.8.19"],
7+
"const-name-snakecase": "off",
8+
"no-empty-blocks": "off",
9+
"constructor-syntax": "error",
10+
"func-visibility": ["error", { "ignoreConstructors": true }],
11+
"modifier-name-mixedcase": "error",
12+
"max-line-length": ["error", 120],
13+
"not-rely-on-time": "off",
14+
"reason-string": ["warn", { "maxLength": 64 }],
15+
"no-unused-import": "error",
16+
"no-unused-vars": "error",
17+
"no-inline-assembly": "off",
18+
"avoid-low-level-calls": "off",
19+
"no-global-import": "error",
20+
"prettier/prettier": "error",
21+
"private-vars-leading-underscore": "off"
22+
}
23+
}

Makefile

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
-include .env
2+
3+
.PHONY: all test clean coverage typechain deploy-main
4+
5+
all: clean install build
6+
7+
# function: generate abi for given contract name (key)
8+
# requires contract name to match the file name
9+
define generate_abi
10+
$(eval $@_CONTRACT_NAME = $(1))
11+
$(eval $@_CONTRACT_PATH = $(2))
12+
forge inspect --optimize --optimizer-runs 2000 contracts/${$@_CONTRACT_PATH}/${$@_CONTRACT_NAME}.sol:${$@_CONTRACT_NAME} abi > abi/${$@_CONTRACT_NAME}.json
13+
endef
14+
15+
# Clean the repo
16+
forge-clean :; forge clean
17+
clean :; npx hardhat clean
18+
19+
# Remove modules
20+
forge-remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules"
21+
22+
install :; npm install
23+
24+
# Update Dependencies
25+
forge-update :; forge update
26+
27+
forge-build :; forge build
28+
build :; npx hardhat compile
29+
30+
test :; forge test
31+
32+
snapshot :; forge snapshot
33+
34+
slither :; slither ./contracts
35+
36+
# glob doesn't work for nested folders, so we do it manually
37+
format:
38+
npx prettier --write contracts/*.sol
39+
npx prettier --write contracts/**/*.sol
40+
npx prettier --write contracts/**/**/*.sol
41+
npx prettier --write contracts/**/**/**/*.sol
42+
npx prettier --write contracts/**/**/**/**/*.sol
43+
44+
# generate forge coverage on pinned mainnet fork
45+
# process lcov file, ignore test, script, and contracts/mocks folders
46+
# generate html report from lcov.info (ignore "line ... has branchcov but no linecov data" error)
47+
coverage:
48+
mkdir -p coverage
49+
forge coverage --report lcov --fork-url https://rpc.ankr.com/eth --fork-block-number 19042069
50+
lcov --remove lcov.info -o coverage/lcov.info 'test/*' 'script/*' 'contracts/mocks/*' --rc branch_coverage=1
51+
genhtml coverage/lcov.info -o coverage --rc branch_coverage=1 --ignore-errors category
52+
53+
abi:
54+
mkdir -p abi
55+
@$(call generate_abi,"AccessController",".")
56+
@$(call generate_abi,"DisputeModule","./modules/dispute-module")
57+
@$(call generate_abi,"RoyaltyModule","./modules/royalty-module")
58+
@$(call generate_abi,"TaggingModule","./modules/tagging")
59+
@$(call generate_abi,"IPAccountRegistry","./registries")
60+
@$(call generate_abi,"IPRecordRegistry","./registries")
61+
@$(call generate_abi,"LicenseRegistry","./registries")
62+
@$(call generate_abi,"ModuleRegistry","./registries")
63+
@$(call generate_abi,"IPMetadataResolver","./resolvers")
64+
65+
# typechain:
66+
# make abi
67+
# rm -rf ./types-typechain
68+
# npx typechain --target ethers-v6 ./abi/*.json --out-dir ./types-typechain
69+
typechain :; npx hardhat typechain
70+
71+
# solhint should be installed globally
72+
lint :; npx solhint contracts/**/*.sol && npx solhint contracts/*.sol
73+
74+
deploy-goerli :; npx hardhat run ./script/deploy-reveal-engine.js --network goerli
75+
verify-goerli :; npx hardhat verify --network goerli ${contract}
76+
77+
anvil :; anvil -m 'test test test test test test test test test test test junk'
78+
79+
# run: RPC_URL=https://rpc.url make deploy-main
80+
deploy-main :; forge script script/foundry/deployment/Main.s.sol:Main --rpc-url ${RPC_URL} --broadcast --verify -vvvv

README.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Foundry
2+
3+
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
4+
5+
Foundry consists of:
6+
7+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
11+
12+
## Documentation
13+
14+
https://book.getfoundry.sh/
15+
16+
## Usage
17+
18+
### Build
19+
20+
```shell
21+
$ forge build
22+
```
23+
24+
### Test
25+
26+
```shell
27+
$ forge test
28+
```
29+
30+
### Format
31+
32+
```shell
33+
$ forge fmt
34+
```
35+
36+
### Gas Snapshots
37+
38+
```shell
39+
$ forge snapshot
40+
```
41+
42+
### Anvil
43+
44+
```shell
45+
$ anvil
46+
```
47+
48+
### Deploy
49+
50+
```shell
51+
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52+
```
53+
54+
### Cast
55+
56+
```shell
57+
$ cast <subcommand>
58+
```
59+
60+
### Help
61+
62+
```shell
63+
$ forge --help
64+
$ anvil --help
65+
$ cast --help
66+
```

foundry.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[profile.default]
2+
src = 'contracts'
3+
out = 'out'
4+
libs = ['node_modules', 'lib']
5+
cache_path = 'forge-cache'
6+
gas_reports = ["*"]
7+
optimizer = true
8+
optimizer_runs = 20000
9+
test = 'test'
10+
solc = '0.8.23'
11+
fs_permissions = [{ access = 'read-write', path = './deploy-out' }]
12+
13+
[rpc_endpoints]
14+
# Comment out for local development (testing requires 0xSplit forks — will add Mock soon)
15+
# pin fork by using --fork-block-number 19042069 to reduce wait time
16+
mainnet = "https://rpc.ankr.com/eth"
17+
sepolia = "${SEPOLIA_RPC_URL}"
18+
19+
20+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

lib/forge-std

Submodule forge-std added at ae570fe

0 commit comments

Comments
 (0)