Skip to content

Commit

Permalink
chore(contracts): update configs for networks and deployments; minor …
Browse files Browse the repository at this point in the history
…CI improvements
  • Loading branch information
0xjei committed Sep 25, 2024
1 parent 79b6c40 commit 45a509f
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 43 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/pull-requests.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: pull-requests
name: main

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
style:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
run: yarn
Expand All @@ -31,6 +39,9 @@ jobs:
- packages/contracts/**/*.{js,json,ts,sol}
docs:
- apps/docs/**/*
packages:
- packages/**/*.{js,json,ts}
- '!packages/{contracts}/**/*'
to_format:
- '**/*.{cjs,js,json,jsx,md,mdx,sol,ts,tsx,yaml,yml}'
to_lint:
Expand All @@ -48,7 +59,7 @@ jobs:
yarn workspace excubiae-docs build
yarn workspace excubiae-docs format
- if: steps.changed-files.outputs.libraries_any_changed == 'true'
- if: steps.changed-files.outputs.packages_any_changed == 'true'
name: Build packages
run: yarn build:packages

Expand All @@ -64,16 +75,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
run: yarn
Expand All @@ -85,9 +97,6 @@ jobs:
files_yaml: |
contracts:
- packages/contracts/**/*.{js,json,ts,sol}
libraries:
- packages/**/*.{js,json,ts}
- '!packages/{circuits,contracts}/**/*'
- if: steps.changed-files.outputs.contracts_any_changed == 'true'
name: Build and Test contracts
Expand Down
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"semi": false,
"arrowParens": "always",
"trailingComma": "none",
"plugins": ["prettier-plugin-solidity"]
"plugins": ["prettier-plugin-solidity"],
"printWidth": 120,
"tabWidth": 4
}
10 changes: 10 additions & 0 deletions packages/contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# core
DEFAULT_NETWORK=hardhat

# report & verify
REPORT_GAS=false
COINMARKETCAP_API_KEY=
ETHERSCAN_API_KEY=

# account
BACKEND_PRIVATE_KEY=
4 changes: 2 additions & 2 deletions packages/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ node_modules
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
# Hardhat Ignition
ignition/deployments/chain-*
36 changes: 31 additions & 5 deletions packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
[profile.default]
src = 'contracts/src'
out = 'out'
libs = ['node_modules']
test = 'contracts/test'
cache_path = 'cache_forge'
# core
libs = ['node_modules']
cache_path = 'cache_forge'
test = 'contracts/test'
src = 'contracts/src'
out = 'out'
script = "contracts/scripts"

# sol
auto_detect_solc = false
fuzz = { runs = 1_000 }
gas_reports = ["*"]
optimizer = true
optimizer_runs = 200_000
solc = "0.8.27"

[rpc_endpoints]
sepolia = "https://rpc2.sepolia.org"

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
44 changes: 43 additions & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,56 @@
import { HardhatUserConfig } from "hardhat/config"
import { resolve } from "path"
import { config as dotenvConfig } from "dotenv"
import "@nomicfoundation/hardhat-toolbox"
import "@nomicfoundation/hardhat-foundry"
import "@nomicfoundation/hardhat-verify"
import "hardhat-gas-reporter"

dotenvConfig({ path: resolve(__dirname, ".env") })

const backendPrivateKey = process.env.BACKEND_PRIVATE_KEY

