Skip to content

Commit

Permalink
Merge pull request #45 from SatoshiPortal/develop
Browse files Browse the repository at this point in the history
v0.1.6
  • Loading branch information
ethicnology authored Jan 23, 2025
2 parents 7c60552 + 79c6c41 commit 1b7a054
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 93 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/precompiled_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,42 @@ 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:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
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 }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.5

- Initial version

## 0.1.6

- Score improvments
- fix liblwk.a not found
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
lwk: 22e06bc5664247d6b2dac91cfe209b63b70dd580
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

Expand Down
5 changes: 2 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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());
}

Expand Down
2 changes: 2 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ environment:
sdk: '>=3.1.0 <4.0.0'

dependencies:
flutter:
sdk: flutter
lwk:
path: ../
# git:
Expand Down
3 changes: 2 additions & 1 deletion flutter_rust_bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
dart_entrypoint_class_name: LwkCore
enable_lifetime: true
5 changes: 3 additions & 2 deletions lib/lwk.dart
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion lib/src/generated/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LwkCore extends BaseEntrypoint<LwkCoreApi, LwkCoreApiImpl, LwkCoreWire> {

static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
stem: 'lwk_dart',
stem: 'lwk',
ioDirectory: 'rust/target/release/',
webPrefix: 'pkg/',
);
Expand Down
18 changes: 18 additions & 0 deletions lib/src/root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ Future<void> setCurrentDirectory() async {
}
}

/// List of Balance objects represents a balance of a specific asset
typedef Balances = List<Balance>;

/// 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<Balance> balances, String assetId) {
for (var balance in balances) {
if (balance.assetId == assetId) {
Expand All @@ -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<Balance> 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<Balance> balances) {
return getBalanceByAssetId(balances, lTestAssetId);
}
Expand Down
1 change: 0 additions & 1 deletion lib/src/utils/loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
41 changes: 20 additions & 21 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -49,4 +48,4 @@ flutter:
macos:
ffiPlugin: true
linux:
ffiPlugin: true
ffiPlugin: true
Loading

0 comments on commit 1b7a054

Please sign in to comment.