doughnut-js
v1.0.1
Published
Doughnut API for DAPP.
Downloads
3
Readme
doughnut-js
Doughnut API for DAPP.
Javascript SDK for Doughnut Dapp.
Installation
npm install doughnut-js
Usage
Npm
var donut = require('doughnut-js')
console.log(donut.isConnected());
Browser
<script src="./dist/donut.min.js"></script>
<script>
console.log(donut.isConnected());
</script>
Contents
1. API
1.1 donut.isConnected
donut.isConnected()
1.2 donut.getAppInfo
donut.getAppInfo()
Returns
Object
:
result
:Boolean
data
:Object
name
:String
system
:String
version
:String
sys_version
:String
msg
:String
Example
donut.getAppInfo().then(console.log)
> {
result: true,
data: {
name: 'Doughnut',
system: 'android',
version: '1.1.0',
sys_version: '24'
},
msg: 'success'
}
1.3 donut.getDeviceId
donut.getDeviceId()
Returns
String
Example
donut.getDeviceId().then(console.log)
> "76a4651d-41a2-4580-859a-5ede75d8c75c"
1.4 donut.getCurrentWallet
获取用户当前钱包信息
donut.getCurrentWallet()
Returns
Object
:
result
:Boolean
data
:Object
name
:String
address
:String
msg
:String
Example
donut.getCurrentWallet().then(console.log)
> {
result: true,
data: {
name: 'test',
address: 'jBvrdYc6G437hipoCiEpTwrWSRBS2ahXN6',
},
msg: 'success'
}
1.5 donut.getWallets
获取用户钱包列表
donut.getWallets()
Returns
Object
:
result
:Boolean
data
:Array
address
:String
name
:String
msg
:String
Example
donut.getWallets().then(console.log)
> {
result: true,
data: [
{
name: 'test',
address: 'jBvrdYc6G437hipoCiEpTwrWSRBS2ahXN6',
},
{
name: 'ceshi',
address: 'jGqcZ3Zgy9EPaFs89zSv44K8hh7qLsNtBw',
}
],
msg: 'success'
}
1.6 donut.sign
donut.sign(params)
Parameters
params
- Object
: tx object
to
:String
currency
:Float
issuer
:String|Object
value
:String|Object
gas
:String
memo
:Number
Returns
Object
:
result
:Boolean
signedTx
:Stirng
msg
:String
Example
var tx = {
"to": "jKBCwv4EcyvYtD4PafP17PLpnnZ16szQsC",
"currency": "swt",
"issuer": "",
"value": "0.001",
"memo": "test for sign",
"gas": "0.0001"
}
donut.sign(tx).then(console.log)
> {
result: true,
signedTx: "12000022800000002...E68EA5E58FA3E1F1",
msg: 'success'
}
1.7 donut.transfer
donut.transfer(params)
Parameters
params
- Object
: tx object
to
:String
currency
:Float
issuer
:String|Object
value
:String|Object
gas
:String
memo
:Number
Returns
Object
:
result
:Boolean
txHash
:Stirng
msg
:String
Example
var tx = {
"to": "jKBCwv4EcyvYtD4PafP17PLpnnZ16szQsC",
"currency": "swt",
"issuer": "",
"value": "0.001",
"memo": "test for transfer",
"gas": "0.0001"
}
donut.transfer(tx).then(console.log)
> {
result: true,
txHash: "092DD86EF938CFBE344BC26AAA0F36DAE3632535B5439B9CB5BDBD5693691B69",
msg: 'success'
}
1.8 donut.invokeQRScanner
扫码
donut.invokeQRScanner()
Returns
String
Example
donut.invokeQRScanner().then(console.log)
> "jKBCwv4EcyvYtD4PafP17PLpnnZ16szQsC"
1.9 donut.back
donut.back()
Example
donut.back()
1.10 donut.close
donut.close()
Example
donut.close()
1.11 donut.fullScreen
donut.fullScreen(params)
Parameters
params
:
String
1 - fullScreen, 0 - cancel
Example
donut.fullScreen(1)
1.12 donut.shareToSNS
donut.shareToSNS(params)
Parameters
params
- Object
: object
title
:String
url
:Float
text
:String|Object
imgUrl
:String|Object
Example
var params = {
"title": "js分享",
"url": "https://github.com/HFJingchuang/doughnut-js",
"text": "js分享测试",
"imgUrl": "http://www.someserver.com/测试图片网络地址.jpg"
}
donut.shareToSNS(params)