From 86f4e23e4d975f3f29944c3bb20b456e93fc665c Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Thu, 15 May 2025 09:02:52 +0200 Subject: [PATCH] fix(cw_monero): move isolates to top level functions so WalletBase will not get sent over. --- cw_monero/lib/monero_wallet_service.dart | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cw_monero/lib/monero_wallet_service.dart b/cw_monero/lib/monero_wallet_service.dart index c82905d4a..45a0a70d6 100644 --- a/cw_monero/lib/monero_wallet_service.dart +++ b/cw_monero/lib/monero_wallet_service.dart @@ -224,19 +224,7 @@ class MoneroWalletService extends WalletService< final wmaddr = wmPtr.ffiAddress(); final waddr = w.ffiAddress(); openedWalletsByPath.remove("$path/$wallet"); - if (Platform.isWindows) { - await Isolate.run(() { - monero.WalletManager_closeWallet( - Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true); - monero.WalletManager_errorString(Pointer.fromAddress(wmaddr)); - }); - } else { - unawaited(Isolate.run(() { - monero.WalletManager_closeWallet( - Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true); - monero.WalletManager_errorString(Pointer.fromAddress(wmaddr)); - })); - } + await closeWalletAwaitIfShould(wmaddr, waddr); printV("wallet closed"); } @@ -570,3 +558,19 @@ class MoneroWalletService extends WalletService< false; } } + +Future closeWalletAwaitIfShould(int wmaddr, int waddr) async { + if (Platform.isWindows) { + await Isolate.run(() { + monero.WalletManager_closeWallet( + Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true); + monero.WalletManager_errorString(Pointer.fromAddress(wmaddr)); + }); + } else { + unawaited(Isolate.run(() { + monero.WalletManager_closeWallet( + Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true); + monero.WalletManager_errorString(Pointer.fromAddress(wmaddr)); + })); + } +} \ No newline at end of file