diff --git a/.env.example b/.env.example index fe295b73..14d938c8 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ MAINNET_RPC= -MAINNET_DEPLOYER_PK= +MAINNET_DEPLOYER_NAME= SEPOLIA_RPC= -SEPOLIA_DEPLOYER_PK= +SEPOLIA_DEPLOYER_NAME= ETHERSCAN_API_KEY= diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 0c13f9c2..b5631751 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b70ed1fe..c61a69d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 18624462..a9b5fdbb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 @@ -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 @@ -151,4 +151,4 @@ jobs: - name: Install dependencies run: yarn --frozen-lockfile --network-concurrency 1 - - run: yarn lint:check \ No newline at end of file + - run: yarn lint:check diff --git a/.husky/commit-msg b/.husky/commit-msg index 314e8214..d468455f 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx --no-install commitlint --edit $1 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 509d461f..c8d494d5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -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 \ No newline at end of file diff --git a/.solhint.json b/.solhint.json index 94f58b24..23782374 100644 --- a/.solhint.json +++ b/.solhint.json @@ -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" } } diff --git a/.solhint.tests.json b/.solhint.tests.json deleted file mode 100644 index fb26b4ea..00000000 --- a/.solhint.tests.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "extends": "solhint:recommended", - "rules": { - "compiler-version": ["off"], - "constructor-syntax": "warn", - "quotes": ["error", "single"], - "func-visibility": ["warn", { "ignoreConstructors": true }], - "not-rely-on-time": "off", - "style-guide-casing": "off", - "var-name-mixedcase": "off", - "const-name-snakecase": "off", - "no-inline-assembly": "off", - "no-empty-blocks": "error", - "definition-name-capwords": "off", - "named-parameters-function": "off", - "no-global-import": "off", - "max-states-count": "off", - "private-vars-leading-underscore": ["warn", { "strict": false }], - "ordering": "off", - "immutable-name-snakecase": "warn", - "avoid-low-level-calls": "off", - "one-contract-per-file": "off", - "max-line-length": ["warn", 120] - } -} diff --git a/README.md b/README.md index 7f350720..5a4d6546 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/foundry.toml b/foundry.toml index b9d9beb4..fcadc272 100644 --- a/foundry.toml +++ b/foundry.toml @@ -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] @@ -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}" } diff --git a/natspec-smells.config.js b/natspec-smells.config.js index 458623a3..d75ae615 100644 --- a/natspec-smells.config.js +++ b/natspec-smells.config.js @@ -4,5 +4,6 @@ /** @type {import('@defi-wonderland/natspec-smells').Config} */ module.exports = { - include: 'src' + include: 'src/**/*.sol', + exclude: '(test|scripts)/**/*.sol', }; diff --git a/package.json b/package.json index 0ae14e9c..88242ec3 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/script/.solhint.json b/script/.solhint.json new file mode 100644 index 00000000..740c6a42 --- /dev/null +++ b/script/.solhint.json @@ -0,0 +1,7 @@ +{ + "rules": { + "ordering": "off", + "one-contract-per-file": "off", + "no-console": "off" + } +} diff --git a/src/interfaces/.solhint.json b/src/interfaces/.solhint.json new file mode 100644 index 00000000..8bb790c1 --- /dev/null +++ b/src/interfaces/.solhint.json @@ -0,0 +1,11 @@ +{ + "rules": { + "ordering": "warn", + "style-guide-casing": [ + "warn", + { + "ignoreExternalFunctions": true + } + ] + } +} diff --git a/test/.solhint.json b/test/.solhint.json new file mode 100644 index 00000000..3ec7f113 --- /dev/null +++ b/test/.solhint.json @@ -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" + } +} diff --git a/yarn.lock b/yarn.lock index 7cdad647..59ef3222 100644 --- a/yarn.lock +++ b/yarn.lock @@ -181,13 +181,13 @@ "@types/conventional-commits-parser" "^5.0.0" chalk "^5.3.0" -"@defi-wonderland/natspec-smells@1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@defi-wonderland/natspec-smells/-/natspec-smells-1.1.1.tgz#1eed85765ebe4799f8861247308d6365dbf6dbaa" - integrity sha512-vtOKN4j32Rxl8c1txXxs/iDlkPRmrL/UzUYWOzowe1HYH8ioPMRrsKAYVriDBLsvSi2bY06Sl3cN9SQJSbVzsA== +"@defi-wonderland/natspec-smells@1.1.3": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@defi-wonderland/natspec-smells/-/natspec-smells-1.1.3.tgz#6d4c7e289b24264856170fec33e0cae0c844bd32" + integrity sha512-QfZ7uD2bseU/QwQgY8uFrGSD5+a4y1S+GqCNePfmjgRGnEaV7zSFL5FO+zd1GUMtWQNGLgSuRknJMu6DEp3njw== dependencies: fast-glob "3.3.2" - solc-typed-ast "18.1.2" + solc-typed-ast "18.1.6" yargs "17.7.2" "@noble/curves@1.3.0", "@noble/curves@~1.3.0": @@ -375,10 +375,10 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" -axios@^1.6.7: - version "1.7.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.1.tgz#522145622a09dfaf49359837db9649ff245a35b9" - integrity sha512-+LV37nQcd1EpFalkXksWNBiA17NZ5m5/WspmHGmZmdx1qBOg/VNq/c4eRJiA9VQQHBOs+N0ZhhdU10h2TyNK7Q== +axios@^1.6.8: + version "1.7.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621" + integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw== dependencies: follow-redirects "^1.15.6" form-data "^4.0.0" @@ -801,9 +801,9 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" -"forge-std@github:foundry-rs/forge-std#1.8.2": - version "1.8.2" - resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/978ac6fadb62f5f0b723c996f64be52eddba6801" +"forge-std@github:foundry-rs/forge-std#1.9.2": + version "1.9.2" + resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/1714bee72e286e73f76e320d110e0eaf5c4e649d" form-data@^4.0.0: version "4.0.0" @@ -1003,10 +1003,10 @@ human-signals@^5.0.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28" integrity sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ== -husky@>=8: - version "9.0.11" - resolved "https://registry.yarnpkg.com/husky/-/husky-9.0.11.tgz#fc91df4c756050de41b3e478b2158b87c1e79af9" - integrity sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw== +husky@>=9: + version "9.1.6" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.6.tgz#e23aa996b6203ab33534bdc82306b0cf2cb07d6c" + integrity sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A== ignore@^5.2.4: version "5.3.1" @@ -1647,26 +1647,26 @@ slice-ansi@^7.0.0: ansi-styles "^6.2.1" is-fullwidth-code-point "^5.0.0" -solc-typed-ast@18.1.2: - version "18.1.2" - resolved "https://registry.yarnpkg.com/solc-typed-ast/-/solc-typed-ast-18.1.2.tgz#bc958fe3aead765cf6c2e06ce3d53c61fd06e70c" - integrity sha512-57IKzvXHcyjqdjHEdX7NQuWkPALlH8V4eJ6UUehWrzgHDVzKVOCFplwgLDRnOZ8kDMO8+Ms8sQhfrivFK+v5FA== +solc-typed-ast@18.1.6: + version "18.1.6" + resolved "https://registry.yarnpkg.com/solc-typed-ast/-/solc-typed-ast-18.1.6.tgz#997e986583f0fdddb3ddb1960c33d5c63b3f729a" + integrity sha512-nBk24fdju+P2xsy32tG6HLqkXI+Tn+W84Fqm5+XD1Xby2/8YLlsMgI3ADoRPhhO7DeWjq/kflm//dGNkEb3ILA== dependencies: - axios "^1.6.7" + axios "^1.6.8" commander "^12.0.0" decimal.js "^10.4.3" findup-sync "^5.0.0" fs-extra "^11.2.0" jsel "^1.1.6" semver "^7.6.0" - solc "0.8.24" + solc "0.8.25" src-location "^1.1.0" web3-eth-abi "^4.2.0" -solc@0.8.24: - version "0.8.24" - resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.24.tgz#6e5693d28208d00a20ff2bdabc1dec85a5329bbb" - integrity sha512-G5yUqjTUPc8Np74sCFwfsevhBPlUifUOfhYrgyu6CmYlC6feSw0YS6eZW47XDT23k3JYdKx5nJ+Q7whCEmNcoA== +solc@0.8.25: + version "0.8.25" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.25.tgz#393f3101617388fb4ba2a58c5b03ab02678e375c" + integrity sha512-7P0TF8gPeudl1Ko3RGkyY6XVCxe2SdD/qQhtns1vl3yAbK/PDifKDLHGtx1t7mX3LgR7ojV7Fg/Kc6Q9D2T8UQ== dependencies: command-exists "^1.2.8" commander "^8.1.0"