Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.8 #25

Merged
merged 9 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions .github/workflows/precompiled_binaries.yml
Original file line number Diff line number Diff line change
@@ -12,32 +12,47 @@ jobs:
os:
- ubuntu-20.04
- macOS-latest
- windows-latest
# - windows-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1

- 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: Install GTK
if: (matrix.os == 'ubuntu-latest')
run: sudo apt-get update && sudo apt-get install libgtk-3-dev
- 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/boltz-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/boltz-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/boltz-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 }}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.7

Initial version
- Initial version

# 0.1.8

- fix libboltz.a not found
57 changes: 46 additions & 11 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
import 'package:boltz/boltz.dart' as bltz;
import 'package:boltz/boltz.dart';
import 'package:flutter/material.dart';

void main() async {
await test();
runApp(MaterialApp(home: Scaffold(body: Container(color: Colors.red))));
await LibBoltz.init();
runApp(const MyApp());
}

Future test() async {
try {
await bltz.LibBoltz.init();
class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Fees Display')),
body: const FeesWidget(),
),
);
}
}

class FeesWidget extends StatelessWidget {
const FeesWidget({Key? key}) : super(key: key);

Future<String> fetchFees() async {
const boltzUrl = 'https://api.testnet.boltz.exchange/v2';
// const amount = 100000;
final fees = await const bltz.Fees(boltzUrl: boltzUrl).chain();
print('FEES:$fees');
} catch (e) {
print('\n\nERRRR: $e\n\n');
try {
final fees = await const Fees(boltzUrl: boltzUrl).chain();
return fees.toString();
} catch (e) {
return 'Error: $e';
}
}

@override
Widget build(BuildContext context) {
return FutureBuilder<String>(
future: fetchFees(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError || !snapshot.hasData) {
return const Center(child: Text('Failed to load fees.'));
} else {
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Text(snapshot.data!, style: const TextStyle(fontSize: 16)),
);
}
},
);
}
}
2 changes: 1 addition & 1 deletion lib/boltz.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library boltz;
library;

export './src/generated/frb_generated.dart';
export './src/generated/api/btc_ln.dart';
2 changes: 1 addition & 1 deletion lib/src/generated/frb_generated.dart
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ class BoltzCore

static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
stem: 'boltz_dart',
stem: 'boltz',
ioDirectory: 'rust/target/release/',
webPrefix: 'pkg/',
);
10 changes: 7 additions & 3 deletions lib/src/generated/frb_generated.io.dart
Original file line number Diff line number Diff line change
@@ -2330,10 +2330,14 @@ class BoltzCoreWire implements BaseWire {
_dummy_method_to_enforce_bundlingPtr.asFunction<int Function()>();
}

typedef DartPostCObjectFnType = ffi.Pointer<
ffi.NativeFunction<
ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>;
typedef DartPort = ffi.Int64;
typedef DartDartPort = int;
typedef DartPostCObjectFnTypeFunction = ffi.Bool Function(
DartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartDartPostCObjectFnTypeFunction = bool Function(
DartDartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartPostCObjectFnType
= ffi.Pointer<ffi.NativeFunction<DartPostCObjectFnTypeFunction>>;

final class wire_cst_list_prim_u_8_strict extends ffi.Struct {
external ffi.Pointer<ffi.Uint8> ptr;
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: boltz
description: A dart/flutter library for boltz swaps
version: 0.1.7
version: 0.1.8
homepage: https://github.com/SatoshiPortal/boltz-dart

environment:
@@ -18,17 +18,17 @@ dependencies:
dio: ^5.4.0
freezed_annotation: ^2.4.1
json_annotation: ^4.8.1
archive: ^3.4.10
archive: ^4.0.2
http: ^1.2.0
web_socket_channel: ^2.1.0
web_socket_channel: ^3.0.1
# rust_lib_boltz:
# path: rust_builder

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
ffigen: ^9.0.1
flutter_lints: ^5.0.0
ffigen: ^16.0.0
test: ^1.24.3
build_runner: ^2.4.6
freezed: ^2.4.6
10 changes: 8 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "boltz_dart"
name = "boltz"
authors = [
"i5hi <ishi@satoshiportal.com>, mocodesmo <morteza@satoshiportal.com>",
]
version = "0.1.6"
edition = "2021"

[lib]
name = "boltz_dart"
name = "boltz"
doctest = false
crate-type = ["staticlib", "cdylib"]

@@ -35,3 +35,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",
]
2 changes: 1 addition & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ m/purpose/network/21/0/*

```dart

import 'package:boltz_client_flutter/boltz_client_flutter.dart';
import 'package:boltz/boltz.dart';

final network = BitcoinNetwork.Mainnet;
final electrumUrl = 'electrum.bullbitcoin.com:50002'