From bea81d2c672e114a047be16fe4196063c5b35f19 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Mon, 11 Nov 2024 08:30:32 -0500 Subject: [PATCH] call sync call in isolate to make it async generate framework for iOS as well fix UR issues --- .../lib/model/pending_zano_transaction.dart | 5 +++ cw_zano/lib/zano_wallet_api.dart | 33 ++++++++++++++---- ios/.gitignore | 4 ++- ios/ZanoWallet.framework/Info.plist | Bin 0 -> 802 bytes lib/main.dart | 2 +- scripts/ios/gen_framework.sh | 16 +++++++++ 6 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 ios/ZanoWallet.framework/Info.plist diff --git a/cw_zano/lib/model/pending_zano_transaction.dart b/cw_zano/lib/model/pending_zano_transaction.dart index 2addbdb31..001ec2cd1 100644 --- a/cw_zano/lib/model/pending_zano_transaction.dart +++ b/cw_zano/lib/model/pending_zano_transaction.dart @@ -44,4 +44,9 @@ class PendingZanoTransaction with PendingTransaction { await zanoWallet.transfer(destinations, fee, comment); zanoWallet.fetchTransactions(); } + + @override + Future commitUR() { + throw UnimplementedError(); + } } diff --git a/cw_zano/lib/zano_wallet_api.dart b/cw_zano/lib/zano_wallet_api.dart index 81d6b1afd..ffad15b2c 100644 --- a/cw_zano/lib/zano_wallet_api.dart +++ b/cw_zano/lib/zano_wallet_api.dart @@ -1,4 +1,5 @@ import 'dart:convert' as convert; +import 'dart:isolate'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_zano/api/consts.dart'; @@ -21,6 +22,7 @@ import 'package:cw_zano/zano_wallet_exceptions.dart'; import 'package:flutter/foundation.dart'; import 'package:json_bigint/json_bigint.dart'; import 'package:monero/zano.dart' as zano; +import 'package:monero/src/generated_bindings_zano.g.dart' as zanoapi; mixin ZanoWalletApi { static const _defaultNodeUri = '195.201.107.230:33336'; @@ -83,12 +85,31 @@ mixin ZanoWalletApi { } Future invokeMethod(String methodName, Object params) async { - var invokeResult = - zano.PlainWallet_syncCall('invoke', hWallet, jsonEncode( - { - "method": "$methodName", - "params": params, - })); + + // var invokeResult = zano.PlainWallet_syncCall( + // 'invoke', + // hWallet, + // jsonEncode( + // { + // "method": "$methodName", + // "params": params, + // }, + // ), + // ); + final request = jsonEncode({ + "method": methodName, + "params": params, + }); + print("zano: >>> $request"); + var invokeResult = await Isolate.run(() { + final ret = zano.PlainWallet_syncCall( + 'invoke', + hWallet, + request, + ); + return ret; + }); + print("zano: <<< ${invokeResult}"); Map map; try { map = jsonDecode(invokeResult) as Map; diff --git a/ios/.gitignore b/ios/.gitignore index 8ded86f14..b0f4c2299 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -31,4 +31,6 @@ Runner/GeneratedPluginRegistrant.* !default.pbxuser !default.perspectivev3 -Mwebd.xcframework \ No newline at end of file +Mwebd.xcframework +ZanoWallet +zano_libwallet2_api_c.dylib diff --git a/ios/ZanoWallet.framework/Info.plist b/ios/ZanoWallet.framework/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..c430c096e537f3c24961842c4d7474422ae99a7f GIT binary patch literal 802 zcmZWlOHb5L6u$QeI^u&npa>&~^6+hK%PTGn33Ny%gom`ujD*nKY3~eIZhLE|C9?1j zXbf@V!i5PWZe6+aAGq-+7*}rm18$6+G8Gc<=A3)Z`M&d=uNDa2j8yeI>BDfUqx1Bc z+}W;k=Pz9BCi$M;OPBku^bZuS4h~%#zJ6nLZ2ac!J9i%_4-1>~3v;pW3bsr=_SCRU zW3iQ046Eu$mu;k#xtI&rCIi{5!FHLDfyex4jWxLRZPK0f$}DWAmEIJ!M4fH!vlTP_ zZ5h_8piy0hUTcd@dNbH6b#`cjS$jcJEo4=5TZU1a(TqawH%>O=AV}KG%_y5T8Oo3) zzb*~#M2Qp{?)?+hll6-)m=i~|CR!)XOE2Jpg*F*nFRiiXF%OxW9LXIvPXk)xf=8Ss z^kj+q+>5;x^MA&Yo7lnYoP}HKr6ceH^|;uxN&fikHg2=+Z`;{?Cd=dvpGI+*n9zL; zN~bn9s4pv22o`PfU|af3HnkaL($c0T)UvJ>bxmDk{u8aNPZV{1vYHK93rm$nQ&ZG~ zkt$zp0ar|OT2W6B+GNC$oNgb4Ru68i)6knv7A9bu^tTXo z8A&0XolrSecX;nU!33<9xQaGa)YVC9&d$!F9GXD}T1I6=(Mzc!zhe{0y;c~8o2NbB)oz*un%wH9ehCP O1AG*b+K%l2hkpS-#`e7c literal 0 HcmV?d00001 diff --git a/lib/main.dart b/lib/main.dart index 51fab4dd1..b6e79c173 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -204,7 +204,7 @@ Future initializeAppConfigs() async { transactionDescriptions: transactionDescriptions, secureStorage: secureStorage, anonpayInvoiceInfo: anonpayInvoiceInfo, - initialMigrationVersion: 43, + initialMigrationVersion: 44, ); } diff --git a/scripts/ios/gen_framework.sh b/scripts/ios/gen_framework.sh index 5c9bcd228..e9cc44801 100755 --- a/scripts/ios/gen_framework.sh +++ b/scripts/ios/gen_framework.sh @@ -29,3 +29,19 @@ cd $FRWK_DIR # go to iOS framework dir lipo -create $DYLIB_LINK_PATH -output WowneroWallet echo "Generated ${FRWK_DIR}" + +# also generate for zano +IOS_DIR="$(pwd)/../../ios" +DYLIB_NAME="zano_libwallet2_api_c.dylib" +DYLIB_LINK_PATH="${IOS_DIR}/${DYLIB_NAME}" +FRWK_DIR="${IOS_DIR}/ZanoWallet.framework" + +if [ ! -f $DYLIB_LINK_PATH ]; then + echo "Dylib is not found by the link: ${DYLIB_LINK_PATH}" + exit 0 +fi + +cd $FRWK_DIR # go to iOS framework dir +lipo -create $DYLIB_LINK_PATH -output ZanoWallet + +echo "Generated ${FRWK_DIR}"