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

View file

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

View file

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

View file

@ -44,7 +44,14 @@ final pWalletBalance = Provider.family<Balance, String>(
final pWalletBalanceSecondary = Provider.family<Balance, String>( final pWalletBalanceSecondary = Provider.family<Balance, String>(
(ref, walletId) { (ref, walletId) {
return ref.watch(_wiProvider(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));
}, },
); );