Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.29.2'
channel: 'stable'
flutter-version: "3.29.2"
channel: "stable"

- name: Install dependencies
run: flutter pub get
Expand All @@ -54,7 +54,7 @@ jobs:

build-android:
name: Build Android APK
needs: [ rust-checks, flutter-checks ]
needs: [rust-checks, flutter-checks]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -73,8 +73,8 @@ jobs:
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.29.2'
channel: 'stable'
flutter-version: "3.29.2"
channel: "stable"

- uses: kuhnroyal/flutter-fvm-config-action/setup@v3

Expand All @@ -96,7 +96,7 @@ jobs:

build-ios:
name: Build iOS
needs: [ rust-checks, flutter-checks ]
needs: [rust-checks, flutter-checks]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -115,8 +115,8 @@ jobs:
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.29.2'
channel: 'stable'
flutter-version: "3.29.2"
channel: "stable"

- uses: kuhnroyal/flutter-fvm-config-action/setup@v3

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ as a reference implementation for building an Ark Wallet using Flutter and Rust.
```

3. Generate Flutter-Rust bindings :
NOTE: make sure you have the correct flutter version installed as defined in .fmrc!
NOTE: make sure you have the correct flutter version installed as defined in .fmrc!
```bash
just ffi-build
```
Expand All @@ -41,8 +41,8 @@ NOTE: make sure you have the correct flutter version installed as defined in .fm
5. Build for your target platform

```bash
just ios-build
just android-build
just ios-build
just android-build
```

5. Run the app:
Expand Down
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ run:

flutter-fmt:
dart format --output=write .

## ------------------------
## formatting
## ------------------------

fmt:
dprint fmt
72 changes: 69 additions & 3 deletions lib/src/rust/api/ark_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'ark_api.freezed.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `fmt`, `fmt`

Future<bool> walletExists({required String dataDir}) =>
RustLib.instance.api.crateApiArkApiWalletExists(dataDir: dataDir);

Expand Down Expand Up @@ -54,7 +56,8 @@ Future<String> restoreWallet(

Future<Balance> balance() => RustLib.instance.api.crateApiArkApiBalance();

Future<Addresses> address() => RustLib.instance.api.crateApiArkApiAddress();
Future<Addresses> address({BigInt? amount}) =>
RustLib.instance.api.crateApiArkApiAddress(amount: amount);

Future<List<Transaction>> txHistory() =>
RustLib.instance.api.crateApiArkApiTxHistory();
Expand All @@ -73,19 +76,36 @@ Future<void> resetWallet({required String dataDir}) =>

Future<Info> information() => RustLib.instance.api.crateApiArkApiInformation();

Future<PaymentReceived> waitForPayment(
{String? arkAddress,
String? boardingAddress,
String? boltzSwapId,
required BigInt timeoutSeconds}) =>
RustLib.instance.api.crateApiArkApiWaitForPayment(
arkAddress: arkAddress,
boardingAddress: boardingAddress,
boltzSwapId: boltzSwapId,
timeoutSeconds: timeoutSeconds);

class Addresses {
final String boarding;
final String offchain;
final String bip21;
final BoltzSwap? lightning;

const Addresses({
required this.boarding,
required this.offchain,
required this.bip21,
this.lightning,
});

@override
int get hashCode => boarding.hashCode ^ offchain.hashCode ^ bip21.hashCode;
int get hashCode =>
boarding.hashCode ^
offchain.hashCode ^
bip21.hashCode ^
lightning.hashCode;

@override
bool operator ==(Object other) =>
Expand All @@ -94,7 +114,8 @@ class Addresses {
runtimeType == other.runtimeType &&
boarding == other.boarding &&
offchain == other.offchain &&
bip21 == other.bip21;
bip21 == other.bip21 &&
lightning == other.lightning;
}

class Balance {
Expand All @@ -115,6 +136,30 @@ class Balance {
offchain == other.offchain;
}

class BoltzSwap {
final String swapId;
final BigInt amountSats;
final String invoice;

const BoltzSwap({
required this.swapId,
required this.amountSats,
required this.invoice,
});

@override
int get hashCode => swapId.hashCode ^ amountSats.hashCode ^ invoice.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BoltzSwap &&
runtimeType == other.runtimeType &&
swapId == other.swapId &&
amountSats == other.amountSats &&
invoice == other.invoice;
}

class Info {
final String serverPk;
final String network;
Expand Down Expand Up @@ -161,6 +206,27 @@ class OffchainBalance {
totalSats == other.totalSats;
}

class PaymentReceived {
final String txid;
final BigInt amountSats;

const PaymentReceived({
required this.txid,
required this.amountSats,
});

@override
int get hashCode => txid.hashCode ^ amountSats.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PaymentReceived &&
runtimeType == other.runtimeType &&
txid == other.txid &&
amountSats == other.amountSats;
}

@freezed
sealed class Transaction with _$Transaction {
const Transaction._();
Expand Down
6 changes: 3 additions & 3 deletions lib/src/rust/ark/client.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.9.0.
// @generated by `flutter_rust_bridge`@ 2.11.1.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<Balance>>
abstract class Balance implements RustOpaqueInterface {}
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BoltzSwap>>
abstract class BoltzSwap implements RustOpaqueInterface {}
Loading
Loading