From 4f77dd4da91eb2350f51324c0a98ab6414d13890 Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:12:51 -0500 Subject: [PATCH 1/8] enabled_lifetime parameter --- flutter_rust_bridge.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From ce38267c98a0334d8698b036c4b9178c63b97bff Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:13:46 -0500 Subject: [PATCH 2/8] dependences upgraded --- example/ios/Podfile.lock | 2 +- pubspec.yaml | 41 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 22 deletions(-) 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/pubspec.yaml b/pubspec.yaml index 1b20206..5a6a05e 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 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 - 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 - + cupertino_icons: ^1.0.8 + ffi: ^2.1.3 + flutter_rust_bridge: 2.0.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 From e74aebc33df618a45e4323cadd18bd935715a1ef Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:15:46 -0500 Subject: [PATCH 3/8] code cleanup --- lib/src/utils/loader.dart | 1 - 1 file changed, 1 deletion(-) 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'; From 8a03529944e6f41df7d0751558c4c763eb642161 Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:16:10 -0500 Subject: [PATCH 4/8] doc comments added --- lib/src/root.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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); } From 5ddb5e8a63e37652d3197c40a28a6accef086532 Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:16:43 -0500 Subject: [PATCH 5/8] exports optimized --- lib/lwk.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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'; From 162f6143ccb72664251258d939e6be69b5b07c30 Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:25:09 -0500 Subject: [PATCH 6/8] fix: resolved depend_on_referenced_packages warning --- example/pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) 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: From 87e9e30b3fd1831b8487c46a14ad86bed366c18c Mon Sep 17 00:00:00 2001 From: StaxoLotl Date: Fri, 10 Jan 2025 14:50:39 -0500 Subject: [PATCH 7/8] code cleanup --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5a6a05e..f8c60ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: sdk: flutter cupertino_icons: ^1.0.8 ffi: ^2.1.3 - flutter_rust_bridge: 2.0.0 + flutter_rust_bridge: ^2.0.0 meta: ^1.15.0 uuid: ^4.5.1 dio: ^5.7.0 From f85a3781de24b48dcafe4c27c9cced644eed61d1 Mon Sep 17 00:00:00 2001 From: ethicnology Date: Mon, 13 Jan 2025 12:09:28 -0500 Subject: [PATCH 8/8] docs: update example --- example/lib/main.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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()); }