Skip to content

Commit 64ad7df

Browse files
authored
Improve initialization script with liquidity and whitelists (#68)
2 parents 881108e + 2ed0aa1 commit 64ad7df

16 files changed

+504
-150
lines changed

.github/workflows/slither.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Slither Analysis
1+
name: Smart Contract Security Analysis
22
on:
33
push:
44
branches:
@@ -10,6 +10,7 @@ on:
1010

1111
jobs:
1212
analyze:
13+
name: Smart Contract Static Analysis
1314
runs-on: ubuntu-latest
1415
permissions:
1516
contents: read

.github/workflows/test.yml

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
name: test
1+
name: Smart Contract Tests
22

33
on:
44
push:
55
branches:
6-
- '*'
6+
- '*'
77
pull_request:
88
branches:
99
- develop
1010
- main
11+
1112
env:
1213
FOUNDRY_PROFILE: ci
14+
ARBITRUM_SEPOLIA_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}
1315
ETH_SEPOLIA_RPC_URL: ${{ secrets.ETH_SEPOLIA_RPC_URL }}
1416
SCROLL_SEPOLIA_RPC_URL: ${{ secrets.SCROLL_SEPOLIA_RPC_URL }}
1517
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
@@ -23,38 +25,43 @@ jobs:
2325
strategy:
2426
fail-fast: true
2527

26-
name: Foundry project
28+
name: Smart Contract Tests
2729
runs-on: ubuntu-latest
2830
steps:
29-
- uses: actions/checkout@v4
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
3033
with:
3134
submodules: recursive
3235

33-
- name: Set up cache for Foundry
36+
- name: Set up cache for Foundry
3437
uses: actions/cache@v3
3538
with:
3639
path: |
3740
.forge-cache
3841
lib
3942
key: ${{ runner.os }}-forge-cache-${{ hashFiles('**/*.sol') }}
40-
restore-keys: |
4143

4244
- name: Initialize and update submodules
43-
run: |
44-
git submodule update --init --recursive
45+
run: git submodule update --init --recursive
4546

4647
- name: Install Foundry
4748
uses: foundry-rs/foundry-toolchain@v1
4849
with:
4950
version: nightly
5051

52+
- name: Export all required environment variables to .env
53+
run: env | grep -E '^(FOUNDRY_PROFILE|ARBITRUM_SEPOLIA_RPC_URL|ETH_SEPOLIA_RPC_URL|SCROLL_SEPOLIA_RPC_URL|PRIVATE_KEY|BACKEND_EOA|BACKEND_PK|NFT_BASE_URI|FOUNDRY_DISABLE_NIGHTLY_WARNING)=' > .env
54+
5155
- name: Run Forge build
5256
run: |
5357
forge --version
54-
forge build --sizes
58+
forge build --sizes 2>&1 | tee forge_build.log || (grep -q "error:" forge_build.log && exit 1 || exit 0)
5559
id: build
5660

61+
# run tests
62+
# Suppress deprecation warnings for testFail* while keeping all other output.
63+
# Ensures that tests run without unnecessary noise in CI logs.
5764
- name: Run Forge tests
5865
run: |
59-
yarn test:local
66+
(yarn test:local 2>&1 | tee forge_test.log | grep -v "testFail* has been removed") || true
6067
id: test

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiler files
22
cache/
33
out/
4+
*.log
45

56
# Ignores development broadcast logs
67
/broadcast
@@ -24,4 +25,7 @@ package-lock.json
2425
abi
2526

2627
# cache
27-
.forge-cache
28+
.forge-cache
29+
30+
# Coverage temp files
31+
lcov.info

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ yarn run test:local
8282
yarn run test:prod
8383

8484
# Run coverage tests
85-
yarn run test:coverage
85+
yarn run test:coverage:local
8686

8787
# Run gas report
8888
yarn run test:gas
@@ -95,14 +95,12 @@ forge fmt
9595

