Skip to content

Add miner reward menu#477

Open
dewabisma wants to merge 14 commits intomainfrom
beast/miner-reward-menu
Open

Add miner reward menu#477
dewabisma wants to merge 14 commits intomainfrom
beast/miner-reward-menu

Conversation

@dewabisma
Copy link
Copy Markdown
Collaborator

@dewabisma dewabisma commented May 6, 2026

Summary

  • Menu for miner rewards
  • Update skeleton styling
  • Update empty state home screen
  • Replace launchUrl to proper way with error handling

Screenshots

  • Miner loading
Simulator Screenshot - iPhone 8 - 2026-05-06 at 17 26 02
  • Miner empty
Simulator Screenshot - iPhone 8 - 2026-05-06 at 17 25 08
  • Miner has rewards
Simulator Screenshot - iPhone 8 - 2026-05-06 at 17 26 26
  • Home empty state
Simulator Screenshot - iPhone 8 - 2026-05-06 at 17 53 17

Note

Medium Risk
Introduces a new mining rewards flow that derives a Wormhole keypair from the user mnemonic and queries UTXO + Taskmaster stats, which touches wallet/keys and network calls. UI/theme changes are broad but mostly low-risk; the primary risk is correctness and error handling around rewards calculations and external service responses.

Overview
Adds a new Mining Rewards entry in v2 Settings (with a new axe.svg icon) and a full MiningRewardsScreen showing mined blocks/rewards, loading/empty/error states, and external links to telemetry and the mining setup guide.

Updates mining rewards data plumbing to include Planck reward totals plus redeemed vs redeemable amounts by fetching Taskmaster miner stats and Wormhole UTXO unspent balance (new hdWalletServiceProvider/wormholeUtxoServiceProvider), and extends MiningRewardsData accordingly.

Standardizes external link handling by introducing openUrl() (wrapped url_launcher with error logging) and replacing direct launchUrl calls across multiple components/sheets. Also refreshes UI polish: reworks v2 skeleton shimmer/colors (and adds TxItemSkeleton), simplifies the Home empty-state messaging, adds a zero-balance “Get Testnet Tokens” bottom CTA, and extends v2 theme text/colors for the new designs. Additionally fixes Wormhole transfer GraphQL ordering (block.height).

Reviewed by Cursor Bugbot for commit a4ac898. Bugbot is set up for automated code reviews on this repo. Configure here.

dewabisma added 6 commits May 5, 2026 15:21
- comply with hasura syntax
- change to new graphql url in constants
- update data model construction from json to comply new hasura return value
We have made hasura return string for number value.
Comment thread mobile-app/lib/v2/screens/home/home_screen.dart
Comment thread mobile-app/lib/v2/screens/home/home_screen.dart Outdated
Copy link
Copy Markdown
Collaborator

@n13 n13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can only show Planck total rewards, and available rewards, and a redeem button

I think we need to update miner screen to include claiming reward,

we might need a redeem button, so it will show
total earned
redeemed:
redeemable: (total - redeemed) [REDEEM BUTTON]

We cannot show total QUAN mined, we don't have the information - we only have info how many blocks someone mined.

Block rewards are not fixed, so it's not a multiplication either.

Change to:
Show total mined blocks
Testnet mined blocks
Testnet total rewards (lets use testnet instead of planck in the wording)
Available to claim:
[Claim button] (can be disabled for now, will implement shortly)

Comment thread mobile-app/lib/services/mining_rewards_service.dart Outdated
@dewabisma dewabisma changed the base branch from beast/update-graphql to main May 7, 2026 06:53
@dewabisma
Copy link
Copy Markdown
Collaborator Author

Added more stats and button

Simulator Screenshot - iPhone 8 - 2026-05-08 at 13 35 02

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a4ac898. Configure here.

TaskmasterService().getMinerStats(),
wormholeUtxoService.getUnspentBalance(wormholeAddress: keyPair.address, secretHex: keyPair.secretHex),
).wait;
final redeemedRewards = planckStats.totalRewards - redeemableRewards;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redeemed rewards can be negative from data inconsistency

Medium Severity

The calculation planckStats.totalRewards - redeemableRewards can produce a negative BigInt if the wormhole unspent balance exceeds the total rewards reported by the miner stats endpoint. This can occur due to timing differences between the two independent API calls, or if the wormhole address received funds from non-mining sources. The negative value would be formatted and displayed in the UI under "REDEEMED", showing something like "-0.5 QUAN" which is nonsensical.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a4ac898. Configure here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nonsense

}

final mnemonic = await ref.watch(settingsServiceProvider).getMnemonic(0);
final keyPair = ref.watch(hdWalletServiceProvider).deriveWormholeKeyPair(mnemonic: mnemonic!);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force unwrap of nullable mnemonic without null check

Low Severity

getMnemonic(0) returns Future<String?> and the result is force-unwrapped with mnemonic!. The codebase already handles the null mnemonic case in wallet_initializer.dart (showing a "mnemonic lost" dialog and sending telemetry), confirming this is a known possible state. If triggered here, the null assertion throws a generic exception surfaced as a confusing "Error getting mining rewards" message rather than guiding the user appropriately.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a4ac898. Configure here.


if (path != null) launchUrl(Uri.parse('${AppConstants.explorerEndpoint}/$path'));
if (path != null) openUrl('${AppConstants.explorerEndpoint}/$path');
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we changing semantics here, and why?

All these changes should be in separate PRs - there's some style changes, class changes, and the main implementation of miner reweards all mixed together.

final Uri url = Uri.parse(AppConstants.tutorialsAndGuidesUrl);
launchUrl(url);
},
onTap: () => openUrl(AppConstants.tutorialsAndGuidesUrl),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these style and API changes should be in a separate PR, they have nothing to do with the feature

@@ -11,25 +8,15 @@ class Skeleton extends StatefulWidget {
final BorderRadius? borderRadius;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skeleton refactor should be in a separate PR

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.

2 participants