Skip to content

Commit

Permalink
Merge pull request #43 from StaxoLotl/improve/pub-score
Browse files Browse the repository at this point in the history
Enhancements to Improve pub score
  • Loading branch information
ethicnology authored Jan 13, 2025
2 parents 584818f + f85a378 commit ade07d0
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 28 deletions.
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';
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
39 changes: 19 additions & 20 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

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

0 comments on commit ade07d0

Please sign in to comment.