Skip to content

Commit

Permalink
Merge branch 'main' into feat/foundry-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
lempire123 authored Nov 28, 2024
2 parents 6bedb6b + 0db7d79 commit 6327968
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MAINNET_RPC=
MAINNET_DEPLOYER_PK=
MAINNET_DEPLOYER_NAME=

SEPOLIA_RPC=
SEPOLIA_DEPLOYER_PK=
SEPOLIA_DEPLOYER_NAME=

ETHERSCAN_API_KEY=
29 changes: 17 additions & 12 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ on: workflow_dispatch
jobs:
export:
name: Generate Interfaces And Contracts
# Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM

# 1) Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
if: false
runs-on: ubuntu-latest
strategy:
matrix:
export_type: ['interfaces', 'contracts']
export_type: ['interfaces', 'all']

env:
# 2) Fill the project name to be used in NPM
NPM_PACKAGE_NAME: 'my-cool-project'
EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }}

steps:
- name: Checkout Repo
Expand All @@ -37,18 +43,17 @@ jobs:
- name: Update version
run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version

- name: Export Solidity - ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@v2.0.0
- name: Export Solidity - Export Type ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@v2.1.0
with:
# Update package_name with your package name
package_name: 'my-cool-project'
package_name: ${{ env.NPM_PACKAGE_NAME }}
out: 'out'
interfaces: 'src/interfaces'
contracts: 'src/contracts'
interfaces: 'solidity/interfaces'
contracts: 'solidity/contracts'
libraries: "solidity/libraries"
export_type: '${{ matrix.export_type }}'

- name: Publish to NPM - ${{ matrix.export_type }}
# Update `my-cool-project` with your package name
run: cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public --tag canary
- name: Publish to NPM - Export Type ${{ matrix.export_type }}
run: cd export/${{ env.NPM_PACKAGE_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag canary
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 17 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ on:
jobs:
release:
name: Release
# Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM

# 1) Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
if: false
runs-on: ubuntu-latest
strategy:
matrix:
export_type: ['interfaces', 'contracts']
export_type: ['interfaces', 'all']

env:
# 2) Fill the project name to be used in NPM
NPM_PACKAGE_NAME: 'my-cool-project'
EXPORT_NAME: ${{ matrix.export_type == 'interfaces' && '-interfaces' || '' }}

steps:
- name: Checkout Repo
Expand All @@ -36,18 +42,17 @@ jobs:
- name: Build project and generate out directory
run: yarn build

- name: Export Solidity - ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@v2.0.0
- name: Export Solidity - Export Type ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@v2.1.0
with:
# Update package_name with your package name
package_name: 'my-cool-project'
package_name: ${{ env.NPM_PACKAGE_NAME }}
out: 'out'
interfaces: 'src/interfaces'
contracts: 'src/contracts'
interfaces: 'solidity/interfaces'
contracts: 'solidity/contracts'
libraries: "solidity/libraries"
export_type: '${{ matrix.export_type }}'

- name: Publish to NPM - ${{ matrix.export_type }}
# Update `my-cool-project` with your package name
run: cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public --tag latest
- name: Publish to NPM - Export Type ${{ matrix.export_type }}
run: cd export/${{ env.NPM_PACKAGE_NAME }}${{ env.EXPORT_NAME }} && npm publish --access public --tag latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile using 0.8.14 and via-ir=false
- name: Precompile
run: yarn build

- name: Run tests
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile using 0.8.14 and via-ir=false
- name: Precompile
run: yarn build

- name: Run tests
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- name: Precompile with via-ir=false
- name: Precompile
run: yarn build

- name: Run tests
Expand Down Expand Up @@ -151,4 +151,4 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- run: yarn lint:check
- run: yarn lint:check
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
7 changes: 2 additions & 5 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# 1. Build the contracts
# 2. Stage build output
# 2. Lint and stage style improvements
# 2. Stage build output
# 3. Lint and stage style improvements
yarn build && npx lint-staged
10 changes: 3 additions & 7 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["off"],
"constructor-syntax": "warn",
"quotes": ["error", "single"],
"compiler-version": ["warn"],
"quotes": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"private-vars-leading-underscore": ["warn", { "strict": false }],
"ordering": "warn",
"immutable-name-snakecase": "warn",
"avoid-low-level-calls": "off",
"no-console": "off",
"max-line-length": ["warn", 120]
"named-parameters-mapping": "warn"
}
}
25 changes: 0 additions & 25 deletions .solhint.tests.json

