What
The claim_reward function in learn-token mints tokens by directly writing to balance and supply storage, bypassing the max_supply check that mint() enforces.
Why
If max_supply is set to a value lower than the total rewards that would be minted over time, the claim_reward path will exceed the cap. This undermines the supply cap guarantee — the primary token distribution path doesn't respect it.
Scope
- Add the same
max_supply check from mint() to claim_reward
- Ensure the check uses the same logic and error message
- Add a test verifying the cap is enforced
Technical Context
- File:
contracts/learn-token/src/lib.rs (lines ~418-423 for claim_reward, ~359-363 for mint)
claim_reward writes directly to storage: storage::write_balance and storage::write_supply
mint checks: if current_supply + amount > max_supply { panic!("maximum supply cap exceeded"); }
Acceptance Criteria
What
The
claim_rewardfunction inlearn-tokenmints tokens by directly writing to balance and supply storage, bypassing themax_supplycheck thatmint()enforces.Why
If
max_supplyis set to a value lower than the total rewards that would be minted over time, theclaim_rewardpath will exceed the cap. This undermines the supply cap guarantee — the primary token distribution path doesn't respect it.Scope
max_supplycheck frommint()toclaim_rewardTechnical Context
contracts/learn-token/src/lib.rs(lines ~418-423 forclaim_reward, ~359-363 formint)claim_rewardwrites directly to storage:storage::write_balanceandstorage::write_supplymintchecks:if current_supply + amount > max_supply { panic!("maximum supply cap exceeded"); }Acceptance Criteria
claim_rewardpanics when minting would exceedmax_supplymint()