mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Mweb enhancements (#1715)
* node peer enhancement, delay mweb address generation, increase logging * prevent unnecessary sync status changes if we can't connect to the ltc node * handle potential errors * set nodeUri to null for testing * [skip ci] redo good changes * [skip ci] draft * [skip ci] minor * [skip ci] cleanup * [skip ci] minor * [skip ci] minor * [skip ci] localization * [skip ci] save * [skip ci] wip * use proxy layer * ui * minor changes Add ToDos for later * fixes * [skip ci] minor * [skip ci] minor * [skip ci] ui * handle case where there are no addresses with txcount > 0 * comment out pegin button --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
382a0ff35d
commit
37b822b7f5
46 changed files with 853 additions and 421 deletions
|
@ -30,7 +30,8 @@ class CwMwebPlugin: FlutterPlugin, MethodCallHandler {
|
|||
if (call.method == "start") {
|
||||
server?.stop()
|
||||
val dataDir = call.argument("dataDir") ?: ""
|
||||
server = server ?: Mwebd.newServer("", dataDir, "")
|
||||
val nodeUri = call.argument("nodeUri") ?: ""
|
||||
server = server ?: Mwebd.newServer("", dataDir, nodeUri)
|
||||
port = server?.start(0)
|
||||
result.success(port)
|
||||
} else if (call.method == "stop") {
|
||||
|
|
|
@ -12,6 +12,7 @@ public static func register(with registrar: FlutterPluginRegistrar) {
|
|||
private static var server: MwebdServer?
|
||||
private static var port: Int = 0
|
||||
private static var dataDir: String?
|
||||
private static var nodeUri: String?
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
|
@ -22,7 +23,9 @@ public static func register(with registrar: FlutterPluginRegistrar) {
|
|||
stopServer()
|
||||
let args = call.arguments as? [String: String]
|
||||
let dataDir = args?["dataDir"]
|
||||
let nodeUri = args?["nodeUri"]
|
||||
CwMwebPlugin.dataDir = dataDir
|
||||
CwMwebPlugin.nodeUri = nodeUri
|
||||
startServer(result: result)
|
||||
break
|
||||
case "stop":
|
||||
|
@ -48,7 +51,7 @@ public static func register(with registrar: FlutterPluginRegistrar) {
|
|||
private func startServer(result: @escaping FlutterResult) {
|
||||
if CwMwebPlugin.server == nil {
|
||||
var error: NSError?
|
||||
CwMwebPlugin.server = MwebdNewServer("", CwMwebPlugin.dataDir, "", &error)
|
||||
CwMwebPlugin.server = MwebdNewServer("", CwMwebPlugin.dataDir, CwMwebPlugin.nodeUri, &error)
|
||||
|
||||
if let server = CwMwebPlugin.server {
|
||||
do {
|
||||
|
|
|
@ -17,7 +17,8 @@ class CwMweb {
|
|||
await Future.delayed(const Duration(seconds: 5));
|
||||
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
_port = await CwMwebPlatform.instance.start(appDir.path);
|
||||
const ltcNodeUri = "45.79.13.180:9333";
|
||||
_port = await CwMwebPlatform.instance.start(appDir.path, ltcNodeUri);
|
||||
if (_port == null || _port == 0) {
|
||||
throw Exception("Failed to start server");
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@ class MethodChannelCwMweb extends CwMwebPlatform {
|
|||
final methodChannel = const MethodChannel('cw_mweb');
|
||||
|
||||
@override
|
||||
Future<int?> start(String dataDir) async {
|
||||
final result = await methodChannel.invokeMethod<int>('start', {'dataDir': dataDir});
|
||||
Future<int?> start(String dataDir, String nodeUri) async {
|
||||
final result =
|
||||
await methodChannel.invokeMethod<int>('start', {'dataDir': dataDir, 'nodeUri': nodeUri});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract class CwMwebPlatform extends PlatformInterface {
|
|||
_instance = instance;
|
||||
}
|
||||
|
||||
Future<int?> start(String dataDir) {
|
||||
Future<int?> start(String dataDir, String nodeUri) {
|
||||
throw UnimplementedError('start() has not been implemented.');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue