Skip to content

Commit 2a54216

Browse files
Initial commit
0 parents  commit 2a54216

38 files changed

Lines changed: 2796 additions & 0 deletions

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MAINNET_RPC=
2+
MAINNET_DEPLOYER_NAME=
3+
4+
SEPOLIA_RPC=
5+
SEPOLIA_DEPLOYER_NAME=
6+
7+
ETHERSCAN_API_KEY=

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sol linguist-language=Solidity

.github/workflows/canary.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Canary Release
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
export:
7+
name: Generate Interfaces And Contracts
8+
9+
# 1) Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
10+
if: false
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
export_type: ['interfaces', 'all']
15+
16+
env:
17+
# 2) Fill the project name to be used in NPM
18+
NPM_PACKAGE_NAME: 'my-cool-project'
19+
EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }}
20+
21+
steps:
22+
- name: Checkout Repo
23+
uses: actions/checkout@v4
24+
25+
- name: Install Foundry
26+
uses: foundry-rs/foundry-toolchain@v1
27+
with:
28+
version: stable
29+
30+
- name: Install Node
31+
uses: actions/setup-node@v4
32+
with:
33+
registry-url: 'https://registry.npmjs.org'
34+
node-version: 20.x
35+
cache: 'yarn'
36+
37+
- name: Install dependencies
38+
run: yarn --frozen-lockfile
39+
40+
- name: Build project and generate out directory
41+
run: yarn build
42+
43+
- name: Update version
44+
run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version
45+
46+
- name: Export Solidity - Export Type ${{ matrix.export_type }}
47+
uses: defi-wonderland/solidity-exporter-action@v2.1.0
48+
with:
49+
package_name: ${{ env.NPM_PACKAGE_NAME }}
50+
out: 'out'
51+
interfaces: 'solidity/interfaces'
52+
contracts: 'solidity/contracts'
53+
libraries: "solidity/libraries"
54+
export_type: '${{ matrix.export_type }}'
55+
56+
- name: Publish to NPM - Export Type ${{ matrix.export_type }}
57+
run: cd export/${{ env.NPM_PACKAGE_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag canary
58+
env:
59+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/coverage.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Coverage Check
2+
3+
on: [push]
4+
5+
env:
6+
COVERAGE_SENSITIVITY_PERCENT: 1
7+
8+
jobs:
9+
upload-coverage:
10+
name: Upload Coverage
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Foundry
17+
uses: foundry-rs/foundry-toolchain@v1
18+
with:
19+
version: stable
20+
21+
- name: Use Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20.x
25+
cache: 'yarn'
26+
27+
- name: Install dependencies
28+
run: yarn --frozen-lockfile --network-concurrency 1
29+
30+
- name: Run coverage
31+
shell: bash
32+
run: yarn coverage
33+
34+
- name: Setup LCOV
35+
uses: hrishikesh-kadam/setup-lcov@v1
36+
37+
- name: Filter directories
38+
run: lcov --remove lcov.info 'test/*' 'script/*' --output-file lcovNew.info --rc branch_coverage=1 --rc derive_function_end_line=0 --ignore-errors unused
39+
40+
- name: Capture coverage output
41+
id: new-coverage
42+
uses: zgosalvez/github-actions-report-lcov@v4
43+
with:
44+
coverage-files: lcovNew.info
45+
46+
- name: Retrieve previous coverage
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: coverage.info
50+
continue-on-error: true
51+
52+
- name: Check if a previous coverage exists
53+
run: |
54+
if [ ! -f coverage.info ]; then
55+
echo "Artifact not found. Initializing at 0"
56+
echo "0" >> coverage.info
57+
fi
58+
59+
- name: Compare previous coverage
60+
run: |
61+
old=$(cat coverage.info)
62+
new=$(( ${{ steps.new-coverage.outputs.total-coverage }} + ${{ env.COVERAGE_SENSITIVITY_PERCENT }} ))
63+
if [ "$new" -lt "$old" ]; then
64+
echo "Coverage decreased from $old to $new"
65+
exit 1
66+
fi
67+
mv lcovNew.info coverage.info
68+
69+
- name: Upload the new coverage
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: coverage.info
73+
path: ./coverage.info

.github/workflows/natspec.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Natspec Check
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
natspec:
7+
name: Run Lintspec
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: wagoid/commitlint-github-action@v5
13+
14+
- name: Install Foundry
15+
uses: foundry-rs/foundry-toolchain@v1
16+
with:
17+
version: stable
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20.x
23+
cache: 'yarn'
24+
25+
- name: Install and run Lintspec
26+
uses: beeb/lintspec@v0.6.0

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Production Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
11+
# 1) Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
12+
if: false
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
export_type: ['interfaces', 'all']
17+
18+
env:
19+
# 2) Fill the project name to be used in NPM
20+
NPM_PACKAGE_NAME: 'my-cool-project'
21+
EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }}
22+
23+
steps:
24+
- name: Checkout Repo
25+
uses: actions/checkout@v4
26+
27+
- name: Install Foundry
28+
uses: foundry-rs/foundry-toolchain@v1
29+
with:
30+
version: stable
31+
32+
- name: Install Node
33+
uses: actions/setup-node@v4
34+
with:
35+
registry-url: 'https://registry.npmjs.org'
36+
node-version: 20.x
37+
cache: 'yarn'
38+
39+
- name: Install dependencies
40+
run: yarn --frozen-lockfile
41+
42+
- name: Build project and generate out directory
43+
run: yarn build
44+
45+
- name: Export Solidity - Export Type ${{ matrix.export_type }}
46+
uses: defi-wonderland/solidity-exporter-action@v2.1.0
47+
with:
48+
package_name: ${{ env.NPM_PACKAGE_NAME }}
49+
out: 'out'
50+
interfaces: 'solidity/interfaces'
51+
contracts: 'solidity/contracts'
52+
libraries: "solidity/libraries"
53+
export_type: '${{ matrix.export_type }}'
54+
55+
- name: Publish to NPM - Export Type ${{ matrix.export_type }}
56+
run: cd export/${{ env.NPM_PACKAGE_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag latest
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tests.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
concurrency:
6+
group: ${{github.workflow}}-${{github.ref}}
7+
cancel-in-progress: true
8+
9+
env:
10+
MAINNET_RPC: ${{ secrets.MAINNET_RPC }}
11+
SEPOLIA_RPC: ${{ secrets.SEPOLIA_RPC }}
12+
13+
jobs:
14+
unit-tests:
15+
name: Run Unit Tests
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
with:
23+
version: stable
24+
25+
- name: Use Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20.x
29+
cache: 'yarn'
30+
31+
- name: Install dependencies
32+
run: yarn --frozen-lockfile --network-concurrency 1
33+
34+
- name: Precompile
35+
run: yarn build
36+
37+
- name: Run tests
38+
shell: bash
39+
run: yarn test:unit
40+
41+
integration-tests:
42+
name: Run Integration Tests
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install Foundry
48+
uses: foundry-rs/foundry-toolchain@v1
49+
with:
50+
version: stable
51+
52+
- name: Use Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: 20.x
56+
cache: 'yarn'
57+
58+
- name: Install dependencies
59+
run: yarn --frozen-lockfile --network-concurrency 1
60+
61+
- name: Precompile
62+
run: yarn build
63+
64+
- name: Run tests
65+
run: yarn test:integration
66+
67+
medusa-tests:
68+
name: Medusa Test
69+
runs-on: ubuntu-latest
70+
container: ghcr.io/trailofbits/eth-security-toolbox/ci:nightly-20241223
71+
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@v4
75+
with:
76+
submodules: recursive
77+
78+
- name: Install dependencies
79+
run: yarn --frozen-lockfile --network-concurrency 1
80+
81+
- name: Run Medusa
82+
run: medusa fuzz --test-limit 200000
83+
84+
halmos-tests:
85+
name: Run symbolic execution tests
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
90+
- name: Install Foundry
91+
uses: foundry-rs/foundry-toolchain@v1
92+
with:
93+
version: stable
94+
95+
- name: Use Node.js
96+
uses: actions/setup-node@v4
97+
with:
98+
node-version: 20.x
99+
cache: 'yarn'
100+
101+
- name: Install dependencies
102+
run: yarn --frozen-lockfile --network-concurrency 1
103+
104+
- name: Precompile
105+
run: yarn build
106+
107+
- name: Run tests
108+
run: yarn test:integration
109+
110+
lint:
111+
name: Static Analysis
112+
runs-on: ubuntu-latest
113+
114+
steps:
115+
- uses: actions/checkout@v4
116+
with:
117+
fetch-depth: 0
118+
119+
- uses: wagoid/commitlint-github-action@v5
120+
121+
- name: Install Foundry
122+
uses: foundry-rs/foundry-toolchain@v1
123+
with:
124+
version: stable
125+
126+
- name: Use Node.js
127+
uses: actions/setup-node@v4
128+
with:
129+
node-version: 20.x
130+
cache: 'yarn'
131+
132+
- name: Install dependencies
133+
run: yarn --frozen-lockfile --network-concurrency 1
134+
135+
- name: Run Forge formatter and Solhint
136+
run: yarn lint:check
137+
138+
- name: Install and run Bulloak
139+
uses: smol-ninja/bulloak-toolchain@v1
140+
with:
141+
test-dir: 'test/unit'

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# General
2+
yarn-error.log
3+
node_modules
4+
.DS_STORE
5+
.vscode
6+
7+
# Foundry files
8+
cache
9+
out-via-ir
10+
lcov.info
11+
12+
# Config files
13+
.env
14+
15+
# Avoid ignoring gitkeep
16+
!/**/.gitkeep
17+
18+
# Keep the latest deployment only
19+
broadcast/*/*/*
20+
21+
# Out dir
22+
out
23+
crytic-export
24+
25+
# Medusa corpus
26+
test/invariants/corpus

0 commit comments

Comments
 (0)