Sending.Network provides an extension plug-in platform, enabling developers to enrich the messaging features by interacting with third-party dapps or smart contracts.
Currently, Sending.Network has 3 built-in plugin projects: message-type-plugin, did-method-plugin and social-graph-plugin, and developers are free to develop other plugin projects. Plugin projects are lightweight, pluggable, and easy to deploy. The following sections introduce how to compile and deploy message-type-plugin plugin projects in environments like Web, IOS, and Android.
1. JavaScript
1.1 Compile and install
Please contact developer@sending.network for the wasm files.
At the root directory of message-type-plugin
// generate the wasm package of the plugin project
cd message-type-plugin
./build-wasm.sh
A package called message-type-plugin.wasm will be found in the directory web/.
At the root directory of the Radix main project
// generate the wasm package of the Radix main project
cd radix
./build-wasm.sh
// generate service worker sw.js
cd web/
yarn install
yarn build
A package called server.wasm will be found in the directory web/. sw.js will be generated in the web/dist/.
1.2 Deploy and Register
1.2.1 Deploy
Replace the sw.js and two wasm packages with the newly built ones, clear the web page cache data and refresh it.
1.2.2 Register the Plugin
By launching the message-type-plugin.wasm, the plugin will be automatically registered into Radix main Process. However, you can also register/unregister the plugin by executing console scripts. In the console of your Chrome browser, run the following scripts to register/unregister trading Dapp plugins like Lucky Box and Peer Swap.
Plugin features can be used by calling the interfaces from the frontend.
For instance, http://localhost/_api/media/v3/query_message_type this interface can return all of the supported trading Dapp message types.
The frontend can fetch all of the registered plugins by calling this API.
2. iOS & Android
2.1 Compile the Plugin Project
At the root directory of message-type-plugin:
// iOS
cd message-type-plugin
bash build/gobind-plugin/build.sh -i
//Android
cd message-type-plugin
bash build/gobind-plugin/build.sh -a
Then integrate the generated packages into your iOS or Android SDK.
3. Dapp Callback
In Web3 trading Dapps, there are always some scenes that you need to call a JS API to query data like a user profile. In Sending.Network, trading Dapps like LuckyBox and PeerSwap will fetch user profiles and interact with the P2P nodes. The following section provides a generic guide on how to call a JS API from third-party Dapps.
3.1 Preparation
Install postmate
yarn add postmate
3.2 API Provider (Web applications that provide APIs to Dapps)