-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modernize development environment (#442)
## Summary This PR aims to modernize the development environment in the repository by 1. replacing Truffle with [Hardhat](https://github.com/NomicFoundation/hardhat) and [Foundry](https://github.com/foundry-rs/foundry) 2. updating the CI pipelines to be faster and more comprehensive 3. removing unused code
- Loading branch information
Showing
187 changed files
with
7,321 additions
and
8,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright 2024 Circle Internet Financial, LTD. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
############################## | ||
# Private Key Configurations # | ||
##############################= | ||
# The key to a pre-funded deployer address | ||
DEPLOYER_PRIVATE_KEY= | ||
|
||
############################ | ||
# FiatToken Configurations # | ||
############################ | ||
# The ERC20 name of the FiatToken. | ||
TOKEN_NAME=USDC | ||
|
||
# The ERC20 symbol of the FiatToken. | ||
TOKEN_SYMBOL=USDC | ||
|
||
# The fiat currency that that FiatToken represents. | ||
TOKEN_CURRENCY=USD | ||
|
||
# The ERC20 decimals for the FiatToken. | ||
TOKEN_DECIMALS=6 | ||
|
||
# [OPTIONAL] The address to a deployed FiatTokenProxy contract. | ||
# FIAT_TOKEN_PROXY_ADDRESS= | ||
|
||
# [OPTIONAL] The address to a deployed FiatToken implementation contract. | ||
# FIAT_TOKEN_IMPLEMENTATION_ADDRESS= | ||
|
||
# The address of the FiatTokenProxy's admin. | ||
PROXY_ADMIN_ADDRESS= | ||
|
||
# The address of the FiatToken's owner. | ||
OWNER_ADDRESS= | ||
|
||
# The address of the MasterMinter's owner. | ||
MASTER_MINTER_OWNER_ADDRESS= | ||
|
||
# [OPTIONAL] The address of the FiatToken's pauser. Defaults to the owner address. | ||
# PAUSER_ADDRESS= | ||
|
||
# [OPTIONAL] The address of the FiatToken's blacklister. Defaults to the owner address. | ||
# BLACKLISTER_ADDRESS= | ||
|
||
# [OPTIONAL] The address to which locked funds are sent to. Only applicable for version 2 -> 2.1 upgrades. Defaults to the owner address. | ||
# LOST_AND_FOUND_ADDRESS= | ||
|
||
########################## | ||
# Network Configurations # | ||
########################## | ||
# [OPTIONAL] The URL to a mainnet JSON-RPC node. | ||
# MAINNET_RPC_URL= | ||
|
||
# [OPTIONAL] The URL to a testnet JSON-RPC node. | ||
# TESTNET_RPC_URL= | ||
|
||
# The percentage to multiply gas usage estimations by (eg. 200 to double the estimation). Defaults to 130. | ||
GAS_MULTIPLIER=110 | ||
|
||
################################ | ||
# Miscellaneous Configurations # | ||
################################ | ||
# The file name from which to read the list of addresses to blacklist | ||
BLACKLIST_FILE_NAME=blacklist.remote.json | ||
|
||
# [OPTIONAL] The API key to an Etherscan flavor block explorer. | ||
# ETHERSCAN_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
.DS_Store | ||
.idea/ | ||
**/.DS_Store | ||
|
||
artifacts/ | ||
cache/ | ||
@types/generated/ | ||
|
||
node_modules/ | ||
yarn-error.log | ||
|
||
coverage/ | ||
@types/generated/ | ||
coverage.json | ||
|
||
blacklist.*.json | ||
|
||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2024 Circle Internet Financial, LTD. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Setup CI | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.14.0" | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Update submodules | ||
run: git submodule update --init --recursive | ||
shell: bash | ||
|
||
- name: Install Yarn | ||
run: npm install -g [email protected] | ||
shell: bash | ||
|
||
- name: Get Yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Retrieve cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install packages & Setup repository | ||
run: yarn install --frozen-lockfile | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
Copyright 2024 Circle Internet Financial, LTD. All rights reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
## Coverage Report | ||
|
||
Commit: [{{short_commit_sha}}]({{commit_link}}) | ||
|
||
| Type | Coverage | | ||
| ------------------------- | ------------------------------------- | | ||
| Total Statements Coverage | {{total_statements_coverage_percent}} | | ||
| Total Branches Coverage | {{total_branches_coverage_percent}} | | ||
| Total Functions Coverage | {{total_functions_coverage_percent}} | | ||
| Total Lines Coverage | {{total_lines_coverage_percent}} | | ||
|
||
<details> | ||
<summary>Details </summary> | ||
{{files_coverage_table}} | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
name: Continuous Integration | ||
# Copyright 2024 Circle Internet Financial, LTD. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: CI | ||
on: | ||
push: | ||
branches: [master] | ||
|
@@ -11,35 +27,80 @@ jobs: | |
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.14.0" | ||
|
||
- name: Install Yarn | ||
run: npm install -g [email protected] | ||
- name: Setup CI Environment | ||
uses: ./.github/composite-actions/setup-ci | ||
|
||
- name: Install packages | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Setup local environment | ||
run: cp config.js.example config.js && ./start-ganache.sh | ||
- name: Compile contracts | ||
run: yarn compile | ||
|
||
- name: Run static checks | ||
run: yarn static-check | ||
|
||
- name: Run size check | ||
run: yarn contract-size | ||
|
||
- name: Run tests | ||
run: yarn test | ||
- name: Run forge tests | ||
run: forge test -vvv | ||
|
||
- name: Generate gas report | ||
run: yarn gas-report | ||
env: | ||
ENABLE_GAS_REPORTER: true | ||
|
||
run_hardhat_tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test-groups: | ||
- grep: "FiatTokenV1:.*" | ||
- grep: "FiatTokenV1_1:.*" | ||
- grep: "FiatTokenV2:.*" | ||
- grep: "FiatTokenV2_1:.*" | ||
- grep: "FiatTokenV2_2:.*" | ||
- grep: "FiatTokenV1:.*|FiatTokenV1_1:.*|FiatTokenV2:.*|FiatTokenV2_1:.*|FiatTokenV2_2:.*|gas costs" | ||
invert: true | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup CI Environment | ||
uses: ./.github/composite-actions/setup-ci | ||
|
||
- name: Run hardhat tests | ||
run: HARDHAT_TEST_GREP='${{ matrix.test-groups.grep }}' HARDHAT_TEST_INVERT='${{ matrix.test-groups.invert }}' yarn test | ||
|
||
- name: Upload test results to artifacts | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: junit-report-${{ hashFiles('report/junit.xml') }} | ||
path: report/junit.xml | ||
|
||
post_run_hardhat_tests: | ||
runs-on: ubuntu-latest | ||
needs: [run_hardhat_tests] | ||
if: always() | ||
steps: | ||
- name: Download test results | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: junit-report-* | ||
|
||
- name: Publish combined test report | ||
uses: mikepenz/action-junit-report@v4 | ||
with: | ||
check_name: upload_test_results | ||
job_summary: true | ||
detailed_summary: true | ||
report_paths: "./junit-report-*/junit.xml" | ||
|
||
scan: | ||
needs: run_ci_tests | ||
if: github.event_name == 'pull_request' | ||
uses: circlefin/circle-public-github-workflows/.github/workflows/pr-scan.yaml@v1 | ||
uses: circlefin/circle-public-github-workflows/.github/workflows/[email protected] | ||
with: | ||
allow-reciprocal-licenses: false | ||
|
||
release-sbom: | ||
needs: run_ci_tests | ||
if: github.event_name == 'push' | ||
uses: circlefin/circle-public-github-workflows/.github/workflows/attach-release-assets.yaml@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2024 Circle Internet Financial, LTD. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Coverage | ||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run_coverage: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.label.name == 'needs_coverage' }} | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup CI Environment | ||
uses: ./.github/composite-actions/setup-ci | ||
|
||
- name: Compile contracts | ||
run: yarn compile | ||
|
||
- name: Run coverage | ||
run: yarn coverage | ||
|
||
- name: Report coverage to PR | ||
id: report-coverage | ||
uses: sidx1024/[email protected] | ||
with: | ||
coverage_file: "coverage/coverage-summary.json" | ||
base_coverage_file: "" | ||
comment_template_file: ".github/resources/coverage-report-template.md" | ||
|
||
- name: Check coverage | ||
if: | | ||
fromJSON(steps.report-coverage.outputs.total_lines_coverage_percent_raw) < 100 || | ||
fromJSON(steps.report-coverage.outputs.total_branches_coverage_percent_raw) < 98 || | ||
fromJSON(steps.report-coverage.outputs.total_statements_coverage_percent_raw) < 100 || | ||
fromJSON(steps.report-coverage.outputs.total_functions_coverage_percent_raw) < 100 | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
core.setFailed('Test coverage is under the threshold') |
Oops, something went wrong.