9696
_Deploy_
9797
```bash
98-
# Deploy Simulation
99-
yarn run deploy:simulate
10098

10199
# Real Deploy
102-
yarn run deploy:prod
100+
yarn run deploy:arbitrum-sepolia
103101

104102
# Real Deploy + Verify contracts
105-
yarn run deploy:verify
103+
yarn run deploy:arbitrum-sepolia:verify
106104

107105
# Deploy only ChatterPay contract
108106
yarn run deploy:chatterpay

example_env

+8
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ ETHERSCAN_API_KEY=Your etherscan api key, if you want to verify contracts
88
ROUTER_ADDRESS=Uniswap SwapRouter02 address
99
ARBISCAN_API_KEY=Your Aribtrum api key, if you want to verify contracts
1010
NFT_BASE_URI=https://dev.back.chatterpay.net/nft/metadata/opensea/
11+
12+
# Uniswap V3 Addresses
13+
UNISWAP_FACTORY=0x1F98431c8aD98523631AE4a59f267346ea31F984
14+
POSITION_MANAGER=0xC36442b4a4522E871399CD717aBDD847Ab11FE88
15+
16+
# Tokens and their respective Price Feeds (ensure the order matches between tokens[i] and price_feeds[i])
17+
TOKENS=0xe6B817E31421929403040c3e42A6a5C5D2958b4A,0xE9C723D01393a437bac13CE8f925A5bc8E1c335c
18+
PRICE_FEEDS=0x80EDee6f667eCc9f63a0a6f55578F870651f06A4,0xd30e2101a97dcbAeBCBC04F14C3f624E67A35165

foundry.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ libs = ["lib"]
55
remappings = [
66
'@openzeppelin/contracts=lib/openzeppelin-contracts/contracts',
77
'@openzeppelin/contracts-upgradeable=lib/openzeppelin-contracts-upgradeable/contracts',
8+
'forge-std/=lib/forge-std/src/'
89
]
910

1011
# Local development profile - optimized for faster builds

lib/openzeppelin-contracts

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
{
22
"name": "chatterpay-contracts",
3+
"license": "MIT",
34
"type": "module",
45
"scripts": {
56
"build:local": "FOUNDRY_PROFILE=local forge build",
67
"build:prod": "FOUNDRY_PROFILE=production forge build",
78
"test:local": "FOUNDRY_PROFILE=local bash test/run_all_tests.sh",
89
"test:prod": "FOUNDRY_PROFILE=production bash test/run_all_tests.sh",
9-
"test:coverage": "forge coverage --profile local --fork-url $ARBITRUM_SEPOLIA_RPC_URL --match-path 'test/modules/*'",
1010
"test:gas": "REPORT_GAS=true FOUNDRY_PROFILE=production bash test/run_all_tests.sh",
11+
"test:coverage:local": "FOUNDRY_PROFILE=local bash test/run_tests_coverage.sh",
1112
"clean": "forge clean",
1213
"clean:full": "forge clean && rm -rf cache .forge-cache",
13-
"deploy:simulate": "bash script/deploy.sh simulate",
14-
"deploy:prod": "bash script/deploy.sh prod",
15-
"deploy:chatterpay": "bash script/deploy.sh chatterpay",
14+
"deploy:arbitrum-sepolia": "make deploy_arbitrum_sepolia_all",
15+
"deploy:arbitrum-sepolia:verify": "make deploy_verify_arbitrum_sepolia_all",
16+
"deploy:chatterpay": "make deploy_arbitrum_sepolia_only_chatterpay",
17+
"deploy:chatterpay:verify": "make deploy_verify_arbitrum_sepolia_only_chatterpay",
1618
"generate-types": "typechain --target=ethers-v5 './src/artifacts/**/*.json'",
1719
"generate:abis": "bash script/generate_abis.sh"
1820
},

0 commit comments

Comments
 (0)