diff --git a/.github/workflows/precompiled_binaries.yml b/.github/workflows/precompiled_binaries.yml index 1950f9c..f2993f4 100644 --- a/.github/workflows/precompiled_binaries.yml +++ b/.github/workflows/precompiled_binaries.yml @@ -17,18 +17,33 @@ jobs: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 - - name: Install GTK - if: (matrix.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install libgtk-3-dev + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Set RUSTFLAGS for macOS + if: (matrix.os == 'macOS-latest') + run: | + echo "RUSTFLAGS=-C link-arg=-undefined -C link-arg=dynamic_lookup" >> $GITHUB_ENV + echo "MACOSX_DEPLOYMENT_TARGET=17.5" >> $GITHUB_ENV + echo "IPHONEOS_DEPLOYMENT_TARGET=17.5" >> $GITHUB_ENV + + - name: Install Xcode Tools + if: (matrix.os == 'macOS-latest') + run: xcode-select --install || echo "Xcode tools already installed" + - name: Set up Android SDK if: (matrix.os == 'ubuntu-20.04') - uses: android-actions/setup-android@v2 - + uses: android-actions/setup-android@v2 + - name: Install Specific NDK if: (matrix.os == 'ubuntu-20.04') - run: sdkmanager --install "ndk;24.0.8215888" - - name: Precompile - if: (matrix.os == 'macOS-latest') || (matrix.os == 'windows-latest') + run: sdkmanager --install "ndk;25.1.8937393" + - name: Precompile (with iOS) + if: (matrix.os == 'macOS-latest') run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=SatoshiPortal/lwk-dart working-directory: cargokit/build_tool env: @@ -36,8 +51,8 @@ jobs: PRIVATE_KEY: ${{ secrets.RELEASE_PRIVATE_KEY }} - name: Precompile (with Android) - if: (matrix.os == 'ubuntu-latest') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=SatoshiPortal/lwk-dart --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23 + if: (matrix.os == 'ubuntu-20.04') + run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=SatoshiPortal/lwk-dart --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=25.1.8937393 --android-min-sdk-version=23 working-directory: cargokit/build_tool env: GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c16e3d1..98f6a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ ## 0.1.5 - Initial version + +## 0.1.6 + +- Score improvments +- fix liblwk.a not found diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ed5e3c8..62188a2 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -21,7 +21,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 lwk: 22e06bc5664247d6b2dac91cfe209b63b70dd580 - path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 diff --git a/example/lib/main.dart b/example/lib/main.dart index 09da41d..9642ffe 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,11 +1,10 @@ -import 'package:lwk/lwk.dart' as lwk; -import 'dart:typed_data'; import 'package:lwk/lwk.dart'; +import 'dart:typed_data'; import 'package:path_provider/path_provider.dart'; import 'package:flutter/material.dart'; void main() async { - await lwk.LibLwk.init(); + await LibLwk.init(); runApp(const TestApp()); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ac88ef0..6ead9ee 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,6 +9,8 @@ environment: sdk: '>=3.1.0 <4.0.0' dependencies: + flutter: + sdk: flutter lwk: path: ../ # git: diff --git a/flutter_rust_bridge.yaml b/flutter_rust_bridge.yaml index 090b2d5..9ef6834 100644 --- a/flutter_rust_bridge.yaml +++ b/flutter_rust_bridge.yaml @@ -3,4 +3,5 @@ dart_output: lib/src/generated/ full_dep: true c_output: ios/Classes/frb_generated.h duplicated_c_output: [macos/Classes/frb_generated.h] -dart_entrypoint_class_name: LwkCore \ No newline at end of file +dart_entrypoint_class_name: LwkCore +enable_lifetime: true diff --git a/lib/lwk.dart b/lib/lwk.dart index 0118e22..92fa021 100644 --- a/lib/lwk.dart +++ b/lib/lwk.dart @@ -1,8 +1,9 @@ +///A dart/flutter library with language bindings for rust library [lwk](https://github.com/Blockstream/lwk) - Liquid Wallet Kit. library lwk; -export './src/generated/frb_generated.dart'; +// export './src/generated/frb_generated.dart'; export './src/generated/api/descriptor.dart'; -export './src/generated/api/wallet.dart'; +export './src/generated/api/wallet.dart' show Wallet; export './src/generated/api/types.dart'; export './src/utils/loader.dart'; export './src/root.dart'; diff --git a/lib/src/generated/frb_generated.dart b/lib/src/generated/frb_generated.dart index 21dbc24..c0a719e 100644 --- a/lib/src/generated/frb_generated.dart +++ b/lib/src/generated/frb_generated.dart @@ -63,7 +63,7 @@ class LwkCore extends BaseEntrypoint { static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( - stem: 'lwk_dart', + stem: 'lwk', ioDirectory: 'rust/target/release/', webPrefix: 'pkg/', ); diff --git a/lib/src/root.dart b/lib/src/root.dart index f77e994..e45bcea 100644 --- a/lib/src/root.dart +++ b/lib/src/root.dart @@ -21,9 +21,17 @@ Future setCurrentDirectory() async { } } +/// List of Balance objects represents a balance of a specific asset typedef Balances = List; +/// Utility class for handling balance-related operations class BalanceUtils { + /// Returns the balance amount for a specific asset ID from a list of balances + /// + /// [balances] - List of Balance objects to search through + /// [assetId] - The asset ID to look for + /// + /// Returns the balance value if found, or 0 if no matching asset ID is found static int getBalanceByAssetId(List balances, String assetId) { for (var balance in balances) { if (balance.assetId == assetId) { @@ -33,10 +41,20 @@ class BalanceUtils { return 0; // Return 0 if no balance is found for the asset ID } + /// Returns the L-BTC balance from a list of balances + /// + /// [balances] - List of Balance objects to search through + /// + /// Returns the L-BTC balance value if found, or 0 if not found static int getLBtcBalance(List balances) { return getBalanceByAssetId(balances, lBtcAssetId); } + /// Returns the TEST balance from a list of balances + /// + /// [balances] - List of Balance objects to search through + /// + /// Returns the TEST balance value if found, or 0 if not found static int getLTestBalance(List balances) { return getBalanceByAssetId(balances, lTestAssetId); } diff --git a/lib/src/utils/loader.dart b/lib/src/utils/loader.dart index 9b17cd1..e343b9f 100644 --- a/lib/src/utils/loader.dart +++ b/lib/src/utils/loader.dart @@ -4,7 +4,6 @@ import 'package:archive/archive.dart'; import 'package:flutter/services.dart' show Uint8List, rootBundle; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:http/http.dart' as http; -import 'package:lwk/lwk.dart'; import '../generated/frb_generated.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 1b20206..0706656 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,37 +1,36 @@ name: lwk -description: "Dart/Flutter language bindings for Liquid Wallet Kit" +description: "A dart/flutter library with language bindings for rust library [lwk](https://github.com/Blockstream/lwk) - Liquid Wallet Kit." repository: https://github.com/SatoshiPortal/lwk-dart -version: 0.1.5 +version: 0.1.6 environment: - sdk: '>=3.2.0 <4.0.0' - flutter: '>=3.3.0' + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.3.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.2 - ffi: ^2.0.1 + cupertino_icons: ^1.0.8 + ffi: ^2.1.3 flutter_rust_bridge: ^2.0.0 - meta: ^1.8.0 - uuid: ^4.1.0 - dio: ^5.4.0 - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 - archive: ^3.4.10 - http: ^1.2.0 - + meta: ^1.15.0 + uuid: ^4.5.1 + dio: ^5.7.0 + freezed_annotation: ^2.4.4 + json_annotation: ^4.9.0 + archive: ^4.0.2 + http: ^1.2.2 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.0 - freezed: ^2.3.5 - ffigen: ^14.0.0 - test: ^1.24.3 - build_runner: ^2.4.8 - json_serializable: ^6.7.1 + flutter_lints: ^3.0.2 + freezed: ^2.5.7 + ffigen: ^14.0.1 + test: ^1.25.8 + build_runner: ^2.4.14 + json_serializable: ^6.9.0 lints: ^3.0.0 integration_test: sdk: flutter @@ -49,4 +48,4 @@ flutter: macos: ffiPlugin: true linux: - ffiPlugin: true + ffiPlugin: true diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 98f77e0..9a09f94 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -190,11 +190,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] @@ -555,9 +556,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.7" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b" dependencies = [ "shlex", ] @@ -2000,9 +2001,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -2093,9 +2094,25 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "lwk" +version = "0.1.5" +dependencies = [ + "anyhow", + "flutter_rust_bridge", + "flutter_rust_bridge_codegen", + "hex", + "lazy_static", + "log", + "lwk_common", + "lwk_signer", + "lwk_wollet", + "thiserror 1.0.69", +] [[package]] name = "lwk_common" @@ -2124,22 +2141,6 @@ dependencies = [ "testcontainers", ] -[[package]] -name = "lwk_dart" -version = "0.1.5" -dependencies = [ - "anyhow", - "flutter_rust_bridge", - "flutter_rust_bridge_codegen", - "hex", - "lazy_static", - "log", - "lwk_common", - "lwk_signer", - "lwk_wollet", - "thiserror 1.0.69", -] - [[package]] name = "lwk_jade" version = "0.8.0" @@ -2248,9 +2249,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -2556,9 +2557,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -2585,7 +2586,7 @@ dependencies = [ "rustc-hash 2.1.0", "rustls", "socket2", - "thiserror 2.0.10", + "thiserror 2.0.11", "tokio", "tracing", ] @@ -2604,7 +2605,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.10", + "thiserror 2.0.11", "tinyvec", "tracing", "web-time", @@ -3358,11 +3359,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ac7f54ca534db81081ef1c1e7f6ea8a3ef428d2fc069097c079443d24124d3" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.10", + "thiserror-impl 2.0.11", ] [[package]] @@ -3378,9 +3379,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9465d30713b56a37ede7185763c3492a91be2f5fa68d958c44e41ab9248beb" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -3705,20 +3706,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -3730,9 +3732,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -3743,9 +3745,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3753,9 +3755,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -3766,9 +3768,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-timer" @@ -3787,9 +3792,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -4040,9 +4045,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.22" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 5643397..cbfb325 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "lwk_dart" +name = "lwk" description = "Flutter-Rust Bridge for Liquid Wallet Kit (lwk)" authors = ["i5hi , mocodesmo "] version = "0.1.5" edition = "2021" [lib] -name = "lwk_dart" +name = "lwk" doctest = false crate-type = ["staticlib", "cdylib"] @@ -33,3 +33,9 @@ opt-level = "z" lto = true codegen-units = 1 panic = "abort" + +[target.'cfg(target_os = "macos")'] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] \ No newline at end of file