This file was deleted.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,21 @@ yarn coverage

### Setup

Configure the `.env` variables.
Configure the `.env` variables and source them:

```bash
source .env
```

Import your private keys into Foundry's encrypted keystore:

```bash
cast wallet import $MAINNET_DEPLOYER_NAME --interactive
```

```bash
cast wallet import $SEPOLIA_DEPLOYER_NAME --interactive
```

### Sepolia

Expand Down
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bracket_spacing = false
int_types = 'long'
quote_style = 'single'
number_underscore = 'thousands'
multiline_func_header = 'params_first'
multiline_func_header = 'params_first_multi'
sort_imports = true

[profile.default]
Expand All @@ -32,5 +32,5 @@ mainnet = "${MAINNET_RPC}"
sepolia = "${SEPOLIA_RPC}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", chain = "mainnet" }
sepolia = { key = "${ETHERSCAN_API_KEY}", chain = "sepolia" }
mainnet = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }
3 changes: 2 additions & 1 deletion natspec-smells.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

/** @type {import('@defi-wonderland/natspec-smells').Config} */
module.exports = {
include: 'src'
include: 'src/**/*.sol',
exclude: '(test|scripts)/**/*.sol',
};
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
"build": "forge build",
"build:optimized": "FOUNDRY_PROFILE=optimized forge build",
"coverage": "forge coverage --report summary --report lcov --match-path 'test/unit/*'",
"deploy:mainnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK'",
"deploy:sepolia": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK'",
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
"deploy:mainnet": "bash -c 'source .env && forge script Deploy --rpc-url $MAINNET_RPC --account $MAINNET_DEPLOYER_NAME --broadcast --verify --chain mainnet -vvvvv'",
"deploy:sepolia": "bash -c 'source .env && forge script Deploy --rpc-url $SEPOLIA_RPC --account $SEPOLIA_DEPLOYER_NAME --broadcast --verify --chain sepolia -vvvvv'",
"lint:check": "yarn lint:sol && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol --fix",
"lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js",
"lint:sol-logic": "solhint -c .solhint.json 'src/**/*.sol' 'script/**/*.sol'",
"lint:sol-tests": "solhint -c .solhint.tests.json 'test/**/*.sol'",
"prepare": "husky install",
"lint:sol": "solhint 'src/**/*.sol' 'script/**/*.sol' 'test/**/*.sol'",
"prepare": "husky",
"test": "forge test -vvv",
"test:fuzz": "echidna test/invariants/fuzz/Greeter.t.sol --contract InvariantGreeter --corpus-dir test/invariants/fuzz/echidna_coverage/ --test-mode assertion",
"test:integration": "forge test --match-contract Integration -vvv",
Expand All @@ -30,17 +29,16 @@
},
"lint-staged": {
"*.{js,css,md,ts,sol}": "forge fmt",
"(src|script)/**/*.sol": "yarn lint:sol-logic",
"test/**/*.sol": "yarn lint:sol-tests",
"(src|test|script)/**/*.sol": "yarn lint:sol",
"package.json": "sort-package-json"
},
"devDependencies": {
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@defi-wonderland/natspec-smells": "1.1.1",
"forge-std": "github:foundry-rs/forge-std#1.8.2",
"@defi-wonderland/natspec-smells": "1.1.3",
"forge-std": "github:foundry-rs/forge-std#1.9.2",
"halmos-cheatcodes": "github:a16z/halmos-cheatcodes#c0d8655",
"husky": ">=8",
"husky": ">=9",
"lint-staged": ">=10",
"solhint-community": "4.0.0",
"sort-package-json": "2.10.0"
Expand Down
7 changes: 7 additions & 0 deletions script/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rules": {
"ordering": "off",
"one-contract-per-file": "off",
"no-console": "off"
}
}
11 changes: 11 additions & 0 deletions src/interfaces/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"rules": {
"ordering": "warn",
"style-guide-casing": [
"warn",
{
"ignoreExternalFunctions": true
}
]
}
}
16 changes: 16 additions & 0 deletions test/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rules": {
"style-guide-casing": [
"warn",
{
"ignorePublicFunctions":true,
"ignoreExternalFunctions":true,
"ignoreContracts":true
}
],
"no-global-import": "off",
"max-states-count": "off",
"ordering": "off",
"one-contract-per-file": "off"
}
}
Loading

0 comments on commit 6327968

Please sign in to comment.