You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DonorRecord::apply_donation is a public method on DonorRecord (campaign/src/types.rs line 451) that maintains the donor's running totals (total_donated, donation_count, last donation metadata). It is defined, public, exported, and has a multi-line doc comment — but the canonical CampaignContract::donate entry point (campaign/src/lib.rs lines 134–249) never calls it. Instead, donate() mutates the donor record inline with explicit field writes that mirror the body of apply_donation almost exactly. Two divergent paths for the same operation will silently desynchronise: a future bug fix to one is unlikely to be ported to the other.
Future contributors copying the inline pattern will copy a stale version; future contributors extending apply_donation will be surprised that it isn't called.
Option A — delete the dead helpers. Remove DonorRecord::apply_donation and DonorRecord::new_for from types.rs and centralise the mutation in donate(). Pro: smallest diff. Con: removes the only "named" abstraction.
Option B — wire them in. Replace the inline block in donate() with:
Overview
DonorRecord::apply_donationis a public method onDonorRecord(campaign/src/types.rs line 451) that maintains the donor's running totals (total_donated, donation_count, last donation metadata). It is defined, public, exported, and has a multi-line doc comment — but the canonicalCampaignContract::donateentry point (campaign/src/lib.rs lines 134–249) never calls it. Instead,donate()mutates the donor record inline with explicit field writes that mirror the body ofapply_donationalmost exactly. Two divergent paths for the same operation will silently desynchronise: a future bug fix to one is unlikely to be ported to the other.Evidence
vs. the never-called helper:
new_foris also defined but unused; onlyapply_donationis invoked (zero times, percargo expand-equivalent grep).Impact
donate()(e.g. fixing [MEDIUM] README documents CLI commands that are not implemented (tx-history, batch, debug, contract query, account create, prepare/complete-wallet-signing, contract-id) #37's saturating issue, cappingdonation_count) does not propagate toapply_donation.apply_donationwill be surprised that it isn't called.Recommended Approach
Pick one:
Option A — delete the dead helpers. Remove
DonorRecord::apply_donationandDonorRecord::new_forfrom types.rs and centralise the mutation indonate(). Pro: smallest diff. Con: removes the only "named" abstraction.Option B — wire them in. Replace the inline block in
donate()with:…and at the same time resolve #37 so
apply_donationuses checked arithmetic.Option B is recommended because it gives the inline block a name and forces any future invariant change to live in one place.
Acceptance Criteria
DonorRecord::apply_donationis either wired intodonate()(Option B) or removed (Option A)DonorRecordpost-unwrap_or/new_forcampaign/,crates/contracts/,crates/tools/ortoken-bridge/Affected Files
campaign/src/lib.rscampaign/src/types.rs