ISSUE-DASH-001: Integrate TotalPool with Real Lottery Contract Data
✨ Issue Request
Replace mock data in the TotalPool component with real information from the Lottery contract, showing the accumulated prize pool of the current active lottery or indicating if the lottery is closed.
📌 Description
The TotalPool component located at packages/nextjs/components/dashboard/pool/page.tsx currently displays hardcoded data (pool: 1245.67, usdValue: 48230) and a countdown based on mock dates. This issue requires integrating the component with the Lottery contract to:
- Get the current active lottery: Determine the ID of the latest lottery and verify if it's active.
- Show the real prize pool: Obtain the accumulated jackpot amount from the contract.
- Handle closed state: If there's no active lottery, display a message indicating the lottery is closed, but still show the final accumulated prize pool.
- Block-based countdown: Use the block system to calculate remaining time instead of mock timestamps.
🛠️ Steps to Reproduce (if applicable)
- Navigate to the main dashboard of the application
- Observe the
TotalPool component at the top
- The displayed values are static and don't reflect the real contract state
🖼️ Screenshots (if applicable)
Not applicable - contract integration improvement.
🎯 Expected Behavior
The implementation must meet the following criteria:
Main Functionality
-
🔹 Get current lottery ID: Use the existing useCurrentDrawId() hook to get the current lottery ID from the contract.
-
🔹 Get draw information: Use the useDrawInfo({ drawId }) hook to obtain:
jackpotFormatted: The prize pool amount in readable format
isDrawActiveBlocks: Lottery status (active/closed)
blocksRemaining: Remaining blocks until closure
timeRemainingFromBlocks: Estimated time converted from blocks
-
🔹 Contract functions to query (through hooks):
GetCurrentDrawId(): Returns the current lottery ID
GetJackpotEntryAmount(drawId): Returns the accumulated prize pool amount
IsDrawActive(drawId): Returns if the lottery is active (true/false)
GetBlocksRemaining(drawId): Returns how many blocks remain until closure
GetJackpotEntryIsActive(drawId): Alternative to verify active status
-
🔹 Display state based on conditions:
- If lottery is active: Show current pool and normal countdown
- If lottery is closed: Show message "Current lottery is closed. New draw coming soon." and final accumulated pool
-
🔹 USD price conversion: Optionally, use the useTokenPrice hook or price service to convert STRKP to USD (can be a future improvement).
State Management
- 🔹 Loading: While loading contract data, show skeleton or loading state
- 🔹 Error: If there's an error fetching data, show appropriate message
- 🔹 No lottery: If
drawId === 0, show message indicating no lotteries have been created yet
UI/UX
- 🔹 Maintain the current visual design of the component
- 🔹 Animations and visual effects should remain
- 🔹 Amount format should continue showing $TRKP symbol
- 🔹 Countdown should auto-update while lottery is active
🚀 Suggested Solution / Feature Request
1. Hooks to use
The component should import and use:
import { useCurrentDrawId } from "~~/hooks/scaffold-stark/useCurrentDrawId";
import { useDrawInfo } from "~~/hooks/scaffold-stark/useDrawInfo";
2. Data structure to obtain
From useCurrentDrawId() hook:
currentDrawId: Numeric ID of current lottery
isLoading: Loading state
error: Error if any
From useDrawInfo({ drawId }) hook:
jackpotAmount: Amount as BigInt
jackpotFormatted: Formatted amount as string (e.g., "1245.67 $TRKP")
isDrawActiveBlocks: Boolean indicating if active
blocksRemaining: Number of remaining blocks
timeRemainingFromBlocks: Object with { days, hours, minutes, seconds }
3. Rendering logic
Step 1: Get currentDrawId from hook
Step 2: Pass the drawId to the useDrawInfo hook
Step 3: Evaluate isDrawActiveBlocks:
- If
true: Show pool + normal countdown
- If
false: Show pool + "lottery closed" message
Step 4: Use timeRemainingFromBlocks for countdown instead of current manual calculation
4. Contract functions (reference)
These functions are called internally by the hooks, no need to call them directly:
GetCurrentDrawId(): Returns current lottery ID (u64)
GetJackpotEntryAmount(drawId: u64): Returns accumulated pool (u256)
IsDrawActive(drawId: u64): Returns if active (bool)
GetBlocksRemaining(drawId: u64): Returns remaining blocks (u64)
GetJackpotEntryIsActive(drawId: u64): Alternative to verify status (bool)
5. Refactored component structure
The component should:
- Remove mock states (
pool, usdValue)
- Use hooks to get real data
- Handle loading/error states
- Condition rendering based on
isDrawActiveBlocks
- Keep existing Framer Motion animations
📌 Additional Notes
- The
useCurrentDrawId and useDrawInfo hooks are already implemented and tested in the project
- The
useDrawInfo hook already handles block-to-time conversion (12 seconds per block)
- The component should continue using
useTranslation for multilingual texts
- Do not implement direct contract function calls, use the provided hooks
⚠️ Before Applying
Please read this guide: Contributor Guidelines
ISSUE-DASH-001: Integrate TotalPool with Real Lottery Contract Data
✨ Issue Request
Replace mock data in the
TotalPoolcomponent with real information from the Lottery contract, showing the accumulated prize pool of the current active lottery or indicating if the lottery is closed.📌 Description
The
TotalPoolcomponent located atpackages/nextjs/components/dashboard/pool/page.tsxcurrently displays hardcoded data (pool: 1245.67,usdValue: 48230) and a countdown based on mock dates. This issue requires integrating the component with the Lottery contract to:🛠️ Steps to Reproduce (if applicable)
TotalPoolcomponent at the top🖼️ Screenshots (if applicable)
Not applicable - contract integration improvement.
🎯 Expected Behavior
The implementation must meet the following criteria:
Main Functionality
🔹 Get current lottery ID: Use the existing
useCurrentDrawId()hook to get the current lottery ID from the contract.🔹 Get draw information: Use the
useDrawInfo({ drawId })hook to obtain:jackpotFormatted: The prize pool amount in readable formatisDrawActiveBlocks: Lottery status (active/closed)blocksRemaining: Remaining blocks until closuretimeRemainingFromBlocks: Estimated time converted from blocks🔹 Contract functions to query (through hooks):
GetCurrentDrawId(): Returns the current lottery IDGetJackpotEntryAmount(drawId): Returns the accumulated prize pool amountIsDrawActive(drawId): Returns if the lottery is active (true/false)GetBlocksRemaining(drawId): Returns how many blocks remain until closureGetJackpotEntryIsActive(drawId): Alternative to verify active status🔹 Display state based on conditions:
🔹 USD price conversion: Optionally, use the
useTokenPricehook or price service to convert STRKP to USD (can be a future improvement).State Management
drawId === 0, show message indicating no lotteries have been created yetUI/UX
🚀 Suggested Solution / Feature Request
1. Hooks to use
The component should import and use:
2. Data structure to obtain
From
useCurrentDrawId()hook:currentDrawId: Numeric ID of current lotteryisLoading: Loading stateerror: Error if anyFrom
useDrawInfo({ drawId })hook:jackpotAmount: Amount as BigIntjackpotFormatted: Formatted amount as string (e.g., "1245.67 $TRKP")isDrawActiveBlocks: Boolean indicating if activeblocksRemaining: Number of remaining blockstimeRemainingFromBlocks: Object with{ days, hours, minutes, seconds }3. Rendering logic
Step 1: Get
currentDrawIdfrom hookStep 2: Pass the
drawIdto theuseDrawInfohookStep 3: Evaluate
isDrawActiveBlocks:true: Show pool + normal countdownfalse: Show pool + "lottery closed" messageStep 4: Use
timeRemainingFromBlocksfor countdown instead of current manual calculation4. Contract functions (reference)
These functions are called internally by the hooks, no need to call them directly:
GetCurrentDrawId(): Returns current lottery ID (u64)GetJackpotEntryAmount(drawId: u64): Returns accumulated pool (u256)IsDrawActive(drawId: u64): Returns if active (bool)GetBlocksRemaining(drawId: u64): Returns remaining blocks (u64)GetJackpotEntryIsActive(drawId: u64): Alternative to verify status (bool)5. Refactored component structure
The component should:
pool,usdValue)isDrawActiveBlocks📌 Additional Notes
useCurrentDrawIdanduseDrawInfohooks are already implemented and tested in the projectuseDrawInfohook already handles block-to-time conversion (12 seconds per block)useTranslationfor multilingual textsPlease read this guide: Contributor Guidelines