Skip to content

feat(loyalty): implement loyalty and rewards program for subscribers (#387)#464

Open
activatedkc wants to merge 5 commits into
Smartdevs17:mainfrom
activatedkc:feat/loyalty-rewards-program-387
Open

feat(loyalty): implement loyalty and rewards program for subscribers (#387)#464
activatedkc wants to merge 5 commits into
Smartdevs17:mainfrom
activatedkc:feat/loyalty-rewards-program-387

Conversation

@activatedkc
Copy link
Copy Markdown
Contributor

Summary

Implements issue #387 — a full loyalty and rewards program with on-chain points, tiered benefits, streaks, referral bonuses, and gamification badges.

Changes

Commit 1: Types (contracts/types/src/lib.rs)

  • New types: LoyaltyConfig, LoyaltyTierConfig, PointTransaction, PointTxType, RewardsRedemption
  • 12 new StorageKey variants: LoyaltyConfig, LoyaltyPoints, LifetimePoints, TotalSpent, MemberSince, Streak, LastChargeAt, PointsExpiration, PointTxCount, PointTx, RedemptionCount, Redemption

Commit 2: Smart Contract (contracts/subscription/src/loyalty.rs + lib.rs)

  • New loyalty.rs module: points accumulation, streak tracking, tier calculation, referral bonuses, points redemption, expiry
  • accumulate_points integrated into charge_subscription (called after successful payment)
  • 11 public contract functions: initialize_loyalty, update_loyalty_config, get_loyalty_config, get_points, get_lifetime_points, get_streak, get_loyalty_status, redeem_loyalty_points, earn_referral_bonus, expire_points, get_point_transactions, get_redemption
  • Points capped at 10M per subscriber (anti-inflation)
  • Minimum charge threshold (100,000) before point earning
  • Streak bonus awarded every 10 consecutive charges
  • Redemption: 100 pts = 1% discount, capped at 50%

Commit 3: Frontend (types, store, screen, gamification)

  • New types: PointTxType, LoyaltyConfig, StreakInfo, ReferralInfo
  • loyaltyStore.ts: contract integration stubs, streak tracking, referral bonuses, gamification triggers
  • LoyaltyDashboardScreen.tsx: added streak card (fire icon, progress bar), referral share button, badges modal, tier comparison table
  • gamificationService.ts: 8 new loyalty achievements and badges (point milestones, streak milestones, referral milestones)
  • Gamification triggers wired into accumulatePoints and earnReferralBonus flows

Edge Cases Handled

  • Points capped to prevent inflation (10M max)
  • Minimum charge threshold for point earning
  • Streak resets on missed payments (gap > threshold)
  • Redemption limited to eligible (non-expired) balance
  • Points never negative after deductions
  • Admin-only loyalty config updates
  • Auto-expiry checked on every balance read

Closes #387

@Smartdevs17
Copy link
Copy Markdown
Owner

@Cyberking99 merge conflicts

- New types: LoyaltyConfig, LoyaltyTierConfig, PointTransaction,
  PointTxType, RewardsRedemption
- 11 new StorageKey variants for on-chain loyalty state:
  LoyaltyConfig, LoyaltyPoints, LifetimePoints, TotalSpent,
  MemberSince, Streak, LastChargeAt, PointsExpiration,
  PointTxCount, PointTx, RedemptionCount, Redemption
…ption

- New loyalty.rs module: accumulate_points, redeem_points, streak
  tracking, tier calculation, referral bonuses, points expiry
- Integrated accumulate_points into charge_subscription flow
- 11 public contract functions for loyalty management
- Points capped at 10M to prevent inflation
- Streak bonus awarded every 10 consecutive charges
- Auto-expiry check on balance reads
- Redemption converts points to discount (100 pts = 1%, max 50%)
…dges/refs to screen

- New types: PointTxType, LoyaltyConfig, StreakInfo, ReferralInfo
- loyaltyStore: contract integration stubs, streak tracking,
  referral bonuses, gamification triggers
- LoyaltyDashboardScreen: streak card, referral share,
  badges modal, points expiry UI, tier comparison table
- gamificationService: 8 new loyalty achievements and badges
  (point milestones, streak milestones, referral milestones)
- Gamification triggers wired into accumulatePoints and
  earnReferralBonus flows
@activatedkc activatedkc force-pushed the feat/loyalty-rewards-program-387 branch from 713c666 to 7e78c8e Compare May 28, 2026 16:28
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@activatedkc 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! 🚀

Learn more about application limits

@activatedkc
Copy link
Copy Markdown
Contributor Author

Fixed @Smartdevs17

@Smartdevs17
Copy link
Copy Markdown
Owner

Still merge conflicts

@activatedkc
Copy link
Copy Markdown
Contributor Author

Resolved @Smartdevs17

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.

Implement loyalty and rewards program for subscribers

2 participants