mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
Merge remote-tracking branch 'origin_SW/staging' into themes
This commit is contained in:
commit
fe0155edc7
3 changed files with 31 additions and 46 deletions
5
.github/workflows/test.yaml
vendored
5
.github/workflows/test.yaml
vendored
|
@ -8,10 +8,13 @@ jobs:
|
|||
- name: Prepare repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
flutter-version: '3.3.4'
|
||||
flutter-version: '3.7.10'
|
||||
channel: 'stable'
|
||||
- name: Install Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.7.10'
|
||||
channel: 'stable'
|
||||
- name: Setup | Rust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 398077d745bfb8e27c6fcb3fae971908566b2222
|
||||
Subproject commit 594ab89bc665a15a810ba7476ed2ad255fa8b5ac
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
|
@ -56,6 +57,10 @@ class BadEpicHttpAddressException implements Exception {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class ListenerManager {
|
||||
static Pointer<Void>? pointer;
|
||||
}
|
||||
|
||||
// isolate
|
||||
|
||||
Map<ReceivePort, Isolate> isolates = {};
|
||||
|
@ -178,18 +183,8 @@ Future<void> executeNative(Map<String, dynamic> arguments) async {
|
|||
sendPort.send(result);
|
||||
return;
|
||||
}
|
||||
} else if (function == "listenForSlates") {
|
||||
final wallet = arguments['wallet'] as String?;
|
||||
final epicboxConfig = arguments['epicboxConfig'] as String?;
|
||||
}
|
||||
|
||||
Map<String, dynamic> result = {};
|
||||
if (!(wallet == null || epicboxConfig == null)) {
|
||||
var res = await epicboxListen(wallet, epicboxConfig);
|
||||
result['result'] = res;
|
||||
sendPort.send(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Logging.instance.log(
|
||||
"Error Arguments for $function not formatted correctly",
|
||||
level: LogLevel.Fatal);
|
||||
|
@ -714,8 +709,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
await _prefs.init();
|
||||
await updateNode(false);
|
||||
await _refreshBalance();
|
||||
//Open Epicbox listener in the background
|
||||
await listenForSlates();
|
||||
// TODO: is there anything else that should be set up here whenever this wallet is first loaded again?
|
||||
}
|
||||
|
||||
|
@ -810,9 +803,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
epicUpdateChangeIndex(0),
|
||||
]);
|
||||
|
||||
//Open Epicbox listener in the background
|
||||
await listenForSlates();
|
||||
|
||||
final initialReceivingAddress = await _getReceivingAddressForIndex(0);
|
||||
|
||||
await db.putAddress(initialReceivingAddress);
|
||||
|
@ -1162,6 +1152,14 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
|
||||
Future<bool> startScans() async {
|
||||
try {
|
||||
if (ListenerManager.pointer != null) {
|
||||
Logging.instance
|
||||
.log("LISTENER HANDLER IS NOT NULL ....", level: LogLevel.Info);
|
||||
Logging.instance
|
||||
.log("STOPPING ANY WALLET LISTENER ....", level: LogLevel.Info);
|
||||
epicboxListenerStop(ListenerManager.pointer!);
|
||||
}
|
||||
|
||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||
|
||||
var restoreHeight = epicGetRestoreHeight();
|
||||
|
@ -1203,6 +1201,7 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
await getSyncPercent;
|
||||
}
|
||||
Logging.instance.log("successfully at the tip", level: LogLevel.Info);
|
||||
await listenToEpicbox();
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e, $s", level: LogLevel.Warning);
|
||||
|
@ -1277,9 +1276,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
|
||||
//Store Epic box address info
|
||||
await storeEpicboxInfo();
|
||||
|
||||
//Open Epicbox listener in the background
|
||||
await listenForSlates();
|
||||
} catch (e, s) {
|
||||
Logging.instance
|
||||
.log("Error recovering wallet $e\n$s", level: LogLevel.Error);
|
||||
|
@ -1287,6 +1283,15 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> listenToEpicbox() async {
|
||||
Logging.instance.log("STARTING WALLET LISTENER ....", level: LogLevel.Info);
|
||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
|
||||
|
||||
ListenerManager.pointer =
|
||||
epicboxListenerStart(wallet!, epicboxConfig.toString());
|
||||
}
|
||||
|
||||
Future<int> getRestoreHeight() async {
|
||||
return epicGetRestoreHeight() ?? epicGetCreationHeight()!;
|
||||
}
|
||||
|
@ -1451,29 +1456,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> listenForSlates() async {
|
||||
final wallet = await _secureStore.read(key: '${_walletId}_wallet');
|
||||
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
|
||||
|
||||
await m.protect(() async {
|
||||
Logging.instance.log("CALLING LISTEN FOR SLATES", level: LogLevel.Info);
|
||||
ReceivePort receivePort = await getIsolate({
|
||||
"function": "listenForSlates",
|
||||
"wallet": wallet,
|
||||
"epicboxConfig": epicboxConfig.toString(),
|
||||
}, name: walletName);
|
||||
|
||||
var result = await receivePort.first;
|
||||
if (result is String) {
|
||||
Logging.instance
|
||||
.log("this is a message $result", level: LogLevel.Error);
|
||||
stop(receivePort);
|
||||
throw Exception("subscribeRequest isolate failed");
|
||||
}
|
||||
stop(receivePort);
|
||||
});
|
||||
}
|
||||
|
||||
/// Refreshes display data for the wallet
|
||||
@override
|
||||
Future<void> refresh() async {
|
||||
|
|
Loading…
Reference in a new issue