Polkadot-Dart
Dart Substrate API.
Polkadot-Dart
Polkadot-Dart is a Dart-lang library to use access API of Polkadot network.
This library contains a set of crypto libraries and implementations of utils.
Table of content
Status
Milestone 1: finished
| Status | Number | Deliverable | Specification |
|---|---|---|---|
| ☑ | 0 | Licence | Apache 2.0 |
| ☑ | 1 | bindings/crypto | Rust binding and implements @polkadot/wasm |
| ☑ | 2 | util_crypto | Porting and implements @polkadot/util-crypto |
| ☑ | 3 | utils | Porting and implements @polkadot/utils |
| ☑ | 4 | keyring | Porting and implements @polkadot/keyring |
| ☑ | 5 | networks | Porting and implements @polkadot/networks |
| ☑ | 6 | tests | Unit tests for deliverables above |
Milestone 2: Under development
| Status | Number | Deliverable | Specification |
|---|---|---|---|
| 75% | 1 | types | Porting @polkadot/types |
| 0% | 2 | rpc_core | Porting and implements @polkadot/rpc |
| 75% | 3 | rpc_provider | Porting and implements @polkadot/rpc_provider |
| 90% | 4 | metadata | Porting @polkadot/metadata |
| 0% | 5 | api_derive | Porting @polkadot/api-derive |
| 0% | 6 | api_contract | Porting @polkadot/api-contract |
| 0% | 7 | api | Porting @polkadot/api |
| 30% | 8 | type_gen | Types generator for @polkadot/types |
| 15% | 9 | tests | Unit tests for deliverables above |
| 0% | 10 | pub.dev | Publish to pub.dev for v1.0.0-dev1 |
Milestone 3: Awaits
| Status | Number | Deliverable | Specification |
|---|---|---|---|
| 0% | 1 | tests | Integration tests for all milestones |
| 0% | 2 | documentations | Documentations for all packages |
| 0% | 3 | pub.dev | Publish to pub.dev for v1.0.0 |
Manually Build
Enviorment Settings
- dart sdk: '>=2.7.0 < 3.0.0'
- flutter: '>=1.20.0 < 2.0.0'
- rust nightly latest
- MacOs or Linux
There are a few settings that needed before manually build, here is the guide.
We will try to make a .make file afterwards to simply the process.
Read before build
There are dynamic libs to be build during the process.
This repository use CI to generate dynamic libs, tests are ensured passed, better not build them yourself.
LLVM and clang
With Macos (because we need to build iOS)
brew upgrade && brew install llvm
Flutter and Dart
Follow Download and Install guide
Verify your flutter version and env settings, make sure everything works
flutter doctor -v
NDK and Android SDK
Android SDK(After Flutter is installed)
Download NDK and set
NDK_HOMEto env.export NDK_HOME=~/ndk/android-ndk-r21b # or if you use `ndk-bundle` of Android SDK locally, for macos: export ANDROID_HOME=~/Library/Android/sdk export ANDROID_NDK_HOME=~/Library/Android/sdk/ndk-bundle export NDK_HOME=~/Library/Android/sdk/ndk-bundle # and for linux, its like export NDK_HOME=/home/${User}/dev/android/ndk-bundle
Everything you need for rust
Install rust-lang and cargo, install here
All others are in
/scriptsfolder, the steps below are not neccesary , just in-case something's missing.- Install cargo-lipo(for ios building) and cbindgen
cargo install cargo-lipo && cargo install --force cbindgen- Install Android and iOS targets:
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android aarch64-apple-ios x86_64-apple-ios
Build rust lib to .so and .a manually
- Build rust binding
./scripts/clean.sh && ./scripts/init.sh && ./scripts/build.sh
- You can locate files in the android and ios folder.
- Android:
android/src/main/jniLibs/ - iOS:
ios - MacOS:
macos(Caution: Build it on macos only) - Linux:
linux(Caution: Build it on linux only) - Windows:
windows(unavailable for now)
- Android:
Testing Guide
Caution!! Do Not use flutter test directly
Run a single unit test
All test scripts are in /test folder. The folder structure matches the lib struture.
For example:
A .dart file name hex.dart
In lib folder, that is lib/utils/hex.dart
In test folder, that is test/utils/hex.dart
To test it, in root folder run flutter test test/utils/hex.dart
| lib folder | test folder | test script |
|---|---|---|
lib/utils/hex.dart |
test/utils/hex.dart |
flutter test test/utils/hex.dart |
Run all tests
The polkadot_dart_test.dart is the entry of all unit tests, simply run:
flutter test test/polkadot_dart_test.dart
Generate coverage
- if on MacOS, install
lcovfirst:brew install lcov - if on Linux:
sudo apt install lcov - then run:
./scripts/runTest.sh
Integration tests
TODO
Mobile phone tests example
Later