pass config param to wallet deletion method

had to add param because existing rust wallet deletion method can't check for existence without it but I'd like to do this differently on the rust side and revert this change

plus the type handling (`decoded is String`) is a hack vs making a model like it probably should be
This commit is contained in:
sneurlax 2023-03-01 17:59:20 -06:00
parent 47e63cca68
commit a8e079bd84
2 changed files with 21 additions and 4 deletions

@ -1 +1 @@
Subproject commit f017e01b574a77ad76b8b9c1837b333b777d7e92 Subproject commit 2a83a84e3454108b454810e5f5740634719aad44

View file

@ -219,8 +219,8 @@ 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({
@ -248,6 +248,23 @@ Future<String> deleteEpicWallet({
// editConfig["wallet_dir"] = walletDir; // editConfig["wallet_dir"] = walletDir;
// config = jsonEncode(editConfig); // config = jsonEncode(editConfig);
// } // }
String? storedConfig =
await secureStore.read(key: '${walletId}_epicboxConfig');
if (storedConfig == null) {
storedConfig = DefaultNodes.defaultEpicBoxConfig;
} else {
dynamic decoded = json.decode(storedConfig!);
if (decoded is String) {
decoded = json.decode(decoded);
}
final domain = decoded["domain"] ?? "empty";
if (domain != "empty") {
//If we have the old invalid config, use the new default one
// new storage format stores domain under "epicbox_domain", old storage format used "domain"
storedConfig = DefaultNodes.defaultEpicBoxConfig;
}
}
final wallet = await secureStore.read(key: '${walletId}_wallet'); final wallet = await secureStore.read(key: '${walletId}_wallet');
@ -255,7 +272,7 @@ Future<String> deleteEpicWallet({
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 compute(_deleteWalletWrapper, Tuple2(wallet, storedConfig));
} 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...";