Adding Features to Indy-VDR #2195
wadeking98
started this conversation in
Guides
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Indy-VDR Development for BC Wallet
indy-vdr is used to fetch objects from the configured ledgers such as schemas, cred defs, revocation registries, etc. The library is written in rust and has JS, Python, and Go wrappers.
This will focus on adding functionality to the JS wrappers in Node and React Native.
This tutorial is designed for intel linux systems building for android, it likely won't work for M1 macs.
This tutorial assumes you have
cargoup and running and you're familiar with JS and Rust. Also make sure you've cloned the indy-vdr repo: https://github.com/hyperledger/indy-vdr.gitAdding Foreign Function Interfaces (FFIs)
This section will show you how to add new functions to indy-vdr and expose them to the JS wrappers using FFIs. The first thing you're going to need to do is to add your function entry point, go to
libindy_vdr > src > ffi > mod.rsand add your wrapper function. Here's an example of the wrapper function created for transaction caching:FFIs don't work so well with unsigned ints so it's best to use signed ints instead. Also use
FFiStrinstead of normal rust strings. Now that your FFI has been created, it needs to be exposed to the javascript wrappers.Go to
libindy_vdr > include > libindy_vdr.hand add the a your function signature like so:Next go to
wrappers > javascript > indy-vdr-nodejs > src > NodeJSIndyVdr.tsand add a signature like the following:Next we're going to go to
wrappers > javascript > indy-vdr-nodejs > src > library > bindings.tsand add a signature like so:In
wrappers > javascript > indy-vdr-nodejs > src > library > NativeBindings.tsadd a signature like this:now we need to add a few mode cpp signatures. Go to
wrappers > javascript > indy-vdr-react-native > cpp > indyVdr.cppand add a section like this:You'll also need a section in
wrappers > javascript > indy-vdr-react-native > cpp > include > libindy_vdr.hlike so:Now we need to made our exported function
setLedgerTxnCacheaccessible. Go towrappers > javascriopt > indy-vdr-react-native > cpp > HostObject.cppand add a statement like so:Then go to
wrappers > javascript > indy-vdr-react-native > cpp > indyVdr.hand add the following entry:Next we need to add it to the React Native bindings, go to
wrappers > javascript > indy-vdr-react-native > src > NativeBindings.tsThen we need to go to
wrappers > javascript > indy-vdr-react-native > src > ReactNativeIndyVdr.tsand add a function like so:Finally for
wrappers > javascript > indy-vdr-shared > src > types > IndyVdr.tsadd the following section:now we're done adding FFIs to the JS wrappers, we can build the packages. Go to
wrappers > javascriptand runyarn installthen runyarn build.To test and apply your changes in BC Wallet you're going to have to run

yarn patch @hyperledger/<PACKAGE_NAME>for each ofindy-vdr-react-nativeandindy-vdr-sharedpaste the folders generated by theyarn buildcommand into corresponding yarn patch folders and commit the patch. Now your function signatures are up to date, you just need to build and compile the binaries. At this point of the process your node_modules folders should look something like this:Make sure the node modules are copied into the BC Wallet
app/folder as well as the project root.Building the Binaries
The last part we need to complete is to build the rust binaries for all the android architectures. If you get lost it's a good idea to take a look at the build.yaml file in
.github > workflowswe're basically copying the android build steps.Run the following command to install cross:
cargo install --bins --git https://github.com/rust-embedded/cross --locked --tag v0.2.4 crossNext we're going to build each of the 4 binaries for android. Make sure you have docker installed and the daemon is running.
run the following command for the 4 architectures:
cross build --lib --release --target aarch64-linux-android --package indy-vdrif you get an error like the following:
...bin/ld: cannot find -lunwindthen you need to revert to using rust1.67. Rust the following command to fix itNote the builds may take a long time.
After the build complete, each binary will be located at the following folders:
indy-vdr/target/<ARCHITECHTURE>/release/libindy_vdr.soYou'll place each of these
.sofiles in the corresponding react-native-indy-vdr node_modules folder undernative > mobile > android > <ARCHITECHTURE>The architecture name used during the build stage is slightly different than the folder it goes into, here's a table that shows which folder each architecture goes into:
By the end your indy-vdr-react-native node_modules folders should look like this:

Now you should be ready to start BC Wallet with your new rust features available
Beta Was this translation helpful? Give feedback.
All reactions