Skip to content

Commit baf331d

Browse files
committed
Merge remote-tracking branch 'origin/feat/v4'
2 parents 7af247d + ebc89a4 commit baf331d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6300
-3029
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
# `flutter_libepiccash`
2-
## Submodules
3-
Initialize submodules:
4-
```sh
5-
git submodule update --init --recursive
6-
```
7-
82
## Dependencies
93
### Rust
104
Install Rust: https://www.rust-lang.org/tools/install
@@ -18,13 +12,13 @@ rustup default 1.81
1812
cargo install cargo-ndk
1913
```
2014

21-
# Android
22-
## Add targets to rust
15+
## Android
16+
### Add targets to rust
2317
```sh
2418
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
2519
```
2620

27-
## Install dependencies
21+
### Install dependencies
2822
```sh
2923
# https://github.com/EpicCash/epic/blob/master/doc/build.md#requirements
3024
sudo apt install build-essential \
@@ -47,44 +41,57 @@ sudo apt install build-essential \
4741
libc6-dev-i386
4842
```
4943

50-
## Build
44+
### Build
5145
```sh
5246
cd scripts/android
5347
./install_ndk.sh
5448
./build_all.sh
5549
```
5650

57-
# iOS
58-
## Add targets to rust
51+
## iOS
52+
### Add targets to rust
5953
```sh
6054
rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
6155
```
6256

63-
## Install dependencies
57+
### Install dependencies
6458
```sh
6559
cargo install cargo-lipo
6660
cargo install cbindgen
6761
```
6862

69-
## Build
63+
### Build
7064
```sh
7165
cd scripts/ios
7266
./build_all
7367
```
7468

75-
# Windows
76-
## Dependencies
69+
## Windows
70+
### Dependencies
7771
Run `scripts/windows/deps.sh` in WSL (may need to alter permissions like with `chmod +x *.sh`) to install `x86_64-w64-mingw32-gcc` and `clang` or run
7872
```sh
7973
sudo apt-get install clang gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
8074
```
8175

82-
## Building for Windows
83-
Run `scripts/windows/build_all.sh` in WSL (Ubuntu 20.04 on WSL2 has been tested)
76+
### Building for Windows
77+
Run `scripts/windows/build_all.sh` in WSL (Ubuntu 24.04 on WSL2 has been tested)
8478

8579
Libraries will be output to `scripts/windows/build`
8680

87-
## Building on Windows
88-
Perl is required for building on Windows. Strawberry Perl has been tested working.
81+
## Contributing
82+
### Regenerate FFI Bindings (ffigen)
83+
84+
The Dart bindings in `lib/src/bindings_generated.dart` are auto-generated from the C header produced by the Rust crate. If you change the Rust FFI surface, regenerate as follows from `flutter_libepiccash/`:
85+
86+
1) Ensure the C header exists/updated with cbindgen:
87+
- Install cbindgen, `cargo install cbindgen`.
88+
- Generate header: `cbindgen rust -c rust/cbindgen.toml -o rust/target/epic_cash_wallet.h`.
89+
90+
2) Generate Dart bindings with ffigen:
91+
- Install Dart SDK and `ffigen` dev dependency.
92+
- Fetch deps: `dart pub get`.
93+
- Generate: `dart run ffigen --config ffigen.yaml`.
8994

90-
Run `build_all.ps1` in Powershell. This is not confirmed working and may need work eg. may need some missing dependencies added but has been included as a starting point or example for Windows developers.
95+
Notes:
96+
- If ffigen cannot find LLVM/Clang, adjust `llvm-path` in `ffigen.yaml` or install LLVM (e.g., `sudo apt install llvm clang`).
97+
- Ensure the Rust library’s exported C functions match those listed under `functions.include` in `ffigen.yaml`.

analysis_options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ analyzer:
2222
linter:
2323
rules:
2424
prefer_relative_imports: true
25-
avoid_relative_lib_imports: true
25+
avoid_relative_lib_imports: false
2626
no_leading_underscores_for_local_identifiers: false
2727
no_leading_underscores_for_library_prefixes: false
2828
avoid_print: true
@@ -31,4 +31,4 @@ linter:
3131
constant_identifier_names: false
3232
prefer_final_locals: true
3333
prefer_final_in_for_each: true
34-
require_trailing_commas: true
34+
require_trailing_commas: true

android/src/main/kotlin/com/example/flutter_libepiccash/FlutterLibepiccashPlugin.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

example/lib/wallet_info_view.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:convert';
2+
13
import 'package:flutter/material.dart';
24
import 'package:flutter/services.dart';
35
import 'package:flutter_libepiccash/epic_cash.dart';
@@ -60,9 +62,19 @@ class _WalletInfoViewState extends State<WalletInfoView> {
6062
return;
6163
}
6264

65+
// Unwrap the JSON envelope.
66+
final envelope = jsonDecode(walletResult);
67+
if (envelope['ok'] != true) {
68+
setState(() {
69+
_resultMessage = 'Error opening wallet: ${envelope['error'] ?? 'Unknown error'}';
70+
});
71+
return;
72+
}
73+
final walletData = envelope['data'];
74+
6375
final epicboxConfig =
6476
await EpicboxConfig.getDefaultConfig(widget.walletName);
65-
final address = getAddressInfo(walletResult, 0, epicboxConfig);
77+
final address = getAddressInfo(walletData, 0, epicboxConfig);
6678
setState(() {
6779
_resultMessage = "Address Info: $address";
6880
});
@@ -271,9 +283,16 @@ class _WalletInfoViewState extends State<WalletInfoView> {
271283
return 'Error opening wallet: $walletResult';
272284
}
273285

286+
// Unwrap the JSON envelope.
287+
final envelope = jsonDecode(walletResult);
288+
if (envelope['ok'] != true) {
289+
return 'Error opening wallet: ${envelope['error'] ?? 'Unknown error'}';
290+
}
291+
final walletData = envelope['data'];
292+
274293
final epicboxConfig =
275294
await EpicboxConfig.getDefaultConfig(widget.walletName);
276-
final address = getAddressInfo(walletResult, 0, epicboxConfig);
295+
final address = getAddressInfo(walletData, 0, epicboxConfig);
277296
return address;
278297
} catch (e) {
279298
return 'Error getting address: $e';

example/linux/flutter/generated_plugin_registrant.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66

77
#include "generated_plugin_registrant.h"
88

9-
#include <flutter_libepiccash/flutter_libepiccash_plugin.h>
109
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
1110

1211
void fl_register_plugins(FlPluginRegistry* registry) {
13-
g_autoptr(FlPluginRegistrar) flutter_libepiccash_registrar =
14-
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLibepiccashPlugin");
15-
flutter_libepiccash_plugin_register_with_registrar(flutter_libepiccash_registrar);
1612
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
1713
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
1814
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);

example/linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6-
flutter_libepiccash
76
flutter_secure_storage_linux
87
)
98

109
list(APPEND FLUTTER_FFI_PLUGIN_LIST
10+
flutter_libepiccash
1111
)
1212

1313
set(PLUGIN_BUNDLED_LIBRARIES)

example/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
import FlutterMacOS
66
import Foundation
77

8-
import flutter_libepiccash
98
import flutter_secure_storage_macos
109
import path_provider_foundation
1110

1211
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
13-
FlutterLibepiccashPlugin.register(with: registry.registrar(forPlugin: "FlutterLibepiccashPlugin"))
1412
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
1513
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
1614
}

0 commit comments

Comments
 (0)