mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
parent
e7e419bc83
commit
01150ef2a7
213 changed files with 23972 additions and 672 deletions
34
cw_haven/lib/haven_balance.dart
Normal file
34
cw_haven/lib/haven_balance.dart
Normal file
|
@ -0,0 +1,34 @@
|
|||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/monero_balance.dart';
|
||||
import 'package:cw_haven/api/balance_list.dart';
|
||||
import 'package:cw_haven/api/structs/haven_balance_row.dart';
|
||||
|
||||
const inactiveBalances = [
|
||||
CryptoCurrency.xcad,
|
||||
CryptoCurrency.xjpy,
|
||||
CryptoCurrency.xnok,
|
||||
CryptoCurrency.xnzd];
|
||||
|
||||
Map<CryptoCurrency, MoneroBalance> getHavenBalance({int accountIndex}) {
|
||||
final fullBalances = getHavenFullBalance(accountIndex: accountIndex);
|
||||
final unlockedBalances = getHavenUnlockedBalance(accountIndex: accountIndex);
|
||||
final havenBalances = <CryptoCurrency, MoneroBalance>{};
|
||||
final balancesLength = fullBalances.length;
|
||||
|
||||
for (int i = 0; i < balancesLength; i++) {
|
||||
final assetType = fullBalances[i].getAssetType();
|
||||
final fullBalance = fullBalances[i].getAmount();
|
||||
final unlockedBalance = unlockedBalances[i].getAmount();
|
||||
final moneroBalance = MoneroBalance(
|
||||
fullBalance: fullBalance, unlockedBalance: unlockedBalance);
|
||||
final currency = CryptoCurrency.fromString(assetType);
|
||||
|
||||
if (inactiveBalances.indexOf(currency) >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
havenBalances[currency] = moneroBalance;
|
||||
}
|
||||
|
||||
return havenBalances;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue