feat(contract): add anonymous donation flow (#461) - #678
Conversation
- donate_anonymous(): no-account one-time payment - Auto-assigns to available planter by region with workload tracking - Mints tree with null sponsor (anonymous) - Preserves all existing escrow deposit/release/refund behavior - Adds planter capacity/workload management - Anonymous trees excluded from sponsor dashboard Closes Farm-credit#461 Relates to ROADMAP-122
|
@Peolite001 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! 🚀 |
|
fix your conflicts and dont forget to offramp with fundable on: https://stellar.fundable.finance/offramp |
4 similar comments
|
fix your conflicts and dont forget to offramp with fundable on: https://stellar.fundable.finance/offramp |
|
fix your conflicts and dont forget to offramp with fundable on: https://stellar.fundable.finance/offramp |
|
fix your conflicts and dont forget to offramp with fundable on: https://stellar.fundable.finance/offramp |
|
fix your conflicts and dont forget to offramp with fundable on: https://stellar.fundable.finance/offramp |
Closes #461
Relates to ROADMAP-122
Summary
Adds an anonymous donation flow allowing sponsors to pay for tree planting without creating an account. Funds are held in escrow, trees are auto-assigned to available planters by region, and tree IDs are minted with a null sponsor address. Anonymous donations are excluded from sponsor dashboard tracking.
Related Issue
Closes #461
What Was Implemented
donate_anonymous(amount, token, species, region)— no-account one-time payment function in escrow contractget_avail(region)inc_work/dec_work) with capacity limitsmint_anon(species, region, planter)in tree registrysponsor: None)get_sponsor_trees()dashboard queriesAnonDepandanon_mintedeventsinitialize_registries()to link escrow → tree_registry + planter_registryImplementation Details
Escrow contract (
contracts/escrow/src/lib.rs):EscrowRecordwithsponsor: Option<Address>,species,region,is_anonymousfieldsdonate_anonymous()that bypasses sponsor auth, validates species cost, transfers tokens, mints tree, creates escrow withsponsor: Nonerelease()checksis_anonymousflag to calldec_work()on planter registryrefund()rejects anonymous donations by requiringsponsor: Some(...)planter_registry.get_avail(),inc_work(),dec_work()andtree_registry.mint_anon()Planter registry (
contracts/planter_registry/src/lib.rs):PlanterRecordwithcapacity,workload,active,total_trees_plantedset_escrow()for escrow-only auth on workload changesget_avail(region)filters byactive && workload < capacityinc_work()/dec_work()are escrow-authenticated with capacity and zero-check guardsset_active()andset_capacity()for admin managementTree registry (
contracts/tree_registry/src/lib.rs):mint_anon()that creates trees withsponsor: NoneTotalAnonymousTreesseparately from total treesNo breaking changes: All existing
deposit(),release(),refund(),register_planter(),increment_score(),slash_score()flows remain unchanged.Screenshots / Recordings
N/A — smart contract changes only, no UI modifications.
How to Test
Build contracts:
cd contracts cargo build --target wasm32-unknown-unknown --releaseRun tests:
cargo testExpected: 28 tests pass (10 existing escrow + 10 existing planter + 8 new anonymous flow tests)
Test anonymous donation flow manually:
Verify:
sponsor: null,is_anonymous: truetotal_anonymous_trees: 1get_sponsor_trees(sponsor_addr)does NOT include the anonymous treeChecklist
feat:,fix:, etc.)cargo build --target wasm32-unknown-unknown --release)cargo fmt && cargo clippy --all-targets --all-features)