@33cn/wallet-api
Advanced tools
Comparing version 1.3.4 to 1.4.1-beta
@@ -0,1 +1,2 @@ | ||
import { ISignTxGroupCommon } from './type'; | ||
export declare function getCurrentBTYAddress(): Promise<any>; | ||
@@ -25,1 +26,13 @@ /** | ||
export declare function configPrivCache(cachePriv?: number): Promise<any>; | ||
/** | ||
* @description 交易组签名 兼容btypay | ||
* @export | ||
* @param {ISignTxGroupCommon} { | ||
* tx: 交易hash,使用,连接 必须 | ||
* exer: 执行器 币钱包必须 | ||
* withhold: 是否代扣 -1 不代扣 1 代扣 | ||
* url 交易待发送的url | ||
* } | ||
* @returns {Promise<any>} | ||
*/ | ||
export declare function signTxGroupCommon({ tx, exer, withhold, url }: ISignTxGroupCommon): Promise<any>; |
import { Environment, getDappEnvironment, getDappEnvironmentDelay } from './dappEnvironment'; | ||
import { androidGetCurrentBTYAddress, androidSignRawTransaction, androidSignTransactionGroup, androidConfigPrivCache } from './androidJsBridge'; | ||
import { iosGetCurrentBTYAddress, iosSignRawTransaction, iosSignTransactionGroup, iosConfigPrivCache } from './iosJsBridge'; | ||
import BtyBaseSdk from '@33cn/chain33-rpc-api'; | ||
var chain33Rpc = new BtyBaseSdk('https://jiedian1.bityuan.com:8801', function (error) { | ||
console.log('catch error ' + error); | ||
}); | ||
var myWindow = window; | ||
@@ -123,2 +127,4 @@ export function getCurrentBTYAddress() { | ||
switch (getDappEnvironment()) { | ||
case Environment.lightWallet: | ||
return Promise.resolve(true); | ||
case Environment.androidBiWallet: | ||
@@ -145,2 +151,55 @@ return androidConfigPrivCache(cachePriv).then(function (res) { | ||
} | ||
/** | ||
* @description 交易组签名 兼容btypay | ||
* @export | ||
* @param {ISignTxGroupCommon} { | ||
* tx: 交易hash,使用,连接 必须 | ||
* exer: 执行器 币钱包必须 | ||
* withhold: 是否代扣 -1 不代扣 1 代扣 | ||
* url 交易待发送的url | ||
* } | ||
* @returns {Promise<any>} | ||
*/ | ||
export function signTxGroupCommon(_a) { | ||
var tx = _a.tx, exer = _a.exer, withhold = _a.withhold, url = _a.url; | ||
switch (getDappEnvironment()) { | ||
case Environment.lightWallet: | ||
var txs = tx.split(','); | ||
chain33Rpc.createRawTxGroup(txs, 'https://jiedian1.bityuan.com:8801').then(function (txs) { | ||
return myWindow.btyExtensionProvider.signGroupTx({ | ||
tx: txs, | ||
url: url, | ||
isSend: false, | ||
}); | ||
}).then(function (res) { | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
return res.result; | ||
}) | ||
.catch(function (error) { return Promise.reject(error); }); | ||
case Environment.androidBiWallet: | ||
return androidSignTransactionGroup(tx, exer, withhold).then(function (res) { | ||
console.log('打印Android签名结果', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
else { | ||
return res.signHash; | ||
} | ||
}); | ||
case Environment.iosBiWallet: | ||
return iosSignTransactionGroup(tx, exer, withhold).then(function (res) { | ||
console.log('打印IOS签名结果', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
else { | ||
return res.signHash; | ||
} | ||
}); | ||
default: | ||
return Promise.reject('invalidEnvironment'); | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -7,1 +7,7 @@ export interface ISignTx { | ||
} | ||
export interface ISignTxGroupCommon { | ||
tx: string; | ||
exer?: string; | ||
withhold?: number; | ||
url?: string; | ||
} |
{ | ||
"name": "@33cn/wallet-api", | ||
"version": "1.3.4", | ||
"version": "1.4.1-beta", | ||
"description": "提供各种比特元钱包的获取地址、签名接口", | ||
@@ -20,3 +20,9 @@ "main": "dist/index.js", | ||
"typescript": "^3.2.4" | ||
}, | ||
"dependencies": { | ||
"@33cn/chain33-rpc-api": "^1.5.18", | ||
"es6-promise": "^4.2.8", | ||
"isomorphic-fetch": "^2.2.1", | ||
"tslib": "^1.10.0" | ||
} | ||
} |
@@ -33,2 +33,23 @@ # bityuan钱包 接口调用工具 | ||
``` | ||
#### signTxGroupCommon | ||
- 功能:构造交易组、签名 | ||
- 环境:币钱包及其各个项目方的拷贝版本,btypay | ||
- 参数 | ||
- tx: string, 未签名的hash,多个hash可以由,隔开 | ||
- exer?: string, 执行器,主链执行器为none,平行链执行器为user.p.${platform}.none | ||
- withhold?: number = 1, 是否代扣 1: 代扣 -1: 不代扣 | ||
- url?: string 交易发送的url btypay环境必填 | ||
``` | ||
// 币钱包交易签名 | ||
signTxGroup({ | ||
tx: "0x1848959835460954609,0x93893548289256a678", | ||
exer: "user.p.xxx.none", | ||
withhold: -1, | ||
}) | ||
// btypay交易签名 | ||
signTxGroup({ | ||
tx: "0x1848959835460954609,0x93893548289256a678", | ||
url: "http://47.89.120.56:8089", | ||
}) | ||
``` | ||
@@ -35,0 +56,0 @@ #### configPriv |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32540
463
64
4
3
+ Addedes6-promise@^4.2.8
+ Addedisomorphic-fetch@^2.2.1
+ Addedtslib@^1.10.0
+ Added@33cn/chain33-rpc-api@1.5.30(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjson-bigint@0.3.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)