mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-22 07:09:10 +00:00
Merge pull request #381 from cypherstack/fix/epic-delete
Fix crash caused by epic wallet deletion panic
This commit is contained in:
commit
94b4c5bc76
2 changed files with 17 additions and 26 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit f017e01b574a77ad76b8b9c1837b333b777d7e92
|
Subproject commit 93af717966758ff07220150f6d9ed77275b29b87
|
|
@ -219,43 +219,34 @@ Future<String> _cancelTransactionWrapper(Tuple2<String, String> data) async {
|
||||||
return cancelTransaction(data.item1, data.item2);
|
return cancelTransaction(data.item1, data.item2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _deleteWalletWrapper(String wallet) async {
|
Future<String> _deleteWalletWrapper(Tuple2<String, String> data) async {
|
||||||
return deleteWallet(wallet);
|
return deleteWallet(data.item1, data.item2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> deleteEpicWallet({
|
Future<String> deleteEpicWallet({
|
||||||
required String walletId,
|
required String walletId,
|
||||||
required SecureStorageInterface secureStore,
|
required SecureStorageInterface secureStore,
|
||||||
}) async {
|
}) async {
|
||||||
// is this even needed for anything?
|
|
||||||
// String? config = await secureStore.read(key: '${walletId}_config');
|
|
||||||
// // TODO: why double check for iOS?
|
|
||||||
// if (Platform.isIOS) {
|
|
||||||
// Directory appDir = await StackFileSystem.applicationRootDirectory();
|
|
||||||
// // todo why double check for ios?
|
|
||||||
// // if (Platform.isIOS) {
|
|
||||||
// // appDir = (await getLibraryDirectory());
|
|
||||||
// // }
|
|
||||||
// // if (Platform.isLinux) {
|
|
||||||
// // appDir = Directory("${appDir.path}/.stackwallet");
|
|
||||||
// // }
|
|
||||||
// final path = "${appDir.path}/epiccash";
|
|
||||||
// final String name = walletId;
|
|
||||||
//
|
|
||||||
// final walletDir = '$path/$name';
|
|
||||||
// var editConfig = jsonDecode(config as String);
|
|
||||||
//
|
|
||||||
// editConfig["wallet_dir"] = walletDir;
|
|
||||||
// config = jsonEncode(editConfig);
|
|
||||||
// }
|
|
||||||
|
|
||||||
final wallet = await secureStore.read(key: '${walletId}_wallet');
|
final wallet = await secureStore.read(key: '${walletId}_wallet');
|
||||||
|
String? config = await secureStore.read(key: '${walletId}_config');
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
Directory appDir = await StackFileSystem.applicationRootDirectory();
|
||||||
|
|
||||||
|
final path = "${appDir.path}/epiccash";
|
||||||
|
final String name = walletId.trim();
|
||||||
|
final walletDir = '$path/$name';
|
||||||
|
|
||||||
|
var editConfig = jsonDecode(config as String);
|
||||||
|
|
||||||
|
editConfig["wallet_dir"] = walletDir;
|
||||||
|
config = jsonEncode(editConfig);
|
||||||
|
}
|
||||||
|
|
||||||
if (wallet == null) {
|
if (wallet == null) {
|
||||||
return "Tried to delete non existent epic wallet file with walletId=$walletId";
|
return "Tried to delete non existent epic wallet file with walletId=$walletId";
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return compute(_deleteWalletWrapper, wallet);
|
return _deleteWalletWrapper(Tuple2(wallet, config!));
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
||||||
return "deleteEpicWallet($walletId) failed...";
|
return "deleteEpicWallet($walletId) failed...";
|
||||||
|
|
Loading…
Reference in a new issue