@33cn/wallet-api
Advanced tools
Comparing version 1.4.1-beta to 1.4.1
@@ -1,2 +0,2 @@ | ||
import { ISignTxGroupCommon } from './type'; | ||
import { ISignTxGroupCommon, ISignTxCommon } from './type'; | ||
export declare function getCurrentBTYAddress(): Promise<any>; | ||
@@ -27,2 +27,13 @@ /** | ||
/** | ||
* @description 单笔交易签名 优化版 | ||
* @export | ||
* @param {ISignTxCommon} { | ||
* tx, 未签名tx | ||
* title = '', 标题 pc钱包,轻钱包必须 | ||
* address 地址 pc钱包必须 | ||
* } | ||
* @returns {Promise<any>} | ||
*/ | ||
export declare function signTxCommon({ tx, title, address }: ISignTxCommon): Promise<any>; | ||
/** | ||
* @description 交易组签名 兼容btypay | ||
@@ -29,0 +40,0 @@ * @export |
@@ -5,5 +5,3 @@ import { Environment, getDappEnvironment, getDappEnvironmentDelay } from './dappEnvironment'; | ||
import BtyBaseSdk from '@33cn/chain33-rpc-api'; | ||
var chain33Rpc = new BtyBaseSdk('https://jiedian1.bityuan.com:8801', function (error) { | ||
console.log('catch error ' + error); | ||
}); | ||
var chain33Rpc = new BtyBaseSdk('https://jiedian1.bityuan.com:8801'); | ||
var myWindow = window; | ||
@@ -55,6 +53,7 @@ export function getCurrentBTYAddress() { | ||
}).then(function (res) { | ||
console.log('signTx res', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
return res.result && res.result.signedTx; | ||
return res.signedTx; | ||
}); | ||
@@ -153,2 +152,59 @@ case Environment.androidBiWallet: | ||
/** | ||
* @description 单笔交易签名 优化版 | ||
* @export | ||
* @param {ISignTxCommon} { | ||
* tx, 未签名tx | ||
* title = '', 标题 pc钱包,轻钱包必须 | ||
* address 地址 pc钱包必须 | ||
* } | ||
* @returns {Promise<any>} | ||
*/ | ||
export function signTxCommon(_a) { | ||
var tx = _a.tx, _b = _a.title, title = _b === void 0 ? '' : _b, address = _a.address; | ||
switch (getDappEnvironment()) { | ||
case Environment.pcWallet: | ||
return myWindow.chain33Wallet.sign(tx, address, '1h', title).then(function (res) { | ||
if (res.error) { | ||
return Promise.reject(res.err); | ||
} | ||
else { | ||
return res.signed; | ||
} | ||
}); | ||
case Environment.lightWallet: | ||
return myWindow.btyExtensionProvider.signTx({ | ||
tx: tx, | ||
title: title, | ||
}).then(function (res) { | ||
console.log('signTx res', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
return res.signedTx; | ||
}); | ||
case Environment.androidBiWallet: | ||
return androidSignRawTransaction(tx).then(function (res) { | ||
console.log('打印Android签名结果', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
else { | ||
return res.signHash; | ||
} | ||
}); | ||
case Environment.iosBiWallet: | ||
return iosSignRawTransaction(tx).then(function (res) { | ||
console.log('打印IOS签名结果', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
else { | ||
return res.signHash; | ||
} | ||
}); | ||
default: | ||
return Promise.reject('invalidEnvironment'); | ||
} | ||
} | ||
/** | ||
* @description 交易组签名 兼容btypay | ||
@@ -169,5 +225,9 @@ * @export | ||
var txs = tx.split(','); | ||
chain33Rpc.createRawTxGroup(txs, 'https://jiedian1.bityuan.com:8801').then(function (txs) { | ||
return chain33Rpc.createRawTxGroup(txs, 'https://jiedian1.bityuan.com:8801').then(function (res) { | ||
console.log('createRawTxGroup res', res); | ||
if (res.error) { | ||
return Promise.reject(res.error); | ||
} | ||
return myWindow.btyExtensionProvider.signGroupTx({ | ||
tx: txs, | ||
tx: res.result, | ||
url: url, | ||
@@ -177,2 +237,3 @@ isSend: false, | ||
}).then(function (res) { | ||
console.log('signTxGroupCommon res', res); | ||
if (res.error) { | ||
@@ -182,4 +243,3 @@ return Promise.reject(res.error); | ||
return res.result; | ||
}) | ||
.catch(function (error) { return Promise.reject(error); }); | ||
}).catch(function (error) { return Promise.reject(error); }); | ||
case Environment.androidBiWallet: | ||
@@ -186,0 +246,0 @@ return androidSignTransactionGroup(tx, exer, withhold).then(function (res) { |
@@ -7,2 +7,7 @@ export interface ISignTx { | ||
} | ||
export interface ISignTxCommon { | ||
tx: string; | ||
title?: string; | ||
address?: string; | ||
} | ||
export interface ISignTxGroupCommon { | ||
@@ -9,0 +14,0 @@ tx: string; |
{ | ||
"name": "@33cn/wallet-api", | ||
"version": "1.4.1-beta", | ||
"version": "1.4.1", | ||
"description": "提供各种比特元钱包的获取地址、签名接口", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -33,2 +33,22 @@ # bityuan钱包 接口调用工具 | ||
``` | ||
#### signTxCommon | ||
- 功能:构造单笔交易签名 | ||
- 环境:币钱包及其各个项目方的拷贝版本,btypay,PC钱包 | ||
- 参数 | ||
- tx: string, 未签名的hash | ||
- title?: string, 标题 默认为'' | ||
- address?: 用户地址 PC钱包必须 | ||
``` | ||
// 币钱包交易签名 | ||
signTxCommon({ | ||
tx: "0x1848959835460954609", | ||
address: "16erdsddsadsadd432432", | ||
}) | ||
// btypay交易签名 | ||
signTxCommon({ | ||
tx: "0x1848959835460954609", | ||
title: "signTx", | ||
}) | ||
``` | ||
#### signTxGroupCommon | ||
@@ -44,3 +64,3 @@ - 功能:构造交易组、签名 | ||
// 币钱包交易签名 | ||
signTxGroup({ | ||
signTxGroupCommon({ | ||
tx: "0x1848959835460954609,0x93893548289256a678", | ||
@@ -51,3 +71,3 @@ exer: "user.p.xxx.none", | ||
// btypay交易签名 | ||
signTxGroup({ | ||
signTxGroupCommon({ | ||
tx: "0x1848959835460954609,0x93893548289256a678", | ||
@@ -54,0 +74,0 @@ url: "http://47.89.120.56:8089", |
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
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
37241
539
2
84