From 75f1f3f7cc77bc9982c41dd779d99392a91739ce Mon Sep 17 00:00:00 2001 From: leo1234 <leonid.ivanov@gmail.com> Date: Sat, 9 Mar 2024 19:04:12 +0800 Subject: [PATCH] removed the duplicate --- cw_zano/lib/api/api_calls.dart | 4 ++-- cw_zano/lib/zano_wallet.dart | 14 +------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/cw_zano/lib/api/api_calls.dart b/cw_zano/lib/api/api_calls.dart index e8cdc9804..65d80b933 100644 --- a/cw_zano/lib/api/api_calls.dart +++ b/cw_zano/lib/api/api_calls.dart @@ -23,7 +23,7 @@ typedef _IsWalletExist = int Function(Pointer<Utf8>); // void close_wallet(uint64_t hwallet) typedef _close_wallet = Void Function(Int64); -typedef _closeWalletStatus = void Function(int hWallet); +typedef _closeWallet = void Function(int hWallet); // uint64_t get_current_tx_fee(uint64_t priority) typedef _get_current_tx_fee = Int64 Function(Int64); @@ -157,7 +157,7 @@ class ApiCalls { return isExist; } - static final _closeWalletNative = zanoApi.lookup<NativeFunction<_close_wallet>>('close_wallet').asFunction<_closeWalletStatus>(); + static final _closeWalletNative = zanoApi.lookup<NativeFunction<_close_wallet>>('close_wallet').asFunction<_closeWallet>(); static void closeWallet({required int hWallet}) => _closeWalletNative(hWallet); diff --git a/cw_zano/lib/zano_wallet.dart b/cw_zano/lib/zano_wallet.dart index 71b2e4e7c..8417f6a44 100644 --- a/cw_zano/lib/zano_wallet.dart +++ b/cw_zano/lib/zano_wallet.dart @@ -465,25 +465,13 @@ abstract class ZanoWalletBase extends WalletBase<ZanoBalance, ZanoTransactionHis } } - final _loadWalletNative = zanoApi.lookup<NativeFunction<_load_wallet>>('load_wallet').asFunction<_LoadWallet>(); - String loadWallet(String path, String password) { print('load_wallet path $path password $password'); - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final result = _convertUTF8ToString( - pointer: _loadWalletNative(pathPointer, passwordPointer, 0), - ); + final result = ApiCalls.loadWallet(path: path, password: password); print('load_wallet result $result'); return result; } - String _convertUTF8ToString({required Pointer<Utf8> pointer}) { - final str = pointer.toDartString(); - calloc.free(pointer); - return str; - } - Future<String> invokeMethod(String methodName, Object params) async { var invokeResult = ApiCalls.asyncCall(methodName: 'invoke', hWallet: hWallet, params: '{"method": "$methodName","params": ${jsonEncode(params)}}'); var map = jsonDecode(invokeResult) as Map<String, dynamic>;