From a73e18df75a754ffe0e3546c15dec7d25d528808 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:23:21 -0600 Subject: [PATCH] expose wallet isar instance to Manager --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 3 +++ lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 3 +++ lib/services/coins/coin_service.dart | 3 +++ lib/services/coins/dogecoin/dogecoin_wallet.dart | 3 +++ lib/services/coins/epiccash/epiccash_wallet.dart | 3 +++ lib/services/coins/firo/firo_wallet.dart | 5 +++-- lib/services/coins/litecoin/litecoin_wallet.dart | 3 +++ lib/services/coins/manager.dart | 3 +++ lib/services/coins/monero/monero_wallet.dart | 3 +++ lib/services/coins/namecoin/namecoin_wallet.dart | 3 +++ lib/services/coins/particl/particl_wallet.dart | 3 +++ lib/services/coins/wownero/wownero_wallet.dart | 3 +++ 12 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index c3f446c23..1e62ea73e 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -3571,4 +3571,7 @@ class BitcoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index bd0033614..079bdce7f 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -3276,6 +3276,9 @@ class BitcoinCashWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Bitcoincash Network diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index fb433466c..e6f5eba5e 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -1,3 +1,4 @@ +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -294,4 +295,6 @@ abstract class CoinServiceAPI { Future updateSentCachedTxData(Map txData); int get storedChainHeight; + + Isar get isarInstance; } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 8c5535172..200b509c5 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -2749,6 +2749,9 @@ class DogecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Dogecoin Network diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index fa2d3aa49..8db32c147 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2337,4 +2337,7 @@ class EpicCashWallet extends CoinServiceAPI { @override Future> get transactions => isar.transactions.where().findAll(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 9c8ec32be..452a3c0f5 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -4873,11 +4873,12 @@ class FiroWallet extends CoinServiceAPI { Balance? _balancePrivate; @override - // TODO: implement utxos Future> get utxos => isar.utxos.where().findAll(); @override - // TODO: implement transactions Future> get transactions => isar.transactions.where().findAll(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index cd32ee605..199039f02 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -3623,6 +3623,9 @@ class LitecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } final litecoin = NetworkType( diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index a590752e0..90e91ce60 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/models.dart'; @@ -214,4 +215,6 @@ class Manager with ChangeNotifier { } int get currentHeight => _currentWallet.storedChainHeight; + + Isar get db => _currentWallet.isarInstance; } diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 017e5de81..5093d2ff6 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1271,4 +1271,7 @@ class MoneroWallet extends CoinServiceAPI { @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 1177e9057..d1901ce7f 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -3615,6 +3615,9 @@ class NamecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Namecoin Network diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index b95c6d567..e5cea378a 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -3384,6 +3384,9 @@ class ParticlWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Particl Network diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 43c04d80a..2a0bf0ada 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1347,4 +1347,7 @@ class WowneroWallet extends CoinServiceAPI { @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); + + @override + Isar get isarInstance => isar; }