feat: advanced crowdfunding suite, bridge deposits, campaign stats, backer badges & DAO upgrade governance#392
Open
KodeSage wants to merge 8 commits into
Open
feat: advanced crowdfunding suite, bridge deposits, campaign stats, backer badges & DAO upgrade governance#392KodeSage wants to merge 8 commits into
KodeSage wants to merge 8 commits into
Conversation
|
@KodeSage Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR delivers four additive features across the
shadeandcrowdfundcontracts that round out the advanced crowdfunding experience. Each integrates with the existing fundraising/payment modules, appliesrequire_auth()and role-based access control, optimizes storage for Soroban rent, and emits detailed events for off-chain indexing:shade, Add Bridge Listener Interface for External Deposits #364) — record confirmed cross-chain deposits via an admin-managed relayer allowlist, with replay protection.crowdfund, Add Read-Only Views for Deep Campaign Statistics #373) — aggregate campaign metrics, an organizer-only backer leaderboard, and an on-chain stats snapshot event.crowdfund, Implement Gamification Badges and Achievements for Backers #369) — on-chain-verified achievement badges (FirstBacker, EarlyBacker, Whale, GoalGetter).shade, Implement DAO Governance for Protocol Upgrades #357) — a council-based propose → vote → finalize flow that gates WASM upgrades.All four are backwards compatible — no existing signature, storage key, or behavior was changed.
Type of Change
Related Issues
Fixes #364
Fixes #373
Fixes #369
Fixes #357
Changes Made
1. Bridge Listener Interface for External Deposits —
shade(#364)components/bridge.rs: admin-managed bridge-listener allowlist;record_bridge_depositverifies the caller is a registered listener, the token is accepted, and the amount is positive.ProcessedBridgeDeposit), set before state writes so concurrent retries are rejected.DataKeys (BridgeListener,BridgeListenerCount,BridgeDeposit,BridgeDepositCount,ProcessedBridgeDeposit,BridgeCredit) +BridgeDeposittype; idempotent register/remove; detailedBridgeListenerRegistered/RemovedandBridgeDepositRecordedevents.2. Read-Only Views for Deep Campaign Statistics —
crowdfund(#373)get_campaign_stats()— public, no-auth, no-mutation aggregate: goal, raised, total matched, matching-pool balance, contributor count, average/largest pledge, largest backer, percent funded (bps, saturating), deadline, time remaining, ended/goal-reached/executed flags.get_backer_leaderboard(caller, limit)— organizer-only ranked backers (per-backer amounts are sensitive, so it's role-gated).snapshot_campaign_stats(caller)— organizer-only; emits a detailedCampaignStatsSnapshotEventfor indexers/UIs and returns the stats.TotalMatchedDataKey(O(1) update); everything else is derived in the read view (no redundant persisted state).#[contractevent]onPledgeReceivedEventthat prevented the crate from compiling.3. Gamification Badges and Achievements for Backers —
crowdfund(#369)BadgeKindenum:FirstBacker,EarlyBacker,Whale,GoalGetter, each with on-chain eligibility rules verified at award time.award_badge(caller, backer, kind)— callable by the backer (self-claim) or organizer (role check); idempotent double-award guard; emitsBadgeAwardedEvent.set_badge_config(...)— organizer-only Whale threshold + EarlyBacker limit.has_badge,badge_awarded_at,badge_count,get_backer_badges.DataKeys (Badge,BadgeCount,WhaleThreshold,EarlyBackerLimit); badge ownership stored as a single award timestamp per(backer, kind).4. DAO Governance for Protocol Upgrades —
shade(#357)components/governance.rs: admin-managed council;propose_upgrade→vote_on_upgrade(one member, one vote, in-window) →finalize_upgrade(quorum + simple majority ⇒ WASM swap, elseDefeated). Preserves the existing admin emergencyupgradepath.UpgradeProposal/ProposalStatustypes and a consolidatedGovStaterecord (voting params + counters), plusGovMember/GovProposal/GovVoteDataKeys.GovernanceErrorenum (codes 100+) so the existingContractErrorenum is untouched.ShadeTraitmethods exposed; 6 detailed events (GovMemberAdded/Removed,GovConfigSet,UpgradeProposed,UpgradeVoteCast,UpgradeProposalFinalized) + reusedContractUpgraded.Testing
Tests added per feature:
shade/src/tests/test_bridge.rs) — 11 tests: registration/idempotency, deposit recording + credit accumulation, replay rejection, unauthorized/unregistered callers, unaccepted token, non-positive amount, unknown-deposit lookup.crowdfund/src/test.rs) — 8 tests: aggregate metrics, matching-pool reflection, overfunded/ended, leaderboard ordering + organizer-only gating, snapshot returns + emits, pre-init panic.crowdfund/src/test.rs) — 15 tests: each badge's eligibility + rejection paths, config gating, self-claim vs organizer vs third-party, double-award guard, multi-badge accumulation.shade/src/tests/test_governance.rs) — 15 tests: membership idempotency, config validation, full pass-and-execute flow, defeated (no quorum / tie), and every failure code (#100–#107).Checklist
Screenshots (if applicable)
N/A — smart-contract changes with no UI.
Additional Notes
upgradepath remains available alongside the new governance route.shade'sContractErrorandDataKeyenums are at Soroban's hard limit of 50 cases per#[contracterror]/#[contracttype]enum. This was handled by (a) placing governance errors in a separateGovernanceErrorenum (codes 100+), and (b) consolidating governance's scalar storage keys into oneGovStatestruct soDataKeystays at the cap rather than exceeding it. The bridge feature likewise reused existing error codes and returnsOptionfrom getters to avoid adding error variants.036e1f4Add Bridge Listener Interface for External Deposits #364,694f81fAdd Read-Only Views for Deep Campaign Statistics #373,4dc34daImplement Gamification Badges and Achievements for Backers #369,8aa4ccaImplement DAO Governance for Protocol Upgrades #357); they can be split into one PR per issue if the project prefers single-issue PRs.