Skip to content

fix: Replace LRNBalanceWidget mock data with real LearnToken contract calls #209#467

Merged
Anuoluwapo25 merged 2 commits intobakeronchain:mainfrom
Nanle-code:replace
Mar 31, 2026
Merged

fix: Replace LRNBalanceWidget mock data with real LearnToken contract calls #209#467
Anuoluwapo25 merged 2 commits intobakeronchain:mainfrom
Nanle-code:replace

Conversation

@Nanle-code
Copy link
Copy Markdown
Contributor

Summary

This PR replaces the hardcoded mock data in LRNBalanceWidget with real LearnToken contract calls, resolving issue #209.

What Changed

  • Removed Mock Data: Eliminated hardcoded mockBalance = 142, mockPrev = 122, and mockPercentile = 8
  • Real Contract Integration: Integrated the existing useLearnToken hook to call the actual LearnToken Soroban contract's balance() function
  • Proper Loading States: Replaced artificial 1200ms setTimeout with real async contract call loading
  • Balance History: Added localStorage-based balance tracking for change indicators
  • Percentile Calculation: Implemented balance-based percentile ranking system

Technical Details

  • Uses the existing useLearnToken hook from src/hooks/useLearnToken.ts
  • Created useLearnTokenWithHistory wrapper for balance persistence and percentile logic
  • Maintains all existing widget functionality (sm/md/lg sizes, animations, tooltips)
  • Proper error handling for contract failures

Files Modified

  • src/components/LRNBalanceWidget.tsx - Complete refactor to use real contract data

Testing

  • Verified real contract calls work correctly
  • Confirmed balance history tracking functions properly
  • Tested percentile calculations and rank labels
  • All widget sizes and features remain functional

Issue Resolution

Fixes #209: "LRNBalanceWidget: replace hardcoded mock data with real LearnToken contract call"

Dependencies

… calls

- Remove hardcoded mock values (mockBalance, mockPrev, mockPercentile)
- Remove artificial setTimeout loading simulation
- Integrate real useLearnToken hook with LearnToken contract balance() calls
- Add balance history tracking with localStorage persistence
- Implement percentile calculation based on actual balance
- Add proper loading and error handling for contract interactions

Fixes bakeronchain#209
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 28, 2026

@Nanle-code 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

@Anuoluwapo25
Copy link
Copy Markdown
Contributor

please reslove conflict

@Anuoluwapo25 Anuoluwapo25 merged commit 94cdf0a into bakeronchain:main Mar 31, 2026
2 of 6 checks passed
chonilius pushed a commit to chonilius/learnvault that referenced this pull request Apr 24, 2026
fix: Replace LRNBalanceWidget mock data with real LearnToken contract calls bakeronchain#209
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.

LRNBalanceWidget: replace hardcoded mock data with real LearnToken contract call

2 participants