From 8ee94287589db1a8965f8dd753f693e624bad60f Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:50:22 -0600 Subject: [PATCH] add currentHeight getter --- .../coins/bitcoincash/bitcoincash_wallet.dart | 6 ++++-- lib/services/coins/coin_service.dart | 2 ++ lib/services/coins/firo/firo_wallet.dart | 19 ++++++++++++++----- lib/services/coins/manager.dart | 2 ++ lib/services/coins/monero/monero_wallet.dart | 4 ++++ .../coins/wownero/wownero_wallet.dart | 4 ++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index b18a97186..743822e2f 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -253,7 +253,8 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - Future get storedChainHeight async { + @override + int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; return storedHeight ?? 0; @@ -1174,7 +1175,8 @@ class BitcoinCashWallet extends CoinServiceAPI { final priceData = await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final String worthNow = Format.localizedStringAsFixed( value: ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index a690157ee..ff953708f 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -307,4 +307,6 @@ abstract class CoinServiceAPI { // used for electrumx coins Future updateSentCachedTxData(Map txData); + + int get storedChainHeight; } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 5d29bd0a9..adf259a32 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -883,7 +883,8 @@ class FiroWallet extends CoinServiceAPI { @override Future updateSentCachedTxData(Map txData) async { final currentPrice = await firoPrice; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final String worthNow = Format.localizedStringAsFixed( value: ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / @@ -2756,7 +2757,8 @@ class FiroWallet extends CoinServiceAPI { var price = await firoPrice; var builtHex = txb.build(); // return builtHex; - final locale =Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; return { "transaction": builtHex, "txid": txId, @@ -2810,7 +2812,8 @@ class FiroWallet extends CoinServiceAPI { final currentPrice = await firoPrice; // Grab the most recent information on all the joinsplits - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final updatedJSplit = await getJMintTransactions(cachedElectrumXClient, joinsplits, _prefs.currency, coin, currentPrice, locale!); @@ -3249,7 +3252,8 @@ class FiroWallet extends CoinServiceAPI { final currentPrice = await firoPrice; final List> midSortedArray = []; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; Logging.instance.log("refresh the txs", level: LogLevel.Info); for (final txObject in allTransactions) { @@ -4375,7 +4379,8 @@ class FiroWallet extends CoinServiceAPI { final lelantusEntry = await _getLelantusEntry(); final anonymitySets = await fetchAnonymitySets(); final locktime = await getBlockHead(electrumXClient); - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; ReceivePort receivePort = await getIsolate({ "function": "createJoinSplit", @@ -4806,4 +4811,8 @@ class FiroWallet extends CoinServiceAPI { Future availablePublicBalance() async { return (await balances)[4]; } + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); } diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index c850358eb..1c2163c04 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -278,4 +278,6 @@ class Manager with ChangeNotifier { } return success; } + + int get currentHeight => _currentWallet.storedChainHeight; } diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index d9c6ae42b..7b073e63f 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1334,4 +1334,8 @@ class MoneroWallet extends CoinServiceAPI { key: "highestPercentCached", value: value, ); + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 7abd64f48..fad3fc8ba 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1378,4 +1378,8 @@ class WowneroWallet extends CoinServiceAPI { key: "highestPercentCached", value: value, ); + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); }