fix(mobile): use wallet-service for balance queries

- Planting page: fetch USDT balance from wallet-service instead of blockchain-service
- Deposit page: fetch USDT balance from wallet-service instead of blockchain-service

This ensures balance reflects internal wallet state, not on-chain balance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-10 09:07:15 -08:00
parent 3714edb30b
commit 317ea1234d
2 changed files with 10 additions and 21 deletions

View File

@ -77,19 +77,14 @@ class _DepositUsdtPageState extends ConsumerState<DepositUsdtPage> {
_bscAddress = addressResponse.bscAddress;
_dstAddress = addressResponse.dstAddress;
//
// wallet-service
try {
final balanceResponse = await depositService.getUsdtBalances();
//
final walletService = ref.read(walletServiceProvider);
final walletResponse = await walletService.getMyWallet();
// USDT
if (mounted) {
setState(() {
if (_selectedNetwork == NetworkType.kava && balanceResponse.kava != null) {
_balance = balanceResponse.kava!.balance;
} else if (_selectedNetwork == NetworkType.bsc && balanceResponse.bsc != null) {
_balance = balanceResponse.bsc!.balance;
} else {
_balance = '0.00';
}
_balance = walletResponse.balances.usdt.available.toStringAsFixed(2);
_isLoading = false;
});
}

View File

@ -96,18 +96,12 @@ class _PlantingQuantityPageState extends ConsumerState<PlantingQuantityPage> {
});
try {
// API USDT
final depositService = ref.read(depositServiceProvider);
final balanceResponse = await depositService.getUsdtBalances();
// wallet-service
final walletService = ref.read(walletServiceProvider);
final walletResponse = await walletService.getMyWallet();
// KAVA BSC
double totalBalance = 0.0;
if (balanceResponse.kava != null) {
totalBalance += double.tryParse(balanceResponse.kava!.balance) ?? 0.0;
}
if (balanceResponse.bsc != null) {
totalBalance += double.tryParse(balanceResponse.bsc!.balance) ?? 0.0;
}
// 使 USDT
final totalBalance = walletResponse.balances.usdt.available;
//
final maxQty = (totalBalance / _pricePerTree).floor();