Skip to content

crypto-com/defi-wallet-core-rs

 
 

Repository files navigation

DeFi Wallet Core

Pre-requisites

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

cargo install uniffi_bindgen
uniffi-bindgen --version # check the version is 0.17.0 or newer
brew install ktlint
brew install swiftformat

Generate bindings

Android

uniffi-bindgen generate common/src/common.udl --config-path common/uniffi.toml --language kotlin --out-dir bindings/android

iOS

uniffi-bindgen generate common/src/common.udl --config-path common/uniffi.toml --language swift --out-dir bindings/ios

WASM

wasm-pack build --scope crypto-com bindings/wasm

Building

Building Proto files from source

The single proto-build crate in this repo clones and rebuilds proto files for all other crates, simply make the required edits in main.rs, then

cd proto-build # enter `proto-build`, so that we can clone repos and build proto files relative to it
cargo run # build proto files and output to `../proto/src/prost` folder

or simply run make proto.

Android

build in macos or linux

requires android sdk and ndk, java sdk

install android ndk: https://developer.android.com/ndk

suggest version r22 https://github.com/android/ndk/wiki/Unsupported-Downloads

android studio: https://developer.android.com/studio

set env ANDROID_SDK_ROOT,NDK_HOME,JAVA_HOME

such as

export ANDROID_SDK_ROOT={DIR}/Android/sdk
export NDK_HOME=$ANDROID_SDK_ROOT/ndk/22.1.7171670
export JAVA_HOME={DIR}/openjdk/17.0.1_1/

build:

make android

iOS

build in macos

Requires Xcode 13+

build:

make ios

C++

Build bindings/cpp and example/cpp_example

make build_cpp

Build bindings/cpp and example/cpp_example, and run the example programs. Please notice, errors could happen if devnets (chainmain and cronos) are not running.

make cpp

Examples

WASM

  1. generate the bindings as above
  2. cd example/js-example
  3. npm install
  4. npm start

extension example

  1. make wasmweb
  2. cd example/extension-example
  3. npm install

Integration Tests

WASM

Without nix

Please install pystarport, supervisord, chain-maind v3.3.3 or newer before running this test.

make wasm-tests

With nix

Please install nix before running this test.

make wasm-ci-tests

Cargo test

The recommended way to use wasm-bindgen-test is with wasm-pack, since it will handle installing the test runner, installing a WebDriver client for your browser, and informing cargo how to use the custom test runner. However, you can also manage those tasks yourself, if you wish.

It is also possible to use cargo test instead of wasm-pack

  1. Install wasm-bindgen-cli

    cargo install wasm-bindgen-cli
  2. Install chromdriver (for chrome)

    brew install --cask chromedriver
  3. Run the test in binding/wasm folder

    cargo test

C++

make cpp-ci-tests # build bindings and examples, then run the test
# or
make cpp-tests # run the test without building bindings and examples
References

Python

With nix

Please install nix before running this test.

make python-tests

About

Cross-platform, cross-blockchain wallet library in Rust for DeFi Wallet and other applications.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 13