From 09b02f9b0b015115685ffc2ee753fdab21f05aad Mon Sep 17 00:00:00 2001
From: Czarek Nakamoto <cyjan@mrcyjanek.net>
Date: Sun, 10 Nov 2024 22:10:19 -0500
Subject: [PATCH] move async call to a synchronouse one

---
 cw_zano/lib/zano_wallet_api.dart | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/cw_zano/lib/zano_wallet_api.dart b/cw_zano/lib/zano_wallet_api.dart
index bb82b3c4e..81d6b1afd 100644
--- a/cw_zano/lib/zano_wallet_api.dart
+++ b/cw_zano/lib/zano_wallet_api.dart
@@ -84,7 +84,11 @@ mixin ZanoWalletApi {
 
   Future<String> invokeMethod(String methodName, Object params) async {
     var invokeResult =
-        zano.PlainWallet_asyncCall('invoke', hWallet, '{"method": "$methodName","params": ${jsonEncode(params)}}');
+        zano.PlainWallet_syncCall('invoke', hWallet, jsonEncode(
+          {
+            "method": "$methodName",
+            "params": params,
+          }));
     Map<String, dynamic> map;
     try {
       map = jsonDecode(invokeResult) as Map<String, dynamic>;
@@ -93,24 +97,6 @@ mixin ZanoWalletApi {
       error('exception in parsing json in invokeMethod: $invokeResult');
       rethrow;
     }
-    int attempts = 0;
-    if (map['job_id'] != null) {
-      final jobId = map['job_id'] as int;
-      do {
-        await Future.delayed(Duration(milliseconds: attempts < 2 ? 100 : 500));
-        final result = zano.PlainWallet_tryPullResult(jobId);
-        try {
-          map = jsonDecode(result) as Map<String, dynamic>;
-        } catch (e) {
-          if (result.contains(Consts.errorWalletWrongId)) throw ZanoWalletException('Wrong wallet id');
-          error('exception in parsing json in invokeMethod: $result');
-          rethrow;
-        }
-        if (map['status'] != null && map['status'] == _statusDelivered && map['result'] != null) {
-          return result;
-        }
-      } while (++attempts < _maxInvokeAttempts);
-    }
     return invokeResult;
   }