diff --git a/.github/workflows/pr_test_build_android.yml b/.github/workflows/pr_test_build_android.yml index c55148f4c..b40798cd9 100644 --- a/.github/workflows/pr_test_build_android.yml +++ b/.github/workflows/pr_test_build_android.yml @@ -219,6 +219,17 @@ jobs: popd cp /opt/generic_cache/key.jks android/app + - name: Fetch prebuilt Torch + run: | + set -x -e + pushd scripts + wget https://github.com/MrCyjaneK/torch_dart/releases/download/4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653/torch_dart-4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653.tar.gz -O torch_dart.tar.gz + mkdir torch_dart + pushd torch_dart + tar -xzf ../torch_dart.tar.gz + popd + popd + - name: Execute Build and Setup Commands run: | pushd scripts/android diff --git a/.github/workflows/pr_test_build_linux.yml b/.github/workflows/pr_test_build_linux.yml index 6a5e10ee3..8c823a504 100644 --- a/.github/workflows/pr_test_build_linux.yml +++ b/.github/workflows/pr_test_build_linux.yml @@ -203,6 +203,17 @@ jobs: ln -sf "$MONEROC_CACHE_DIR_ROOT/_cache/wownero/contrib/depends/sources" "$PWD/wownero/contrib/depends/sources" popd + - name: Fetch prebuilt Torch + run: | + set -x -e + pushd scripts + wget https://github.com/MrCyjaneK/torch_dart/releases/download/4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653/torch_dart-4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653.tar.gz -O torch_dart.tar.gz + mkdir torch_dart + pushd torch_dart + tar -xzf ../torch_dart.tar.gz + popd + popd + - name: Execute Build and Setup Commands run: | pushd scripts/linux diff --git a/.gitignore b/.gitignore index 9482d8f94..38e6596f3 100644 --- a/.gitignore +++ b/.gitignore @@ -228,3 +228,5 @@ flatpak-build/ **/linux/flutter/generated_plugin_registrant.cc **/linux/flutter/generated_plugin_registrant.h **/linux/flutter/generated_plugins.cmake + +scripts/torch_dart/ \ No newline at end of file diff --git a/cw_bitcoin/pubspec.lock b/cw_bitcoin/pubspec.lock index 16186c22a..139088655 100644 --- a/cw_bitcoin/pubspec.lock +++ b/cw_bitcoin/pubspec.lock @@ -1061,15 +1061,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 7f691f955..ddccceddc 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -274,14 +274,14 @@ class Node extends HiveObject with Keyable { } Future requestNodeWithProxy() async { - if (!isValidProxyAddress && !CakeTor.instance.enabled) { + if (!isValidProxyAddress && !CakeTor.instance!.enabled) { return false; } String? proxy = socksProxyAddress; - if ((proxy?.isEmpty ?? true) && CakeTor.instance.enabled) { - proxy = "${InternetAddress.loopbackIPv4.address}:${CakeTor.instance.port}"; + if ((proxy?.isEmpty ?? true) && CakeTor.instance!.enabled) { + proxy = "${InternetAddress.loopbackIPv4.address}:${CakeTor.instance!.port}"; } printV("proxy: $proxy"); if (proxy == null) { diff --git a/cw_core/lib/utils/proxy_socket/abstract.dart b/cw_core/lib/utils/proxy_socket/abstract.dart index 9c6019a5c..c22bce3bc 100644 --- a/cw_core/lib/utils/proxy_socket/abstract.dart +++ b/cw_core/lib/utils/proxy_socket/abstract.dart @@ -17,10 +17,10 @@ class ProxyAddress { abstract class ProxySocket { static Future connect(bool sslEnabled, ProxyAddress address, {Duration? connectionTimeout}) async { - if (CakeTor.instance.started) { + if (CakeTor.instance!.started) { var socksSocket = await SOCKSSocket.create( proxyHost: InternetAddress.loopbackIPv4.address, - proxyPort: CakeTor.instance.port, + proxyPort: CakeTor.instance!.port, sslEnabled: sslEnabled, ); await socksSocket.connect(); diff --git a/cw_core/lib/utils/proxy_wrapper.dart b/cw_core/lib/utils/proxy_wrapper.dart index 5a838818b..55d84d7a4 100644 --- a/cw_core/lib/utils/proxy_wrapper.dart +++ b/cw_core/lib/utils/proxy_wrapper.dart @@ -5,8 +5,6 @@ import 'dart:typed_data'; import 'package:cw_core/utils/proxy_logger/abstract.dart'; import 'package:cw_core/utils/proxy_socket/abstract.dart'; import 'package:cw_core/utils/tor/abstract.dart'; -import 'package:cw_core/utils/tor/android.dart'; -import 'package:cw_core/utils/tor/disabled.dart'; import 'package:http/http.dart'; import 'package:socks5_proxy/socks_client.dart'; import 'package:http/io_client.dart' as ioc; @@ -37,7 +35,7 @@ class ProxyWrapper { } RequestNetwork requestNetwork() { - return CakeTor.instance.started ? RequestNetwork.tor : RequestNetwork.clearnet; + return CakeTor.instance!.started ? RequestNetwork.tor : RequestNetwork.clearnet; } ioc.IOClient getHttpIOClient({int? portOverride, bool internal = false}) { @@ -56,7 +54,7 @@ class ProxyWrapper { return ioc.IOClient(httpClient); } - int getPort() => CakeTor.instance.port; + int getPort() => CakeTor.instance!.port; @Deprecated('Use ProxyWrapper().get/post/put methods instead, and provide proper clearnet and onion uri.') HttpClient getHttpClient({int? portOverride, bool internal = false}) { @@ -70,13 +68,13 @@ class ProxyWrapper { error: null ); } - if (CakeTor.instance.started) { + if (CakeTor.instance!.started) { // Assign connection factory. final client = HttpClient(); SocksTCPClient.assignToHttpClient(client, [ ProxySettings( InternetAddress.loopbackIPv4, - CakeTor.instance.port, + CakeTor.instance!.port, password: null, ), ]); @@ -154,9 +152,9 @@ class ProxyWrapper { Uri? onionUri, }) async { ioc.IOClient? torClient; - bool torEnabled = CakeTor.instance.started; + bool torEnabled = CakeTor.instance!.started; - if (CakeTor.instance.started) { + if (CakeTor.instance!.started) { torEnabled = true; } else { torEnabled = false; @@ -238,7 +236,7 @@ class ProxyWrapper { ioc.IOClient clearnetClient = ioc.IOClient(cleatnetHttpClient); - bool torEnabled = CakeTor.instance.started; + bool torEnabled = CakeTor.instance!.started; if (torEnabled) { try { @@ -309,7 +307,7 @@ class ProxyWrapper { String? body, }) async { ioc.IOClient? torClient; - bool torEnabled = CakeTor.instance.started; + bool torEnabled = CakeTor.instance!.started; if (torEnabled) { try { @@ -375,9 +373,9 @@ class ProxyWrapper { Uri? onionUri, }) async { ioc.IOClient? torClient; - bool torEnabled = CakeTor.instance.started; + bool torEnabled = CakeTor.instance!.started; - if (CakeTor.instance.started) { + if (CakeTor.instance!.started) { torEnabled = true; } else { torEnabled = false; @@ -443,5 +441,5 @@ class ProxyWrapper { class CakeTor { - static final CakeTorInstance instance = CakeTorInstance.getInstance(); + static CakeTorInstance? instance; } diff --git a/cw_core/lib/utils/tor/abstract.dart b/cw_core/lib/utils/tor/abstract.dart index aeaf37cae..6fc4016a3 100644 --- a/cw_core/lib/utils/tor/abstract.dart +++ b/cw_core/lib/utils/tor/abstract.dart @@ -1,9 +1,9 @@ import 'dart:io'; import 'package:cw_core/utils/print_verbose.dart'; -import 'package:cw_core/utils/tor/android.dart'; import 'package:cw_core/utils/tor/disabled.dart'; import 'package:cw_core/utils/tor/socks.dart'; +import 'package:cw_core/utils/tor/torch.dart'; abstract class CakeTorInstance { bool get started; @@ -17,10 +17,7 @@ abstract class CakeTorInstance { Future start(); Future stop(); - static CakeTorInstance getInstance() { - if (Platform.isAndroid) { - return CakeTorAndroid(); - } + static Future getInstance() async { if (Platform.isLinux) { try { String? socksServer; @@ -46,6 +43,14 @@ abstract class CakeTorInstance { printV("Failed to identify linux version - /etc/os-release missing"); } } + try { + final torch = await CakeTorTorch.getInstance(); + if (torch != null) { + return torch; + } + } catch (e) { + printV("Failed to initialize torch: $e"); + } return CakeTorDisabled(); } diff --git a/cw_core/lib/utils/tor/android.dart b/cw_core/lib/utils/tor/torch.dart similarity index 52% rename from cw_core/lib/utils/tor/android.dart rename to cw_core/lib/utils/tor/torch.dart index ead0a015e..914662759 100644 --- a/cw_core/lib/utils/tor/android.dart +++ b/cw_core/lib/utils/tor/torch.dart @@ -1,18 +1,32 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'dart:isolate'; import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/utils/tor/abstract.dart'; import 'package:path_provider/path_provider.dart'; import 'package:path/path.dart' as p; -import 'package:tor_binary/tor_binary_platform_interface.dart'; +import 'package:torch_dart/abstract_tor.dart'; -class CakeTorAndroid implements CakeTorInstance { - @override - bool get bootstrapped => _proc != null; +class CakeTorTorch implements CakeTorInstance { + final List _torList; + + CakeTorTorch(this._torList); + + static Future getInstance() async { + final list = await Tor.getTorList(); + if (list.isEmpty) { + return null; + } + return CakeTorTorch(list); + } @override - bool get enabled => _proc != null; + bool get bootstrapped => isTorRunning; + + @override + bool get enabled => isTorRunning; @override int get port => 42142; @@ -23,63 +37,54 @@ class CakeTorAndroid implements CakeTorInstance { } @override - bool get started => _proc != null; + bool started = false; + + static bool isTorRunning = false; @override Future stop() async { - _proc?.kill(); - await _proc?.exitCode; - _proc = null; + started = false; } - static Process? _proc; - Future _runEmbeddedTor() async { final dir = await getApplicationCacheDirectory(); - final torBinPath = p.join((await TorBinaryPlatform.instance.getBinaryPath())!, "libtor.so"); - printV("torPath: $torBinPath"); + final torList = await Tor.getTorList(); + printV("tor version: ${torList.first.version}"); - if (started) { + if (isTorRunning) { + started = true; printV("Proxy is running"); return; } + isTorRunning = true; + started = true; printV("Starting embedded tor"); printV("app docs: $dir"); final torrc = """ SocksPort $port -Log notice file ${p.join(dir.path, "tor.log")} +Log notice stdout RunAsDaemon 0 DataDirectory ${p.join(dir.path, "tor-data")} """; final torrcPath = p.join(dir.absolute.path, "torrc"); File(torrcPath).writeAsStringSync(torrc); - if (_proc != null) { - try { - _proc?.kill(); - await _proc?.exitCode; - _proc = null; - } catch (e) { - printV(e); - } - } - printV("path: $torBinPath -f $torrcPath"); - _proc = await Process.start(torBinPath, ["-f", torrcPath]); - _proc?.stdout.transform(utf8.decoder).forEach(printV); - _proc?.stderr.transform(utf8.decoder).forEach(printV); + final tor = _torList.first; + tor.start(["nonexistent", "-f", torrcPath]); } @override String toString() { return """ -CakeTorAndroid( +CakeTorTorch( port: $port, started: $started, bootstrapped: $bootstrapped, enabled: $enabled, - proc: $_proc, + torList: + - ${_torList.map((e) => e.version).join(",\n - ")} ) """; } diff --git a/cw_core/pubspec.lock b/cw_core/pubspec.lock index d7bfdbe2a..5603cf6f3 100644 --- a/cw_core/pubspec.lock +++ b/cw_core/pubspec.lock @@ -730,15 +730,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tor_binary: + torch_dart: dependency: "direct main" description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -828,5 +826,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.27.0" diff --git a/cw_core/pubspec.yaml b/cw_core/pubspec.yaml index 07f87475a..2d61a0002 100644 --- a/cw_core/pubspec.yaml +++ b/cw_core/pubspec.yaml @@ -38,10 +38,8 @@ dependencies: git: url: https://github.com/sneurlax/socks_socket ref: e6232c53c1595469931ababa878759a067c02e94 - tor_binary: - git: - url: https://github.com/MrCyjaneK/flutter-tor_binary - ref: cb811c610871a9517d47134b87c2f590c15c96c5 + torch_dart: + path: ../scripts/torch_dart dev_dependencies: flutter_test: diff --git a/cw_decred/pubspec.lock b/cw_decred/pubspec.lock index f7a5f335d..6a7a1024c 100644 --- a/cw_decred/pubspec.lock +++ b/cw_decred/pubspec.lock @@ -761,15 +761,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -867,5 +865,5 @@ packages: source: hosted version: "2.2.2" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.24.0" diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index e547f5403..91096593c 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -229,12 +229,12 @@ abstract class MoneroWalletBase extends WalletBase connectToNode({required Node node}) async { String socksProxy = node.socksProxyAddress ?? ''; - printV("bootstrapped: ${CakeTor.instance.bootstrapped}"); - printV(" enabled: ${CakeTor.instance.enabled}"); - printV(" port: ${CakeTor.instance.port}"); - printV(" started: ${CakeTor.instance.started}"); - if (CakeTor.instance.enabled) { - socksProxy = "127.0.0.1:${CakeTor.instance.port}"; + printV("bootstrapped: ${CakeTor.instance!.bootstrapped}"); + printV(" enabled: ${CakeTor.instance!.enabled}"); + printV(" port: ${CakeTor.instance!.port}"); + printV(" started: ${CakeTor.instance!.started}"); + if (CakeTor.instance!.enabled) { + socksProxy = "127.0.0.1:${CakeTor.instance!.port}"; } try { syncStatus = ConnectingSyncStatus(); diff --git a/cw_monero/pubspec.lock b/cw_monero/pubspec.lock index 911d01144..46670462d 100644 --- a/cw_monero/pubspec.lock +++ b/cw_monero/pubspec.lock @@ -874,15 +874,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -996,5 +994,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.24.0" diff --git a/cw_nano/pubspec.lock b/cw_nano/pubspec.lock index aa85d6dde..bf393afba 100644 --- a/cw_nano/pubspec.lock +++ b/cw_nano/pubspec.lock @@ -879,15 +879,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -977,5 +975,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.27.0" diff --git a/cw_wownero/lib/wownero_wallet.dart b/cw_wownero/lib/wownero_wallet.dart index a90d32ee3..f068ec492 100644 --- a/cw_wownero/lib/wownero_wallet.dart +++ b/cw_wownero/lib/wownero_wallet.dart @@ -203,12 +203,12 @@ abstract class WowneroWalletBase @override Future connectToNode({required Node node}) async { String socksProxy = node.socksProxyAddress ?? ''; - printV("bootstrapped: ${CakeTor.instance.bootstrapped}"); - printV(" enabled: ${CakeTor.instance.enabled}"); - printV(" port: ${CakeTor.instance.port}"); - printV(" started: ${CakeTor.instance.started}"); - if (CakeTor.instance.enabled) { - socksProxy = "127.0.0.1:${CakeTor.instance.port}"; + printV("bootstrapped: ${CakeTor.instance!.bootstrapped}"); + printV(" enabled: ${CakeTor.instance!.enabled}"); + printV(" port: ${CakeTor.instance!.port}"); + printV(" started: ${CakeTor.instance!.started}"); + if (CakeTor.instance!.enabled) { + socksProxy = "127.0.0.1:${CakeTor.instance!.port}"; } try { syncStatus = ConnectingSyncStatus(); diff --git a/cw_wownero/pubspec.lock b/cw_wownero/pubspec.lock index 491f65e54..69c00436e 100644 --- a/cw_wownero/pubspec.lock +++ b/cw_wownero/pubspec.lock @@ -778,15 +778,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -876,5 +874,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.24.0" diff --git a/cw_zano/pubspec.lock b/cw_zano/pubspec.lock index f31862441..255a95555 100644 --- a/cw_zano/pubspec.lock +++ b/cw_zano/pubspec.lock @@ -775,15 +775,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - tor_binary: + torch_dart: dependency: transitive description: - path: "." - ref: cb811c610871a9517d47134b87c2f590c15c96c5 - resolved-ref: cb811c610871a9517d47134b87c2f590c15c96c5 - url: "https://github.com/MrCyjaneK/flutter-tor_binary" - source: git - version: "4.7.14" + path: "../scripts/torch_dart" + relative: true + source: path + version: "0.0.1" tuple: dependency: transitive description: @@ -873,5 +871,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.6.2 <4.0.0" flutter: ">=3.24.0" diff --git a/docs/builds/ANDROID.md b/docs/builds/ANDROID.md index 2461df4bd..38d7a2f15 100644 --- a/docs/builds/ANDROID.md +++ b/docs/builds/ANDROID.md @@ -22,6 +22,7 @@ cd cake_wallet docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-ndkr28-go1.24.1-ruststablenightly bash -x << EOF set -x -e pushd scripts/android + ./build_torch.sh source ./app_env.sh cakewallet # source ./app_env.sh monero.com # Uncomment this line to build monero.com ./app_config.sh diff --git a/ios/Podfile.lock b/ios/Podfile.lock index abbd40673..5d997f8df 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -43,6 +43,7 @@ PODS: - DKPhotoGallery/Resource (0.0.19): - SDWebImage - SwiftyGif + - dnssec_proof (0.0.1) - fast_scanner (5.1.1): - Flutter - file_picker (0.0.1): @@ -66,6 +67,8 @@ PODS: - Flutter - fluttertoast (0.0.2): - Flutter + - image_picker_ios (0.0.1): + - Flutter - in_app_review (2.0.0): - Flutter - integration_test (0.0.1): @@ -95,6 +98,8 @@ PODS: - sp_scanner (0.0.1): - Flutter - SwiftyGif (5.4.5) + - torch_dart (0.0.1): + - Flutter - uni_links (0.0.1): - Flutter - universal_ble (0.0.1): @@ -114,6 +119,7 @@ DEPENDENCIES: - device_display_brightness (from `.symlinks/plugins/device_display_brightness/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - devicelocale (from `.symlinks/plugins/devicelocale/ios`) + - dnssec_proof (from `.symlinks/plugins/dnssec_proof/ios`) - fast_scanner (from `.symlinks/plugins/fast_scanner/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) @@ -123,6 +129,7 @@ DEPENDENCIES: - flutter_mailer (from `.symlinks/plugins/flutter_mailer/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) + - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - in_app_review (from `.symlinks/plugins/in_app_review/ios`) - integration_test (from `.symlinks/plugins/integration_test/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) @@ -134,6 +141,7 @@ DEPENDENCIES: - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sp_scanner (from `.symlinks/plugins/sp_scanner/ios`) + - torch_dart (from `.symlinks/plugins/torch_dart/ios`) - uni_links (from `.symlinks/plugins/uni_links/ios`) - universal_ble (from `.symlinks/plugins/universal_ble/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) @@ -162,6 +170,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/device_info_plus/ios" devicelocale: :path: ".symlinks/plugins/devicelocale/ios" + dnssec_proof: + :path: ".symlinks/plugins/dnssec_proof/ios" fast_scanner: :path: ".symlinks/plugins/fast_scanner/ios" file_picker: @@ -180,6 +190,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_secure_storage/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" + image_picker_ios: + :path: ".symlinks/plugins/image_picker_ios/ios" in_app_review: :path: ".symlinks/plugins/in_app_review/ios" integration_test: @@ -202,6 +214,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sp_scanner: :path: ".symlinks/plugins/sp_scanner/ios" + torch_dart: + :path: ".symlinks/plugins/torch_dart/ios" uni_links: :path: ".symlinks/plugins/uni_links/ios" universal_ble: @@ -212,42 +226,45 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/wakelock_plus/ios" SPEC CHECKSUMS: - connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d + connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd CryptoSwift: e64e11850ede528a02a0f3e768cec8e9d92ecb90 - cw_decred: 9c0e1df74745b51a1289ec5e91fb9e24b68fa14a - cw_mweb: 22cd01dfb8ad2d39b15332006f22046aaa8352a3 - device_display_brightness: 1510e72c567a1f6ce6ffe393dcd9afd1426034f7 - device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 - devicelocale: 35ba84dc7f45f527c3001535d8c8d104edd5d926 + cw_decred: a02cf30175a46971c1e2fa22c48407534541edc6 + cw_mweb: 3aea2fb35b2bd04d8b2d21b83216f3b8fb768d85 + device_display_brightness: 04374ebd653619292c1d996f00f42877ea19f17f + device_info_plus: 335f3ce08d2e174b9fdc3db3db0f4e3b1f66bd89 + devicelocale: bd64aa714485a8afdaded0892c1e7d5b7f680cf8 DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60 - fast_scanner: 44c00940355a51258cd6c2085734193cd23d95bc - file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655 + dnssec_proof: d461cac7bd3301eb7447f87936745a0c1ae0a67e + fast_scanner: 2cb1ad3e69e645e9980fb4961396ce5804caa3e3 + file_picker: 9b3292d7c8bc68c8a7bf8eb78f730e49c8efc517 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4 - flutter_local_authentication: 1172a4dd88f6306dadce067454e2c4caf07977bb - flutter_local_notifications: ff50f8405aaa0ccdc7dcfb9022ca192e8ad9688f - flutter_mailer: 2ef5a67087bc8c6c4cefd04a178bf1ae2c94cd83 - flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be - fluttertoast: 21eecd6935e7064cc1fcb733a4c5a428f3f24f0f - in_app_review: a31b5257259646ea78e0e35fc914979b0031d011 - integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573 + flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99 + flutter_local_authentication: 989278c681612f1ee0e36019e149137f114b9d7f + flutter_local_notifications: a5a732f069baa862e728d839dd2ebb904737effb + flutter_mailer: 3a8cd4f36c960fb04528d5471097270c19fec1c4 + flutter_secure_storage: 2c2ff13db9e0a5647389bff88b0ecac56e3f3418 + fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1 + image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a + in_app_review: 5596fe56fab799e8edb3561c03d053363ab13457 + integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 - package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 + path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 payjoin_flutter: d9d4c8aa16bd5dfedb9b21d0edc8199e0187d96e - permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 - reown_yttrium: c0e87e5965fa60a3559564cc35cffbba22976089 + permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d + reown_yttrium: cee334ade64725b1d83f7b34c706a6aae2696d58 SDWebImage: 73c6079366fea25fa4bb9640d5fb58f0893facd8 - sensitive_clipboard: d4866e5d176581536c27bb1618642ee83adca986 - share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f - shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 - sp_scanner: eaa617fa827396b967116b7f1f43549ca62e9a12 + sensitive_clipboard: 161e9abc3d56b3131309d8a321eb4690a803c16b + share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a + shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 + sp_scanner: b1bc9321690980bdb44bba7ec85d5543e716d1b5 SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 - uni_links: d97da20c7701486ba192624d99bffaaffcfc298a - universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6 - url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe - wakelock_plus: 76957ab028e12bfa4e66813c99e46637f367fc7e + torch_dart: f4620705d10f05492fab047f2fa1c3a600e7d17d + uni_links: ed8c961e47ed9ce42b6d91e1de8049e38a4b3152 + universal_ble: ff19787898040d721109c6324472e5dd4bc86adc + url_launcher_ios: 694010445543906933d732453a59da0a173ae33d + wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556 YttriumWrapper: 31e937fe9fbe0f1314d2ca6be9ce9b379a059966 PODFILE CHECKSUM: 5296465b1c6d14d506230356756826012f65d97a diff --git a/lib/main.dart b/lib/main.dart index 9ce76113d..2433f269f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,6 +47,7 @@ import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/utils/proxy_logger/memory_proxy_logger.dart'; import 'package:cw_core/utils/proxy_wrapper.dart'; +import 'package:cw_core/utils/tor/abstract.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/foundation.dart'; @@ -85,6 +86,11 @@ Future runAppWithZone({Key? topLevelKey}) async { return true; }; await FlutterDaemon().unmarkBackgroundSync(); + try { + CakeTor.instance = await CakeTorInstance.getInstance(); + } catch (e) { + printV("Failed to initialize tor: $e"); + } await initializeAppAtRoot(); if (kDebugMode) { diff --git a/lib/src/screens/wallet_connect/wc_pairing_detail_page.dart b/lib/src/screens/wallet_connect/wc_pairing_detail_page.dart index a109fa9f3..44f0681bd 100644 --- a/lib/src/screens/wallet_connect/wc_pairing_detail_page.dart +++ b/lib/src/screens/wallet_connect/wc_pairing_detail_page.dart @@ -155,7 +155,7 @@ class WCCDetailsWidget extends BasePage { backgroundImage: (pairing.peerMetadata!.icons.isNotEmpty ? NetworkImage(pairing.peerMetadata!.icons[0]) : AssetImage( - CakeTor.instance.enabled + CakeTor.instance!.enabled ? 'assets/images/tor_logo.svg' : 'assets/images/app_logo.png')) as ImageProvider, ), diff --git a/lib/src/widgets/provider_optoin_tile.dart b/lib/src/widgets/provider_optoin_tile.dart index be6873975..b7929bbea 100644 --- a/lib/src/widgets/provider_optoin_tile.dart +++ b/lib/src/widgets/provider_optoin_tile.dart @@ -267,7 +267,7 @@ class Badge extends StatelessWidget { Widget getImage(String imagePath, {double? height, double? width, Color? imageColor}) { bool isNetworkImage = imagePath.startsWith('http') || imagePath.startsWith('https'); - if (CakeTor.instance.enabled && isNetworkImage) { + if (CakeTor.instance!.enabled && isNetworkImage) { imagePath = "assets/images/tor_logo.svg"; isNetworkImage = false; } diff --git a/lib/utils/feature_flag.dart b/lib/utils/feature_flag.dart index e6afeb846..661595a41 100644 --- a/lib/utils/feature_flag.dart +++ b/lib/utils/feature_flag.dart @@ -8,7 +8,7 @@ class FeatureFlag { static const bool isCakePayRedemptionFlowEnabled = false; static const bool isExolixEnabled = true; static const bool isBackgroundSyncEnabled = true; - static final bool isInAppTorEnabled = CakeTor.instance is! CakeTorDisabled; + static bool get isInAppTorEnabled => CakeTor.instance is! CakeTorDisabled; static const int verificationWordsCount = kDebugMode ? 0 : 2; static const bool hasDevOptions = bool.fromEnvironment('hasDevOptions', defaultValue: kDebugMode); static const bool hasBitcoinViewOnly = true; diff --git a/lib/utils/image_utill.dart b/lib/utils/image_utill.dart index 29cee5e0f..51525bdfc 100644 --- a/lib/utils/image_utill.dart +++ b/lib/utils/image_utill.dart @@ -13,7 +13,7 @@ class ImageUtil { }) { bool isNetworkImage = imagePath.startsWith('http') || imagePath.startsWith('https'); - if (CakeTor.instance.enabled && isNetworkImage) { + if (CakeTor.instance!.enabled && isNetworkImage) { imagePath = "assets/images/tor_logo.svg"; isNetworkImage = false; } diff --git a/lib/utils/tor.dart b/lib/utils/tor.dart index 72b72334a..877d216b0 100644 --- a/lib/utils/tor.dart +++ b/lib/utils/tor.dart @@ -15,7 +15,7 @@ Future ensureTorStopped({required BuildContext? context}) async { if (context != null) dialogContext = await showFullscreenDialog(context); didTorStart = false; printV("Stopping tor"); - await CakeTor.instance.stop(); + await CakeTor.instance!.stop(); printV("Tor stopped"); if (context != null) dismissFullscreenDialog(dialogContext!); } @@ -32,20 +32,20 @@ Future ensureTorStarted({required BuildContext? context}) async { // var rootToken = RootIsolateToken.instance!; // await Isolate.run(() async { // BackgroundIsolateBinaryMessenger.ensureInitialized(rootToken); - // await CakeTor.instance.start(); + // await CakeTor.instance!.start(); // }); // second start is fast but populates the values on current thread - await CakeTor.instance.start(); + await CakeTor.instance!.start(); printV("Tor started"); - while (!CakeTor.instance.started) { + while (!CakeTor.instance!.started) { printV("Waiting for tor to start (part 1)"); await Future.delayed(const Duration(seconds: 1)); } - while (CakeTor.instance.port == -1) { + while (CakeTor.instance!.port == -1) { printV("Waiting for tor to start (listening on port)"); await Future.delayed(const Duration(seconds: 1)); } - printV("Tor started on port ${CakeTor.instance.port}"); + printV("Tor started on port ${CakeTor.instance!.port}"); if (context != null) dismissFullscreenDialog(dialogContext!); } diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index e893ac8d0..3a6cf2d38 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -399,7 +399,7 @@ abstract class DashboardViewModelBase with Store { String get address => wallet.walletAddresses.address; @computed - bool get isTorEnabled => CakeTor.instance.enabled; + bool get isTorEnabled => CakeTor.instance!.enabled; @computed SyncStatus get status => wallet.syncStatus; diff --git a/lib/view_model/node_list/node_create_or_edit_view_model.dart b/lib/view_model/node_list/node_create_or_edit_view_model.dart index 1f988eeef..003247a40 100644 --- a/lib/view_model/node_list/node_create_or_edit_view_model.dart +++ b/lib/view_model/node_list/node_create_or_edit_view_model.dart @@ -64,7 +64,7 @@ abstract class NodeCreateOrEditViewModelBase with Store { bool useSocksProxy; @computed - bool get usesEmbeddedProxy => CakeTor.instance.started; + bool get usesEmbeddedProxy => CakeTor.instance!.started; @observable String socksProxyAddress; diff --git a/lib/view_model/node_list/node_list_view_model.dart b/lib/view_model/node_list/node_list_view_model.dart index 463def285..d53e91ffc 100644 --- a/lib/view_model/node_list/node_list_view_model.dart +++ b/lib/view_model/node_list/node_list_view_model.dart @@ -39,7 +39,7 @@ abstract class NodeListViewModelBase with Store { String getAlertContent(String uri) => S.current.change_current_node(uri) + - '${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (CakeTor.instance.enabled ? '' : S.current.orbot_running_alert) : ''}'; + '${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (CakeTor.instance!.enabled ? '' : S.current.orbot_running_alert) : ''}'; @computed bool get enableAutomaticNodeSwitching => settingsStore.enableAutomaticNodeSwitching; diff --git a/lib/view_model/node_list/pow_node_list_view_model.dart b/lib/view_model/node_list/pow_node_list_view_model.dart index 310a0d311..0e270a6ad 100644 --- a/lib/view_model/node_list/pow_node_list_view_model.dart +++ b/lib/view_model/node_list/pow_node_list_view_model.dart @@ -39,7 +39,7 @@ abstract class PowNodeListViewModelBase with Store { String getAlertContent(String uri) => S.current.change_current_node(uri) + - '${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (CakeTor.instance.enabled ? '' : S.current.orbot_running_alert) : ''}'; + '${uri.endsWith('.onion') || uri.contains('.onion:') ? '\n' + (CakeTor.instance!.enabled ? '' : S.current.orbot_running_alert) : ''}'; @computed bool get enableAutomaticNodeSwitching => settingsStore.enableAutomaticNodeSwitching; diff --git a/lib/view_model/start_tor_view_model.dart b/lib/view_model/start_tor_view_model.dart index 5dc05838c..8bcf2998e 100644 --- a/lib/view_model/start_tor_view_model.dart +++ b/lib/view_model/start_tor_view_model.dart @@ -59,7 +59,7 @@ abstract class StartTorViewModelBase with Store { await ensureTorStarted(context: null); while (true) { await Future.delayed(Duration(milliseconds: 250)); - if (CakeTor.instance.port != -1 && CakeTor.instance.started) { + if (CakeTor.instance!.port != -1 && CakeTor.instance!.started) { break; } } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index f6c94ccf3..e72a5ba58 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -37,6 +37,8 @@ PODS: - FlutterMacOS - sp_scanner (0.0.1): - FlutterMacOS + - torch_dart (0.0.1): + - FlutterMacOS - universal_ble (0.0.1): - Flutter - FlutterMacOS @@ -64,6 +66,7 @@ DEPENDENCIES: - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - sp_scanner (from `Flutter/ephemeral/.symlinks/plugins/sp_scanner/macos`) + - torch_dart (from `Flutter/ephemeral/.symlinks/plugins/torch_dart/macos`) - universal_ble (from `Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) @@ -109,6 +112,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sp_scanner: :path: Flutter/ephemeral/.symlinks/plugins/sp_scanner/macos + torch_dart: + :path: Flutter/ephemeral/.symlinks/plugins/torch_dart/macos universal_ble: :path: Flutter/ephemeral/.symlinks/plugins/universal_ble/darwin url_launcher_macos: @@ -117,28 +122,29 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos SPEC CHECKSUMS: - connectivity_plus: 0a976dfd033b59192912fa3c6c7b54aab5093802 - cw_mweb: 7440b12ead811dda972a9918442ea2a458e8742c - device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f - devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225 + connectivity_plus: 4adf20a405e25b42b9c9f87feff8f4b6fde18a4e + cw_mweb: 4746a3b5cc5bd4afe6fadd2481c4f7b239e391d0 + device_info_plus: b0fafc687fb901e2af612763340f1b0d4352f8e5 + devicelocale: 456a07c045d3113938aa4983065bd8526e2af792 dnssec_proof: d461cac7bd3301eb7447f87936745a0c1ae0a67e - fast_scanner: d31bae07e2653403a69dac99fb710c1722b16a97 - file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d - flutter_inappwebview_macos: bdf207b8f4ebd58e86ae06cd96b147de99a67c9b - flutter_local_authentication: 85674893931e1c9cfa7c9e4f5973cb8c56b018b0 - flutter_local_notifications: 4ccab5b7a22835214a6672e3f9c5e8ae207dab36 - flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea + fast_scanner: a4ead8e56f185cd565e25250fdb97fa669ea1d2e + file_selector_macos: 6280b52b459ae6c590af5d78fc35c7267a3c4b31 + flutter_inappwebview_macos: c2d68649f9f8f1831bfcd98d73fd6256366d9d1d + flutter_local_authentication: 2f9a2682f498abcc12d7e9729b5007a947170fdc + flutter_local_notifications: 4bf37a31afde695b56091b4ae3e4d9c7a7e6cda0 + flutter_secure_storage_macos: 3dacac420d84c4d0dc5e868194ee43c8664ec797 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - in_app_review: a6a031b9acd03c7d103e341aa334adf2c493fb93 + in_app_review: 0599bccaed5e02f6bed2b0d30d16f86b63ed8638 OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 - package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - share_plus: 1fa619de8392a4398bfaf176d441853922614e89 - shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 - sp_scanner: 269d96e0ec3173e69156be7239b95182be3b8303 - universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6 - url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 - wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 + package_info_plus: f0052d280d17aa382b932f399edf32507174e870 + path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 + share_plus: 510bf0af1a42cd602274b4629920c9649c52f4cc + shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 + sp_scanner: d9316427b628dd86d6e9e3c5d42ed6b4b410157c + torch_dart: 7e4f682c34ee0d967a35977102590094a7510c90 + universal_ble: ff19787898040d721109c6324472e5dd4bc86adc + url_launcher_macos: 0fba8ddabfc33ce0a9afe7c5fef5aab3d8d2d673 + wakelock_plus: 21ddc249ac4b8d018838dbdabd65c5976c308497 PODFILE CHECKSUM: 65ec1541137fb5b35d00490dec1bb48d4d9586bb diff --git a/pubspec_base.yaml b/pubspec_base.yaml index e77455765..d9409e3c3 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -143,6 +143,8 @@ dependencies: git: url: https://github.com/MrCyjaneK/dnssec_proof.git ref: a2b0bdac343afc14fc38dfb81f28147eab50be05 + torch_dart: + path: ./scripts/torch_dart dev_dependencies: flutter_test: @@ -188,10 +190,6 @@ dependency_overrides: git: url: https://github.com/LacticWhale/socks_dart.git ref: 27ad7c2efae8d7460325c74b90f660085cbd0685 - tor_binary: - git: - url: https://github.com/MrCyjaneK/flutter-tor_binary - ref: cb811c610871a9517d47134b87c2f590c15c96c5 web_socket_channel: ^3.0.2 freezed_annotation: 2.4.4 diff --git a/run-android.sh b/run-android.sh index feaf0d91d..cd2579db4 100755 --- a/run-android.sh +++ b/run-android.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/scripts" && pwd)/functions.sh" # Get the current git branch get_current_branch() { if git rev-parse --git-dir > /dev/null 2>&1; then diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh index 25a395898..4f369513f 100755 --- a/scripts/android/build_all.sh +++ b/scripts/android/build_all.sh @@ -7,6 +7,8 @@ fi DIR=$(dirname "$0") +$DIR/build_torch.sh + case $APP_ANDROID_TYPE in "monero.com") $DIR/build_monero_all.sh ;; "cakewallet") $DIR/build_monero_all.sh diff --git a/scripts/android/build_torch.sh b/scripts/android/build_torch.sh new file mode 100755 index 000000000..a3955b189 --- /dev/null +++ b/scripts/android/build_torch.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -x -e +cd "$(dirname "$0")" + +../prepare_torch.sh + +cd ../torch_dart + +./build.sh aarch64-linux-android armv7a-linux-androideabi x86_64-linux-android \ No newline at end of file diff --git a/scripts/ios/build_all.sh b/scripts/ios/build_all.sh index 64b04a1be..f620413b8 100755 --- a/scripts/ios/build_all.sh +++ b/scripts/ios/build_all.sh @@ -7,6 +7,8 @@ fi DIR=$(dirname "$0") +$DIR/build_torch.sh + case $APP_IOS_TYPE in "monero.com") $DIR/build_monero_all.sh ;; "cakewallet") $DIR/build_monero_all.sh && $DIR/build_mwebd.sh && $DIR/build_decred.sh ;; diff --git a/scripts/ios/build_torch.sh b/scripts/ios/build_torch.sh new file mode 100755 index 000000000..64c466256 --- /dev/null +++ b/scripts/ios/build_torch.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -x -e +cd "$(dirname "$0")" + +../prepare_torch.sh + +cd ../torch_dart + +# Need to build all platforms to get .xcframework +./build.sh aarch64-apple-ios-simulator aarch64-apple-ios aarch64-apple-darwin x86_64-apple-darwin \ No newline at end of file diff --git a/scripts/macos/build_all.sh b/scripts/macos/build_all.sh index 7929bb719..4cd710fce 100755 --- a/scripts/macos/build_all.sh +++ b/scripts/macos/build_all.sh @@ -1,3 +1,5 @@ #!/bin/sh -./build_monero_all.sh universal && $DIR/build_decred.sh +./build_torch.sh + +./build_monero_all.sh universal && ./build_decred.sh diff --git a/scripts/macos/build_torch.sh b/scripts/macos/build_torch.sh new file mode 100755 index 000000000..14a99e179 --- /dev/null +++ b/scripts/macos/build_torch.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -x -e +cd "$(dirname "$0")" +exec bash ../ios/build_torch.sh \ No newline at end of file diff --git a/scripts/prepare_moneroc.sh b/scripts/prepare_moneroc.sh index 17137a3f7..cd1136de0 100755 --- a/scripts/prepare_moneroc.sh +++ b/scripts/prepare_moneroc.sh @@ -6,6 +6,7 @@ cd "$(dirname "$0")" if [[ ! -d "monero_c/.git" ]]; then + rm -rf monero_c git clone https://github.com/mrcyjanek/monero_c --branch master monero_c cd monero_c git checkout b576312e4d466569cd03482b61c597b39a9f4dc3 diff --git a/scripts/prepare_torch.sh b/scripts/prepare_torch.sh new file mode 100755 index 000000000..f8760e62e --- /dev/null +++ b/scripts/prepare_torch.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -x -e +cd "$(dirname "$0")" + +# IMPORTANT: Make sure to update action 'Build Torch` in +# - .github/workflows/pr_test_build_android.yml +# - .github/workflows/pr_test_build_linux.yml +# https://github.com/MrCyjaneK/torch_dart/releases/download/4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653/torch_dart-4f987d4-1-ge071fcf-1-gc282f09-1-g4c290aa-1-gabdf653.tar.gz + +HASH=abdf653fc15b576f2a67597a1f9618345a297f45 + +if [[ ! -d "torch_dart/.git" ]]; +then + rm -rf torch_dart + git clone https://github.com/mrcyjanek/torch_dart + cd torch_dart +else + cd torch_dart + git fetch -a +fi + + +git reset --hard +git checkout $HASH +git reset --hard + +# recommended to uncomment during development +# sed -i.bak 's/go run . -cleanup/#go run . -cleanup/g' build.sh \ No newline at end of file