mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
remove direct dependency of unused SharedPreferences
This commit is contained in:
parent
077ba6429b
commit
f08a52cd07
6 changed files with 42 additions and 55 deletions
|
@ -26,7 +26,6 @@ import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output;
|
|||
import 'package:http/http.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stackwallet/hive/db.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
||||
|
@ -671,7 +670,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
WalletInfo walletInfo;
|
||||
WalletCredentials credentials;
|
||||
|
@ -707,7 +705,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: _secureStore,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -788,7 +785,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
|
||||
await _generateNewWallet();
|
||||
|
@ -833,7 +829,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
|
||||
await _prefs.init();
|
||||
|
@ -888,7 +883,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
// TODO: are these needed?
|
||||
|
||||
WalletService? walletService;
|
||||
SharedPreferences? prefs;
|
||||
KeyService? keysStorage;
|
||||
MoneroWalletBase? walletBase;
|
||||
WalletCreationService? _walletCreationService;
|
||||
|
@ -969,7 +963,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
WalletInfo walletInfo;
|
||||
WalletCredentials credentials;
|
||||
|
@ -998,7 +991,6 @@ class MoneroWallet extends CoinServiceAPI {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: _secureStore,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
|
|
@ -27,7 +27,6 @@ import 'package:flutter_libmonero/wownero/wownero.dart';
|
|||
import 'package:http/http.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stackwallet/hive/db.dart';
|
||||
import 'package:stackwallet/models/node_model.dart';
|
||||
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
||||
|
@ -673,7 +672,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
// TODO: Wallet Service may need to be switched to Wownero
|
||||
walletService =
|
||||
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
WalletInfo walletInfo;
|
||||
WalletCredentials credentials;
|
||||
|
@ -700,7 +698,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: _secureStore,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -792,7 +789,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
// }
|
||||
walletService =
|
||||
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
|
||||
await _generateNewWallet(seedWordsLength: seedWordsLength);
|
||||
|
@ -837,7 +833,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
|
||||
await _prefs.init();
|
||||
|
@ -892,7 +887,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
// TODO: are these needed?
|
||||
|
||||
WalletService? walletService;
|
||||
SharedPreferences? prefs;
|
||||
KeyService? keysStorage;
|
||||
WowneroWalletBase? walletBase;
|
||||
WalletCreationService? _walletCreationService;
|
||||
|
@ -990,7 +984,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
walletService =
|
||||
wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox);
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(_secureStore);
|
||||
WalletInfo walletInfo;
|
||||
WalletCredentials credentials;
|
||||
|
@ -1019,7 +1012,6 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: _secureStore,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
|
|
@ -1244,7 +1244,7 @@ packages:
|
|||
source: hosted
|
||||
version: "3.0.1"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences
|
||||
url: "https://pub.dartlang.org"
|
||||
|
|
|
@ -126,7 +126,7 @@ dependencies:
|
|||
pointycastle: ^3.6.0
|
||||
package_info_plus: ^1.4.2
|
||||
lottie: ^1.3.0
|
||||
shared_preferences: ^2.0.15
|
||||
# shared_preferences: ^2.0.15
|
||||
file_picker: ^5.0.1
|
||||
connectivity_plus: 2.3.6+1
|
||||
# document_file_save_plus: ^1.0.5
|
||||
|
|
|
@ -19,7 +19,6 @@ import 'package:hive/hive.dart';
|
|||
import 'package:hive_test/hive_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stackwallet/services/wallets.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
|
||||
|
@ -27,10 +26,8 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
|||
|
||||
import 'monero_wallet_test_data.dart';
|
||||
|
||||
//FlutterSecureStorage? storage;
|
||||
FakeSecureStorage? storage;
|
||||
WalletService? walletService;
|
||||
SharedPreferences? prefs;
|
||||
KeyService? keysStorage;
|
||||
MoneroWalletBase? walletBase;
|
||||
late WalletCreationService _walletCreationService;
|
||||
|
@ -46,7 +43,6 @@ WalletType type = WalletType.monero;
|
|||
@GenerateMocks([])
|
||||
void main() async {
|
||||
storage = FakeSecureStorage();
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(storage!);
|
||||
WalletInfo walletInfo = WalletInfo.external(
|
||||
id: '',
|
||||
|
@ -90,12 +86,12 @@ void main() async {
|
|||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
path = await pathForWallet(name: name, type: type);
|
||||
credentials =
|
||||
// // creating a new wallet
|
||||
// monero.createMoneroNewWalletCredentials(
|
||||
// name: name, language: "English");
|
||||
// restoring a previous wallet
|
||||
monero.createMoneroRestoreWalletFromSeedCredentials(
|
||||
name: name, height: 2580000, mnemonic: testMnemonic);
|
||||
// // creating a new wallet
|
||||
// monero.createMoneroNewWalletCredentials(
|
||||
// name: name, language: "English");
|
||||
// restoring a previous wallet
|
||||
monero.createMoneroRestoreWalletFromSeedCredentials(
|
||||
name: name, height: 2580000, mnemonic: testMnemonic);
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
id: WalletBase.idFor(name, type),
|
||||
|
@ -111,7 +107,6 @@ void main() async {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -124,8 +119,8 @@ void main() async {
|
|||
|
||||
test("Test mainnet address generation from seed", () async {
|
||||
final wallet = await
|
||||
// _walletCreationService.create(credentials);
|
||||
_walletCreationService.restoreFromSeed(credentials);
|
||||
// _walletCreationService.create(credentials);
|
||||
_walletCreationService.restoreFromSeed(credentials);
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
//print(walletInfo.address);
|
||||
|
||||
|
@ -134,8 +129,7 @@ void main() async {
|
|||
walletBase = wallet as MoneroWalletBase;
|
||||
//print("${walletBase?.seed}");
|
||||
|
||||
expect(
|
||||
await walletBase!.validateAddress(walletInfo.address ?? ''), true);
|
||||
expect(await walletBase!.validateAddress(walletInfo.address ?? ''), true);
|
||||
|
||||
// print(walletBase);
|
||||
// loggerPrint(walletBase.toString());
|
||||
|
@ -157,20 +151,31 @@ void main() async {
|
|||
expect(
|
||||
await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]);
|
||||
|
||||
expect(await walletBase!.validateAddress(''), false);
|
||||
expect(
|
||||
await walletBase!.validateAddress(''), false);
|
||||
await walletBase!.validateAddress(
|
||||
'4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'),
|
||||
true);
|
||||
expect(
|
||||
await walletBase!.validateAddress('4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), true);
|
||||
await walletBase!.validateAddress(
|
||||
'4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'),
|
||||
false);
|
||||
expect(
|
||||
await walletBase!.validateAddress('4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'), false);
|
||||
await walletBase!.validateAddress(
|
||||
'8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'),
|
||||
false);
|
||||
expect(
|
||||
await walletBase!.validateAddress('8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), false);
|
||||
await walletBase!.validateAddress(
|
||||
'84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'),
|
||||
true);
|
||||
expect(
|
||||
await walletBase!.validateAddress('84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), true);
|
||||
await walletBase!.validateAddress(
|
||||
'8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'),
|
||||
false);
|
||||
expect(
|
||||
await walletBase!.validateAddress('8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'), false);
|
||||
expect(
|
||||
await walletBase!.validateAddress('44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), false);
|
||||
await walletBase!.validateAddress(
|
||||
'44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'),
|
||||
false);
|
||||
});
|
||||
});
|
||||
/*
|
||||
|
@ -229,6 +234,6 @@ Future<String> pathForWalletDir(
|
|||
}
|
||||
|
||||
Future<String> pathForWallet(
|
||||
{required String name, required WalletType type}) async =>
|
||||
{required String name, required WalletType type}) async =>
|
||||
await pathForWalletDir(name: name, type: type)
|
||||
.then((path) => path + '/$name');
|
||||
|
|
|
@ -19,14 +19,12 @@ import 'package:hive/hive.dart';
|
|||
import 'package:hive_test/hive_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||
|
||||
import 'wownero_wallet_test_data.dart';
|
||||
|
||||
FakeSecureStorage? storage;
|
||||
WalletService? walletService;
|
||||
SharedPreferences? prefs;
|
||||
KeyService? keysStorage;
|
||||
WowneroWalletBase? walletBase;
|
||||
late WalletCreationService _walletCreationService;
|
||||
|
@ -41,7 +39,6 @@ WalletType type = WalletType.wownero;
|
|||
@GenerateMocks([])
|
||||
void main() async {
|
||||
storage = FakeSecureStorage();
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(storage!);
|
||||
WalletInfo walletInfo = WalletInfo.external(
|
||||
id: '',
|
||||
|
@ -102,7 +99,6 @@ void main() async {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -127,19 +123,24 @@ void main() async {
|
|||
walletBase = wallet as WowneroWalletBase;
|
||||
|
||||
expect(
|
||||
await walletBase!.validateAddress(wallet.walletAddresses.address ?? ''), true);
|
||||
await walletBase!
|
||||
.validateAddress(wallet.walletAddresses.address ?? ''),
|
||||
true);
|
||||
} catch (_) {
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
|
||||
// Address validation
|
||||
expect(await walletBase!.validateAddress(''), false);
|
||||
expect(
|
||||
await walletBase!.validateAddress(''), false);
|
||||
await walletBase!.validateAddress(
|
||||
'Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'),
|
||||
true);
|
||||
expect(
|
||||
await walletBase!.validateAddress('Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'), true);
|
||||
expect(
|
||||
await walletBase!.validateAddress('WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'), false);
|
||||
await walletBase!.validateAddress(
|
||||
'WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'),
|
||||
false);
|
||||
|
||||
walletBase?.close();
|
||||
walletBase = wallet as WowneroWalletBase;
|
||||
|
@ -174,7 +175,6 @@ void main() async {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -248,7 +248,6 @@ void main() async {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -312,7 +311,6 @@ void main() async {
|
|||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
|
@ -367,6 +365,6 @@ Future<String> pathForWalletDir(
|
|||
}
|
||||
|
||||
Future<String> pathForWallet(
|
||||
{required String name, required WalletType type}) async =>
|
||||
{required String name, required WalletType type}) async =>
|
||||
await pathForWalletDir(name: name, type: type)
|
||||
.then((path) => path + '/$name');
|
||||
|
|
Loading…
Reference in a new issue