const config: HardhatUserConfig = {
solidity: "0.8.27",
solidity: {
version: "0.8.27",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts/src",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
networks: {
hardhat: {
chainId: 1337,
allowUnlimitedContractSize: true
},
sepolia: {
chainId: 11155111,
url: "https://rpc2.sepolia.org",
accounts: !backendPrivateKey ? [] : [backendPrivateKey]
}
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
target: "ethers-v6"
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: []
},
sourcify: {
enabled: true
}
}

Expand Down
19 changes: 11 additions & 8 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"compile": "yarn compile:hardhat && yarn compile:forge",
"compile:hardhat": "hardhat compile",
"compile:forge": "forge compile",
"deploy": "hardhat deploy",
"deploy:lock": "hardhat ignition deploy ignition/modules/Lock.ts",
"deploy:lock-sepolia": "hardhat ignition deploy ignition/modules/Lock.ts --network sepolia",
"verify:lock-sepolia": "hardhat ignition verify sepolia-deployment",
"test": "yarn test:hardhat && yarn test:forge",
"test:hardhat": "hardhat test",
"test:forge": "forge test",
"test:forge": "forge test -vvv",
"test:report-gas": "REPORT_GAS=true yarn test && forge test --gas-report",
"test:coverage": "hardhat coverage && forge coverage",
"typechain": "hardhat typechain",
Expand All @@ -22,27 +24,28 @@
"lint:fix": "solhint 'contracts/**/*.sol' --fix --noPrompt"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-foundry": "^1.1.2",
"@nomicfoundation/hardhat-ignition": "^0.15.5",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.11",
"@nomicfoundation/ignition-core": "^0.15.5",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": "^22.6.1",
"chai": "^4.2.0",
"dotenv": "^16.4.5",
"ethers": "^6.4.0",
"forge-std": "github:foundry-rs/forge-std#v1.9.2",
"hardhat": "^2.22.11",
"hardhat-gas-reporter": "^1.0.8",
"solhint": "^5.0.3",
"solidity-coverage": "^0.8.1",
"solidity-coverage": "^0.8.13",
"ts-node": "^10.9.2",
"typechain": "^8.3.0",
"typescript": "5.3"
Expand Down
34 changes: 21 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,7 @@ __metadata:
languageName: node
linkType: hard

"@nomicfoundation/hardhat-chai-matchers@npm:^2.0.0":
"@nomicfoundation/hardhat-chai-matchers@npm:^2.0.8":
version: 2.0.8
resolution: "@nomicfoundation/hardhat-chai-matchers@npm:2.0.8"
dependencies:
Expand All @@ -3531,7 +3531,7 @@ __metadata:
languageName: node
linkType: hard

"@nomicfoundation/hardhat-ethers@npm:^3.0.0":
"@nomicfoundation/hardhat-ethers@npm:^3.0.8":
version: 3.0.8
resolution: "@nomicfoundation/hardhat-ethers@npm:3.0.8"
dependencies:
Expand All @@ -3555,7 +3555,7 @@ __metadata:
languageName: node
linkType: hard

"@nomicfoundation/hardhat-ignition-ethers@npm:^0.15.0":
"@nomicfoundation/hardhat-ignition-ethers@npm:^0.15.5":
version: 0.15.5
resolution: "@nomicfoundation/hardhat-ignition-ethers@npm:0.15.5"
peerDependencies:
Expand Down Expand Up @@ -3585,7 +3585,7 @@ __metadata:
languageName: node
linkType: hard

"@nomicfoundation/hardhat-network-helpers@npm:^1.0.0":
"@nomicfoundation/hardhat-network-helpers@npm:^1.0.12":
version: 1.0.12
resolution: "@nomicfoundation/hardhat-network-helpers@npm:1.0.12"
dependencies:
Expand Down Expand Up @@ -3622,7 +3622,7 @@ __metadata:
languageName: node
linkType: hard

"@nomicfoundation/hardhat-verify@npm:^2.0.0":
"@nomicfoundation/hardhat-verify@npm:^2.0.11":
version: 2.0.11
resolution: "@nomicfoundation/hardhat-verify@npm:2.0.11"
dependencies:
Expand Down Expand Up @@ -4508,7 +4508,14 @@ __metadata:
languageName: node
linkType: hard

"@types/chai@npm:*, @types/chai@npm:^4.2.0":
"@types/chai@npm:*":
version: 5.0.0
resolution: "@types/chai@npm:5.0.0"
checksum: 10/a6c03aa6b6d59ad40ddb48d07807690efb874628c15b9d89c17d97045a9305a487933398c1e5b5f94087b1a6a9a67a7c828eb9b635104526fd25bb5f9d4c4175
languageName: node
linkType: hard

"@types/chai@npm:^4.2.0":
version: 4.3.19
resolution: "@types/chai@npm:4.3.19"
checksum: 10/5ca7a48ec1c792e536bc228911f442c31eb8a24f1c3531f8a5e1e949590a6a045be17a2ec5a3d83f63dae8d59dd93dc5f6ca7355b9c1a9f003c553a733b2e591
Expand Down Expand Up @@ -9366,14 +9373,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "excubiae-contracts@workspace:packages/contracts"
dependencies:
"@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.0"
"@nomicfoundation/hardhat-ethers": "npm:^3.0.0"
"@nomicfoundation/hardhat-chai-matchers": "npm:^2.0.8"
"@nomicfoundation/hardhat-ethers": "npm:^3.0.8"
"@nomicfoundation/hardhat-foundry": "npm:^1.1.2"
"@nomicfoundation/hardhat-ignition": "npm:^0.15.5"
"@nomicfoundation/hardhat-ignition-ethers": "npm:^0.15.0"
"@nomicfoundation/hardhat-network-helpers": "npm:^1.0.0"
"@nomicfoundation/hardhat-ignition-ethers": "npm:^0.15.5"
"@nomicfoundation/hardhat-network-helpers": "npm:^1.0.12"
"@nomicfoundation/hardhat-toolbox": "npm:^5.0.0"
"@nomicfoundation/hardhat-verify": "npm:^2.0.0"
"@nomicfoundation/hardhat-verify": "npm:^2.0.11"
"@nomicfoundation/ignition-core": "npm:^0.15.5"
"@openzeppelin/contracts": "npm:^5.0.2"
"@typechain/ethers-v6": "npm:^0.5.0"
Expand All @@ -9382,12 +9389,13 @@ __metadata:
"@types/mocha": "npm:>=9.1.0"
"@types/node": "npm:^22.6.1"
chai: "npm:^4.2.0"
dotenv: "npm:^16.4.5"
ethers: "npm:^6.4.0"
forge-std: "github:foundry-rs/forge-std#v1.9.2"
hardhat: "npm:^2.22.11"
hardhat-gas-reporter: "npm:^1.0.8"
solhint: "npm:^5.0.3"
solidity-coverage: "npm:^0.8.1"
solidity-coverage: "npm:^0.8.13"
ts-node: "npm:^10.9.2"
typechain: "npm:^8.3.0"
typescript: "npm:5.3"
Expand Down Expand Up @@ -17765,7 +17773,7 @@ __metadata:
languageName: node
linkType: hard

"solidity-coverage@npm:^0.8.1":
"solidity-coverage@npm:^0.8.13":
version: 0.8.13
resolution: "solidity-coverage@npm:0.8.13"
dependencies:
Expand Down

0 comments on commit 45a509f

Please sign in to comment.