mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
More clean up, handle epicbox config for old wallets
This commit is contained in:
parent
6c84921378
commit
719f554995
1 changed files with 20 additions and 23 deletions
|
@ -456,8 +456,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
|
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
|
||||||
try {
|
try {
|
||||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||||
final epicboxConfig =
|
final epicboxConfig = await getEpicBoxConfig();
|
||||||
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
|
||||||
|
|
||||||
// TODO determine whether it is worth sending change to a change address.
|
// TODO determine whether it is worth sending change to a change address.
|
||||||
dynamic message;
|
dynamic message;
|
||||||
|
@ -517,8 +516,6 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
throw BadEpicHttpAddressException(message: sendTx);
|
throw BadEpicHttpAddressException(message: sendTx);
|
||||||
}
|
}
|
||||||
|
|
||||||
await putSendToAddresses(sendTx);
|
|
||||||
|
|
||||||
Logging.instance.log("CONFIRM_RESULT_IS $sendTx", level: LogLevel.Info);
|
Logging.instance.log("CONFIRM_RESULT_IS $sendTx", level: LogLevel.Info);
|
||||||
|
|
||||||
final decodeData = json.decode(sendTx);
|
final decodeData = json.decode(sendTx);
|
||||||
|
@ -531,21 +528,11 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
// //TODO: second problem
|
// //TODO: second problem
|
||||||
final transaction = json.decode(txCreateResult as String);
|
final transaction = json.decode(txCreateResult as String);
|
||||||
|
|
||||||
Logger.print("TX_IS $transaction");
|
|
||||||
final tx = transaction[0];
|
final tx = transaction[0];
|
||||||
final txLogEntry = json.decode(tx as String);
|
final txLogEntry = json.decode(tx as String);
|
||||||
final txLogEntryFirst = txLogEntry[0];
|
final txLogEntryFirst = txLogEntry[0];
|
||||||
Logger.print("TX_LOG_ENTRY_IS $txLogEntryFirst");
|
|
||||||
final slateToAddresses = epicGetSlatesToAddresses();
|
|
||||||
final slateId = txLogEntryFirst['tx_slate_id'] as String;
|
final slateId = txLogEntryFirst['tx_slate_id'] as String;
|
||||||
slateToAddresses[slateId] = txData['addresss'];
|
return slateId!;
|
||||||
await epicUpdateSlatesToAddresses(slateToAddresses);
|
|
||||||
|
|
||||||
final slatesToCommits = await getSlatesToCommits();
|
|
||||||
String? commitId = slatesToCommits[slateId]?['commitId'] as String?;
|
|
||||||
Logging.instance.log("sent commitId: $commitId", level: LogLevel.Info);
|
|
||||||
return commitId!;
|
|
||||||
// return txLogEntryFirst['tx_slate_id'] as String;
|
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log("Error sending $e - $s", level: LogLevel.Error);
|
Logging.instance.log("Error sending $e - $s", level: LogLevel.Error);
|
||||||
|
@ -568,8 +555,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
|
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||||
final epicboxConfig =
|
final epicboxConfig = await getEpicBoxConfig();
|
||||||
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
|
||||||
|
|
||||||
String? walletAddress;
|
String? walletAddress;
|
||||||
await m.protect(() async {
|
await m.protect(() async {
|
||||||
|
@ -729,8 +715,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
Logging.instance.log("This index is $index", level: LogLevel.Info);
|
Logging.instance.log("This index is $index", level: LogLevel.Info);
|
||||||
final epicboxConfig =
|
final epicboxConfig = await getEpicBoxConfig();
|
||||||
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
|
||||||
String? walletAddress;
|
String? walletAddress;
|
||||||
await m.protect(() async {
|
await m.protect(() async {
|
||||||
walletAddress = await compute(
|
walletAddress = await compute(
|
||||||
|
@ -996,8 +981,21 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getEpicBoxConfig() async {
|
Future<String> getEpicBoxConfig() async {
|
||||||
return await _secureStore.read(key: '${_walletId}_epicboxConfig') ??
|
final storedConfig =
|
||||||
DefaultNodes.defaultEpicBoxConfig;
|
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
||||||
|
if (storedConfig != null) {
|
||||||
|
final decoded = json.decode(storedConfig!);
|
||||||
|
final domain = decoded["domain"] ?? "empty";
|
||||||
|
if (domain != "empty") {
|
||||||
|
//If we have the old invalid config - update
|
||||||
|
await _secureStore.write(
|
||||||
|
key: '${_walletId}_epicboxConfig',
|
||||||
|
value: DefaultNodes.defaultEpicBoxConfig);
|
||||||
|
}
|
||||||
|
return await _secureStore.read(key: '${_walletId}_epicboxConfig') ??
|
||||||
|
DefaultNodes.defaultEpicBoxConfig;
|
||||||
|
}
|
||||||
|
return DefaultNodes.defaultEpicBoxConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getRealConfig() async {
|
Future<String> getRealConfig() async {
|
||||||
|
@ -1315,8 +1313,7 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
|
|
||||||
Future<void> listenForSlates() async {
|
Future<void> listenForSlates() async {
|
||||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||||
final epicboxConfig =
|
final epicboxConfig = await getEpicBoxConfig();
|
||||||
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
|
||||||
|
|
||||||
await m.protect(() async {
|
await m.protect(() async {
|
||||||
Logging.instance.log("CALLING LISTEN FOR SLATES", level: LogLevel.Info);
|
Logging.instance.log("CALLING LISTEN FOR SLATES", level: LogLevel.Info);
|
||||||
|
|
Loading…
Reference in a new issue