Skip to content

fix(circle): claim_streak_bonus and claim_referral_bonus now transfer… - #178

Open
prettyjune04-ops wants to merge 1 commit into
cocor-tech:masterfrom
prettyjune04-ops:fix/circle-bonus-token-transfers
Open

fix(circle): claim_streak_bonus and claim_referral_bonus now transfer…#178
prettyjune04-ops wants to merge 1 commit into
cocor-tech:masterfrom
prettyjune04-ops:fix/circle-bonus-token-transfers

Conversation

@prettyjune04-ops

Copy link
Copy Markdown

… tokens

Both functions computed bonus amounts and emitted events but never performed any on-chain token transfer (issue #103).

Changes:

  • Add CircleError::TokenNotSet = 38 to types.rs
  • Add use soroban_sdk::token; import to contract.rs
  • claim_referral_bonus: after computing bonus_total, load DataKey::Token and call token::Client::transfer(contract → referrer, bonus_total)
  • claim_streak_bonus: after computing bonus_div, load DataKey::Token and call token::Client::transfer(contract → member, bonus_div)
  • Both functions return TokenNotSet if set_token has not been called

Tests:

  • test_claim_referral_bonus_transfers_tokens: verifies referrer balance increases by the exact calculated bonus amount
  • test_claim_referral_bonus_no_double_claim: second claim errors
  • test_claim_referral_bonus_no_token_set_returns_error: TokenNotSet path
  • test_claim_referral_bonus_not_active_circle: rejects non-Active circle
  • test_claim_streak_bonus_transfers_tokens: verifies member balance increases by the exact calculated streak bonus
  • test_claim_streak_bonus_below_threshold_fails: streak < 3 errors
  • test_claim_streak_bonus_no_token_set_returns_error: TokenNotSet path
  • test_claim_streak_bonus_not_active_circle: rejects non-Active circle

Also fixed pre-existing issues blocking compilation:

  • common/vrf.rs: soroban_sdk::Set does not exist in SDK v26; replaced with Vec for the used-positions tracking
  • test.rs: add BytesN + Ledger testutils imports, use BytesN::from_array, switch to register_stellar_asset_contract_v2 + StellarAssetClient::mint

closes #103

… tokens

Both functions computed bonus amounts and emitted events but never
performed any on-chain token transfer (issue cocor-tech#103).

Changes:
- Add CircleError::TokenNotSet = 38 to types.rs
- Add `use soroban_sdk::token;` import to contract.rs
- claim_referral_bonus: after computing bonus_total, load DataKey::Token
  and call token::Client::transfer(contract → referrer, bonus_total)
- claim_streak_bonus: after computing bonus_div, load DataKey::Token
  and call token::Client::transfer(contract → member, bonus_div)
- Both functions return TokenNotSet if set_token has not been called

Tests:
- test_claim_referral_bonus_transfers_tokens: verifies referrer balance
  increases by the exact calculated bonus amount
- test_claim_referral_bonus_no_double_claim: second claim errors
- test_claim_referral_bonus_no_token_set_returns_error: TokenNotSet path
- test_claim_referral_bonus_not_active_circle: rejects non-Active circle
- test_claim_streak_bonus_transfers_tokens: verifies member balance
  increases by the exact calculated streak bonus
- test_claim_streak_bonus_below_threshold_fails: streak < 3 errors
- test_claim_streak_bonus_no_token_set_returns_error: TokenNotSet path
- test_claim_streak_bonus_not_active_circle: rejects non-Active circle

Also fixed pre-existing issues blocking compilation:
- common/vrf.rs: soroban_sdk::Set does not exist in SDK v26; replaced
  with Vec<u32> for the used-positions tracking
- test.rs: add BytesN + Ledger testutils imports, use BytesN::from_array,
  switch to register_stellar_asset_contract_v2 + StellarAssetClient::mint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(circle): claim_streak_bonus and claim_referral_bonus emit events but never transfer tokens

1 participant