Skip to content

Commit

Permalink
feat: update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuelongqy committed Dec 10, 2024
1 parent c013a07 commit 0b71bbf
Show file tree
Hide file tree
Showing 19 changed files with 183 additions and 80 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# wallet_core_bindings
[![License](https://img.shields.io/badge/license-AGPLv3-blue)](https://pub.dev/packages/wallet_core_bindings)
[![Pub](https://img.shields.io/pub/v/wallet_core_bindings)](https://pub.dev/packages/wallet_core_bindings)

Dart bindings for [Trust Wallet Core](https://github.com/trustwallet/wallet-core), used in Flutter and Dart.

## Features
Expand All @@ -9,6 +12,9 @@ Dart bindings for [Trust Wallet Core](https://github.com/trustwallet/wallet-core
- Combined with Dart GC, there is no need to control memory.
- Update the TrustWalletCore version synchronously and keep the APIs consistent.

## Usage
For comprehensive documentation, see [package repository](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings).

## Generate

We need to extract the files from [wallet-core](https://github.com/trustwallet/wallet-core/tree/master/include/TrustWalletCore) and generate the corresponding Dart code so that Dart can communicate with TrustWalletCore.
Expand Down
9 changes: 2 additions & 7 deletions wallet_core_bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
## 4.1.0

* Sync wallet-core [4.1.0](https://github.com/trustwallet/wallet-core/releases/tag/4.1.0).

## 4.0.49

* Sync wallet-core [4.0.49](https://github.com/trustwallet/wallet-core/releases/tag/4.0.49).
## 4.1.21
* Sync wallet-core [4.1.21](https://github.com/trustwallet/wallet-core/releases/tag/4.1.21).
20 changes: 18 additions & 2 deletions wallet_core_bindings/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# wallet_core_bindings
[![License](https://img.shields.io/badge/license-AGPLv3-blue)](https://pub.dev/packages/wallet_core_bindings)
[![Pub](https://img.shields.io/pub/v/wallet_core_bindings)](https://pub.dev/packages/wallet_core_bindings)

Dart bindings for [Trust Wallet Core](https://github.com/trustwallet/wallet-core), used in Flutter and Dart.

## Features
Expand All @@ -9,12 +12,22 @@ Dart bindings for [Trust Wallet Core](https://github.com/trustwallet/wallet-core
- Combined with Dart GC, there is no need to control memory.
- Update the TrustWalletCore version synchronously and keep the APIs consistent.

## Usage
## Getting Started
There are two ways to use wallet_core_bindings, Native and Web Assembly. Please follow the instructions below to make your choice.

| Platform | Native | Web Assembly | wallet_core_bindings_libs |
|:--------:|:------:|:------------:|:-------------------------:|
| Android ||||
| iOS ||||
| macOS ||| x |
| Linux ||| x |
| Windows | x || x |
| Web | x || x |

### Native
The native features of the platform rely on the dynamic library compiled by [Wallet Core](https://github.com/trustwallet/wallet-core), Binding with [dart:ffi](https://dart.dev/interop/c-interop).
* wallet_core_bindings_libs contains native dynamic libraries. Currently, only Android and iOS are supported. Due to the diversity of CPU architectures, Linux and macOS can be compiled and added to the project by themselves. It is possible that subsequent versions will find suitable ways to support them. Windows is not supported at present.
* For more information, see [wallet_core_bindings_libs](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_libs).
```yaml
dependencies:
wallet_core_bindings: version
Expand All @@ -32,7 +45,7 @@ void main() async {
}
```
### Web Assembly
Build WalletCore for WASM,Binding with [wasm_run](https://github.com/juancastillo0/wasm_run).
Build WalletCore for WASM,Binding with [WASI](https://github.com/WebAssembly/WASI) [wasi_snapshot_preview1](https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md) and [wasm_run](https://github.com/juancastillo0/wasm_run).
* It is suitable for use on platforms that do not support native, such as Web and Windows. However, wasm itself has strong cross-platform features and is not limited to these two platforms.
```yaml
dependencies:
Expand All @@ -54,6 +67,9 @@ void main() async {
}
```

## Usage
wallet_core_bindings provides the complete test cases, you can find usage here. See [tests](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings/example/test).

## Generate

### Protobuf
Expand Down
10 changes: 5 additions & 5 deletions wallet_core_bindings/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -443,35 +443,35 @@ packages:
path: ".."
relative: true
source: path
version: "4.1.20"
version: "4.1.21"
wallet_core_bindings_libs:
dependency: "direct main"
description:
path: "../../wallet_core_bindings_libs"
relative: true
source: path
version: "4.1.20"
version: "4.1.21"
wallet_core_bindings_native:
dependency: "direct main"
description:
path: "../../wallet_core_bindings_native"
relative: true
source: path
version: "4.1.20"
version: "4.1.21"
wallet_core_bindings_wasm:
dependency: "direct dev"
description:
path: "../../wallet_core_bindings_wasm"
relative: true
source: path
version: "4.1.20"
version: "4.1.21"
wallet_core_bindings_wasm_assets:
dependency: "direct dev"
description:
path: "../../wallet_core_bindings_wasm_assets"
relative: true
source: path
version: "4.1.20"
version: "4.1.21"
wasm_interop:
dependency: transitive
description:
Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_libs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## 0.0.1

* TODO: Describe initial release.
## 4.1.21
* Sync wallet-core [4.1.21](https://github.com/trustwallet/wallet-core/releases/tag/4.1.21).
2 changes: 1 addition & 1 deletion wallet_core_bindings_libs/LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO: Add your license here.
Link to <https://github.com/trustwallet/wallet-core/blob/master/LICENSE>.
36 changes: 27 additions & 9 deletions wallet_core_bindings_libs/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# wallet_core_bindings_libs
[![Pub](https://img.shields.io/pub/v/wallet_core_bindings_libs)](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_libs)

A new Flutter project.
Dynamic library built by wallet core, used with [wallet_core_bindings_native](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_native).

## Getting Started
## Supported platforms
Currently supported platforms, other platforms will be added if suitable methods are found in the future.
- Android
- iOS

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/to/develop-plugins),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
## Building
By default, wallet core does not expose interface methods. You need to make a small change and compile it before using it.

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
* Repository [wallet core](https://github.com/trustwallet/wallet-core).
* Build documentation, see [building](https://developer.trustwallet.com/developer/wallet-core/developing-the-library/building).

Required modifications
```cmake
# File: /cmake/StandardSettings.cmake
set(CMAKE_CXX_VISIBILITY_PRESET hidden) -> set(CMAKE_CXX_VISIBILITY_PRESET default)
```

### macOS
After compiling on macOS, you get libTrustWalletCore.dylib, which does not meet the requirements for the current multi-CPU architecture. However, you can still import it into the project and run it on a device with a specified CPU architecture.

### Linux
After compiling on Linux, you get libTrustWalletCore.dylib, which does not meet the requirements for the current multi-CPU architecture. However, you can still import it into the project and run it on a device with a specified CPU architecture.

### Windows
Windows is not supported at present.

## Usage
For comprehensive documentation, see [package repository](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings).
2 changes: 1 addition & 1 deletion wallet_core_bindings_libs/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wallet_core_bindings_libs
description: "A new Flutter project."
description: "wallet core dynamic library for wallet_core_bindings_native."
version: 4.1.21
homepage: https://github.com/xuelongqy/wallet_core_bindings

Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## 0.0.1

* TODO: Describe initial release.
## 4.1.21
* Sync wallet-core [4.1.21](https://github.com/trustwallet/wallet-core/releases/tag/4.1.21).
47 changes: 47 additions & 0 deletions wallet_core_bindings_native/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
# wallet_core_bindings_native
[![License](https://img.shields.io/badge/license-AGPLv3-blue)](https://pub.dev/packages/wallet_core_bindings)
[![Pub](https://img.shields.io/pub/v/wallet_core_bindings_native)](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_native)

Native implementation of wallet_core_bindings.

## Getting Started
Usually, it needs to be used with [wallet_core_bindings_wasm_libs](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_wasm_libs).

```yaml
dependencies:
wallet_core_bindings: version
wallet_core_bindings_native: version
wallet_core_bindings_libs: version
```
```dart
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_native/wallet_core_bindings_native.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await WalletCoreBindingsNativeImpl().initialize();
runApp(const MyApp());
}
```

wallet_core_bindings_wasm_libs currently only supports Android and iOS. If you want to support other platforms, you need to import the dynamic library of wallet core into the project. See [wallet_core_bindings_libs](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_libs).

```yaml
dependencies:
wallet_core_bindings: version
wallet_core_bindings_native: version
```
```dart
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_native/wallet_core_bindings_native.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
final bindings = TrustWalletCoreBindings(DynamicLibrary.open('libTrustWalletCore.dylib'));
await WalletCoreBindingsNativeImpl(bindings).initialize();
runApp(const MyApp());
}
```

## Usage
For comprehensive documentation, see [package repository](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings).

## Generate

### C Bindings

Extract header files in include/TrustWalletCore and generate Dart bindings code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import 'package:wallet_core_bindings/wallet_core_bindings.dart';

import 'src/bindings/bindings.dart' as native_bindings;

export 'src/bindings/bindings.dart' show TrustWalletCoreBindings;

part 'src/extensions/uint8_list_extension.dart';
part 'src/wallet_core_bindings_native_impl.dart';
part 'src/tw_account_impl.dart';
Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_native/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wallet_core_bindings_native
description: "Dart bindings for trust wallet core."
description: "Dart native bindings for trust wallet core."
version: 4.1.21
homepage: https://github.com/xuelongqy/wallet_core_bindings

Expand All @@ -8,8 +8,7 @@ environment:

dependencies:
ffi: ^2.1.2
wallet_core_bindings:
path: ../wallet_core_bindings
wallet_core_bindings: ^4.1.21

dev_dependencies:
lints: ^4.0.0
Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## 0.0.1

* TODO: Describe initial release.
## 4.1.21
* Sync wallet-core [4.1.21](https://github.com/trustwallet/wallet-core/releases/tag/4.1.21).
52 changes: 52 additions & 0 deletions wallet_core_bindings_wasm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
# wallet_core_bindings_wasm
[![License](https://img.shields.io/badge/license-AGPLv3-blue)](https://pub.dev/packages/wallet_core_bindings)
[![Pub](https://img.shields.io/pub/v/wallet_core_bindings_wasm)](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_wasm)

WebAssembly System Interface implementation of wallet_core_bindings.

## Getting Started
Usually, it needs to be used with [wallet_core_bindings_wasm_assets](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_wasm_assets).

```yaml
dependencies:
wasm_run_flutter: version
wallet_core_bindings: version
wallet_core_bindings_wasm: version
wallet_core_bindings_wasm_assets: version
```
```dart
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_wasm/wallet_core_bindings_wasm.dart';
import 'package:wasm_run_flutter/wasm_run_flutter.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await WasmRunLibrary.setUp(override: false);
await WalletCoreBindingsWasmImpl().initialize();
runApp(const MyApp());
}
```

If you want to modify wallet_core, see [wallet_core_bindings_wasm_assets](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings_wasm_assets).

```yaml
dependencies:
wasm_run_flutter: version
wallet_core_bindings: version
wallet_core_bindings_wasm: version
```
```dart
import 'package:flutter/services.dart';
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_wasm/wallet_core_bindings_wasm.dart';
import 'package:wasm_run_flutter/wasm_run_flutter.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await WasmRunLibrary.setUp(override: false);
final wasmBytes = (await rootBundle.load('.../wallet-core.wasm')).buffer.asUint8List();
await WalletCoreBindingsWasmImpl(wasmBytes).initialize();
runApp(const MyApp());
}
```

## Usage
For comprehensive documentation, see [package repository](https://github.com/xuelongqy/wallet_core_bindings/tree/main/wallet_core_bindings).

## License

### Commercial license
Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_wasm/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wallet_core_bindings_wasm
description: "Dart bindings for trust wallet core."
description: "Dart wasm bindings for trust wallet core."
version: 4.1.21
homepage: https://github.com/xuelongqy/wallet_core_bindings

Expand All @@ -13,8 +13,7 @@ dependencies:
convert: ^3.1.1
wasm_run_flutter: ^0.1.0
wasm_run: ^0.1.0+2
wallet_core_bindings:
path: ../wallet_core_bindings
wallet_core_bindings: ^4.1.21

dev_dependencies:
flutter_test:
Expand Down
5 changes: 2 additions & 3 deletions wallet_core_bindings_wasm_assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## 0.0.1

* TODO: Describe initial release.
## 4.1.21
* Sync wallet-core [4.1.21](https://github.com/trustwallet/wallet-core/releases/tag/4.1.21).
2 changes: 1 addition & 1 deletion wallet_core_bindings_wasm_assets/LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO: Add your license here.
Link to <https://github.com/trustwallet/wallet-core/blob/master/LICENSE>.
Loading

0 comments on commit 0b71bbf

Please sign in to comment.