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; }