remove flutter secure storage explicit instantiations from wow/xmr

This commit is contained in:
julian 2022-11-11 12:12:01 -06:00
parent ba853837ce
commit 9b09f65f4d
3 changed files with 16 additions and 25 deletions

View file

@ -154,6 +154,7 @@ void main() async {
await Hive.openBox<dynamic>(DB.boxNameDBInfo); await Hive.openBox<dynamic>(DB.boxNameDBInfo);
// todo: db migrate stuff for desktop needs to be handled eventually
if (!Util.isDesktop) { if (!Util.isDesktop) {
int dbVersion = DB.instance.get<dynamic>( int dbVersion = DB.instance.get<dynamic>(
boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ?? boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ??

View file

@ -23,7 +23,6 @@ import 'package:flutter_libmonero/core/key_service.dart';
import 'package:flutter_libmonero/core/wallet_creation_service.dart'; import 'package:flutter_libmonero/core/wallet_creation_service.dart';
import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/monero/monero.dart';
import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output; import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output;
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:mutex/mutex.dart'; import 'package:mutex/mutex.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -670,11 +669,10 @@ class MoneroWallet extends CoinServiceAPI {
"Attempted to overwrite mnemonic on generate new wallet!"); "Attempted to overwrite mnemonic on generate new wallet!");
} }
storage = const FlutterSecureStorage();
walletService = walletService =
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
WalletInfo walletInfo; WalletInfo walletInfo;
WalletCredentials credentials; WalletCredentials credentials;
try { try {
@ -708,7 +706,7 @@ class MoneroWallet extends CoinServiceAPI {
credentials.walletInfo = walletInfo; credentials.walletInfo = walletInfo;
_walletCreationService = WalletCreationService( _walletCreationService = WalletCreationService(
secureStorage: storage, secureStorage: _secureStore,
sharedPreferences: prefs, sharedPreferences: prefs,
walletService: walletService, walletService: walletService,
keyService: keysStorage, keyService: keysStorage,
@ -787,11 +785,11 @@ class MoneroWallet extends CoinServiceAPI {
// Logging.instance.log("Caught in initializeWallet(): $e\n$s"); // Logging.instance.log("Caught in initializeWallet(): $e\n$s");
// return false; // return false;
// } // }
storage = const FlutterSecureStorage();
walletService = walletService =
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
await _generateNewWallet(); await _generateNewWallet();
// var password; // var password;
@ -833,11 +831,10 @@ class MoneroWallet extends CoinServiceAPI {
"Attempted to initialize an existing wallet using an unknown wallet ID!"); "Attempted to initialize an existing wallet using an unknown wallet ID!");
} }
storage = const FlutterSecureStorage();
walletService = walletService =
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
await _prefs.init(); await _prefs.init();
final data = final data =
@ -889,7 +886,7 @@ class MoneroWallet extends CoinServiceAPI {
bool longMutex = false; bool longMutex = false;
// TODO: are these needed? // TODO: are these needed?
FlutterSecureStorage? storage;
WalletService? walletService; WalletService? walletService;
SharedPreferences? prefs; SharedPreferences? prefs;
KeyService? keysStorage; KeyService? keysStorage;
@ -970,11 +967,10 @@ class MoneroWallet extends CoinServiceAPI {
await DB.instance await DB.instance
.put<dynamic>(boxName: walletId, key: "restoreHeight", value: height); .put<dynamic>(boxName: walletId, key: "restoreHeight", value: height);
storage = const FlutterSecureStorage();
walletService = walletService =
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
WalletInfo walletInfo; WalletInfo walletInfo;
WalletCredentials credentials; WalletCredentials credentials;
String name = _walletId; String name = _walletId;
@ -1001,7 +997,7 @@ class MoneroWallet extends CoinServiceAPI {
credentials.walletInfo = walletInfo; credentials.walletInfo = walletInfo;
_walletCreationService = WalletCreationService( _walletCreationService = WalletCreationService(
secureStorage: storage, secureStorage: _secureStore,
sharedPreferences: prefs, sharedPreferences: prefs,
walletService: walletService, walletService: walletService,
keyService: keysStorage, keyService: keysStorage,

View file

@ -1,7 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:cw_core/get_height_by_date.dart';
import 'package:cw_core/monero_transaction_priority.dart'; import 'package:cw_core/monero_transaction_priority.dart';
import 'package:cw_core/node.dart'; import 'package:cw_core/node.dart';
import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/pending_transaction.dart';
@ -25,7 +24,6 @@ import 'package:flutter_libmonero/core/wallet_creation_service.dart';
import 'package:flutter_libmonero/view_model/send/output.dart' import 'package:flutter_libmonero/view_model/send/output.dart'
as wownero_output; as wownero_output;
import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:flutter_libmonero/wownero/wownero.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:mutex/mutex.dart'; import 'package:mutex/mutex.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -672,12 +670,11 @@ class WowneroWallet extends CoinServiceAPI {
"Attempted to overwrite mnemonic on generate new wallet!"); "Attempted to overwrite mnemonic on generate new wallet!");
} }
storage = const FlutterSecureStorage();
// TODO: Wallet Service may need to be switched to Wownero // TODO: Wallet Service may need to be switched to Wownero
walletService = walletService =
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
WalletInfo walletInfo; WalletInfo walletInfo;
WalletCredentials credentials; WalletCredentials credentials;
try { try {
@ -702,7 +699,7 @@ class WowneroWallet extends CoinServiceAPI {
credentials.walletInfo = walletInfo; credentials.walletInfo = walletInfo;
_walletCreationService = WalletCreationService( _walletCreationService = WalletCreationService(
secureStorage: storage, secureStorage: _secureStore,
sharedPreferences: prefs, sharedPreferences: prefs,
walletService: walletService, walletService: walletService,
keyService: keysStorage, keyService: keysStorage,
@ -793,11 +790,10 @@ class WowneroWallet extends CoinServiceAPI {
// Logging.instance.log("Caught in initializeWallet(): $e\n$s"); // Logging.instance.log("Caught in initializeWallet(): $e\n$s");
// return false; // return false;
// } // }
storage = const FlutterSecureStorage();
walletService = walletService =
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
await _generateNewWallet(seedWordsLength: seedWordsLength); await _generateNewWallet(seedWordsLength: seedWordsLength);
// var password; // var password;
@ -839,11 +835,10 @@ class WowneroWallet extends CoinServiceAPI {
"Attempted to initialize an existing wallet using an unknown wallet ID!"); "Attempted to initialize an existing wallet using an unknown wallet ID!");
} }
storage = const FlutterSecureStorage();
walletService = walletService =
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
await _prefs.init(); await _prefs.init();
final data = final data =
@ -895,7 +890,7 @@ class WowneroWallet extends CoinServiceAPI {
bool longMutex = false; bool longMutex = false;
// TODO: are these needed? // TODO: are these needed?
FlutterSecureStorage? storage;
WalletService? walletService; WalletService? walletService;
SharedPreferences? prefs; SharedPreferences? prefs;
KeyService? keysStorage; KeyService? keysStorage;
@ -993,11 +988,10 @@ class WowneroWallet extends CoinServiceAPI {
await DB.instance await DB.instance
.put<dynamic>(boxName: walletId, key: "restoreHeight", value: height); .put<dynamic>(boxName: walletId, key: "restoreHeight", value: height);
storage = const FlutterSecureStorage();
walletService = walletService =
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
keysStorage = KeyService(storage!); keysStorage = KeyService(_secureStore);
WalletInfo walletInfo; WalletInfo walletInfo;
WalletCredentials credentials; WalletCredentials credentials;
String name = _walletId; String name = _walletId;
@ -1024,7 +1018,7 @@ class WowneroWallet extends CoinServiceAPI {
credentials.walletInfo = walletInfo; credentials.walletInfo = walletInfo;
_walletCreationService = WalletCreationService( _walletCreationService = WalletCreationService(
secureStorage: storage, secureStorage: _secureStore,
sharedPreferences: prefs, sharedPreferences: prefs,
walletService: walletService, walletService: walletService,
keyService: keysStorage, keyService: keysStorage,