Skip to content

Commit 7829833

Browse files
Initial commit
0 parents  commit 7829833

37 files changed

+3221
-0
lines changed

.env.example

+7
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sol linguist-language=Solidity

.github/workflows/canary.yml

+59
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/[email protected]
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

+73
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 lcov_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/release.yml

+58
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/[email protected]
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

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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: Lint Commit Messages
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+
- run: yarn lint:check

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
11+
# Config files
12+
.env
13+
14+
# Avoid ignoring gitkeep
15+
!/**/.gitkeep
16+
17+
# Keep the latest deployment only
18+
broadcast/*/*/*
19+
20+
# Out dir
21+
out
22+
crytic-export
23+
24+
# Echidna corpus
25+
test/invariants/fuzz/echidna_coverage

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no-install commitlint --edit $1

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 1. Build the contracts
2+
# 2. Stage build output
3+
# 3. Lint and stage style improvements
4+
yarn build && npx lint-staged

.solhint.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"rules": {
4+
"compiler-version": ["warn"],
5+
"quotes": "off",
6+
"func-visibility": ["warn", { "ignoreConstructors": true }],
7+
"no-inline-assembly": "off",
8+
"no-empty-blocks": "off",
9+
"private-vars-leading-underscore": ["warn", { "strict": false }],
10+
"ordering": "warn",
11+
"avoid-low-level-calls": "off",
12+
"named-parameters-mapping": "warn"
13+
}
14+
}

LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright © 2023 Wonderland
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)