clean up missing balance change issues

This commit is contained in:
julian 2023-11-16 17:32:47 -06:00
parent c83a0ec2a4
commit 32f9fc51e1
4 changed files with 18 additions and 9 deletions

View file

@ -87,10 +87,6 @@ Future<void> migrateWalletsToIsar({
//
Map<String, dynamic> otherData = {};
otherData[WalletInfoKeys.cachedSecondaryBalance] = walletBox.get(
DBKeys.cachedBalanceSecondary,
) as String?;
otherData[WalletInfoKeys.tokenContractAddresses] = walletBox.get(
DBKeys.ethTokenContracts,
) as List<String>?;
@ -132,6 +128,9 @@ Future<void> migrateWalletsToIsar({
cachedBalanceString: walletBox.get(
DBKeys.cachedBalance,
) as String?,
cachedBalanceSecondaryString: walletBox.get(
DBKeys.cachedBalanceSecondary,
) as String?,
otherDataJsonString: jsonEncode(otherData),
);

View file

@ -149,7 +149,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
availableBalance = wallet.info.cachedBalance.spendable;
// (manager.wallet as FiroWallet).availablePrivateBalance();
} else {
availableBalance = wallet.info.cachedSecondaryBalance.spendable;
availableBalance = wallet.info.cachedBalanceSecondary.spendable;
// (manager.wallet as FiroWallet).availablePublicBalance();
}
} else {
@ -556,7 +556,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
balance = info.cachedBalance.spendable;
// balance = wallet.availablePrivateBalance();
} else {
balance = info.cachedSecondaryBalance.spendable;
balance = info.cachedBalanceSecondary.spendable;
// balance = wallet.availablePublicBalance();
}
return ref.read(pAmountFormatter(coin)).format(balance);
@ -763,7 +763,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
// .toStringAsFixed(coin.decimals);
} else {
cryptoAmountController.text = info
.cachedSecondaryBalance.spendable.decimal
.cachedBalanceSecondary.spendable.decimal
.toStringAsFixed(coin.decimals);
// cryptoAmountController.text = firoWallet
// .availablePublicBalance()

View file

@ -320,6 +320,8 @@ class WalletInfo implements IsarId {
int restoreHeight = 0,
bool isMnemonicVerified = false,
String? cachedBalanceString,
String? cachedBalanceSecondaryString,
String? cachedBalanceTertiaryString,
String? otherDataJsonString,
}) : assert(
Coin.values.map((e) => e.name).contains(coinName),
@ -332,6 +334,8 @@ class WalletInfo implements IsarId {
_restoreHeight = restoreHeight,
_isMnemonicVerified = isMnemonicVerified,
_cachedBalanceString = cachedBalanceString,
_cachedBalanceSecondaryString = cachedBalanceSecondaryString,
_cachedBalanceTertiaryString = cachedBalanceTertiaryString,
_otherDataJsonString = otherDataJsonString;
static WalletInfo createNew({
@ -385,7 +389,6 @@ class WalletInfo implements IsarId {
abstract class WalletInfoKeys {
static const String tokenContractAddresses = "tokenContractAddressesKey";
static const String cachedSecondaryBalance = "cachedSecondaryBalanceKey";
static const String epiccashData = "epiccashDataKey";
static const String bananoMonkeyImageBytes = "monkeyImageBytesKey";
}

View file

@ -44,7 +44,14 @@ final pWalletBalance = Provider.family<Balance, String>(
final pWalletBalanceSecondary = Provider.family<Balance, String>(
(ref, walletId) {
return ref.watch(_wiProvider(walletId)
.select((value) => (value.value as WalletInfo).cachedSecondaryBalance));
.select((value) => (value.value as WalletInfo).cachedBalanceSecondary));
},
);
final pWalletBalanceTertiary = Provider.family<Balance, String>(
(ref, walletId) {
return ref.watch(_wiProvider(walletId)
.select((value) => (value.value as WalletInfo).cachedBalanceTertiary));
},
);