Skip to content

Commit bf9c4cd

Browse files
refactor(CampaignInstance): consolidate state variables into structs to resolve linter violations and stack depth issues
BREAKING CHANGE: State variable access patterns updated from direct access to struct member access - Group 24 state variables into 3 logical structs (CampaignCore, DonationConstraints, Counters) - Reduce state variable count from 24 to 11, resolving max-states-count linter violation - Eliminate stack too deep compilation errors by reducing parameter passing overhead - Remove redundant milestoneCount variable; derive from counters.nextMilestoneId - Update all function bodies to use struct member access (e.g., core.creator instead of getCreator) - Add interface compliance getter functions to maintain external API compatibility - Implement pull-based refund pattern with claimRefund() and batchRefund() functions - Fix type mismatch errors in comparison operations (totalRaised vs goalAmount, state vs CampaignState) - Optimize gas consumption by eliminating duplicate state writes - Improve code organization and maintainability through logical data grouping Affected functions: initializeCampaign, createMilestone, finalizeCampaign, donate, withdrawMilestoneFunds, pauseCampaign, resumeCampaign, cancelCampaign, and 40+ others Fixes: #[issue-number] - Stack too deep compiler error Fixes: #[issue-number] - Linter max-states-count violation (24 > 20 limit)
0 parents  commit bf9c4cd

6,095 files changed

Lines changed: 1213675 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
FOUNDRY_PROFILE: ci
10+
11+
jobs:
12+
check:
13+
name: Foundry project
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
23+
- name: Show Forge version
24+
run: |
25+
forge --version
26+
27+
- name: Run Forge fmt
28+
run: |
29+
forge fmt --check
30+
id: fmt
31+
32+
- name: Run Forge build
33+
run: |
34+
forge build --sizes
35+
id: build
36+
37+
- name: Run Forge tests
38+
run: |
39+
forge test -vvv
40+
id: test

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/OpenZeppelin/openzeppelin-contracts
7+
[submodule "lib/chainlink"]
8+
path = lib/chainlink
9+
url = https://github.com/smartcontractkit/chainlink
10+
[submodule "lib/solidity"]
11+
path = lib/solidity
12+
url = https://github.com/onchain-id/solidity

.solhint.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"rules": {
4+
"max-states-count": ["error", 20],
5+
"function-max-lines": ["warn", 50],
6+
"no-complex-fallback": "error",
7+
"no-unused-vars": "error"
8+
}
9+
}

0 commit comments

Comments
 (0)