turing-wallet-provider 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -31
- package/dist/types/providerTypes.d.ts +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,51 +13,51 @@ root.render(
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {
|
|
16
|
+
import { useTuringWallet } from "turing-wallet-provider";
|
|
17
17
|
|
|
18
|
-
const wallet =
|
|
18
|
+
const wallet = useTuringWallet();
|
|
19
19
|
await wallet.connect();
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## disconnect
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
const wallet =
|
|
25
|
+
const wallet = useTuringWallet();
|
|
26
26
|
await wallet.disconnect();
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## isConnected
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
const wallet =
|
|
32
|
+
const wallet = useTuringWallet();
|
|
33
33
|
const ture/false = await wallet.isConnected();
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## getPubKey
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
const wallet =
|
|
39
|
+
const wallet = useTuringWallet();
|
|
40
40
|
const { tbcPubKey } = await wallet.getPubKey(); //tbcPubKey为string类型
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## getAddress
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
|
-
const wallet =
|
|
46
|
+
const wallet = useTuringWallet();
|
|
47
47
|
const { tbcAddress } = await wallet.getAddress(); //tbcAddress为string类型
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
## getBalance
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
const wallet =
|
|
53
|
+
const wallet = useTuringWallet();
|
|
54
54
|
const { tbc } = await wallet.getBalance(); //tbc为number类型,单位为tbc
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
## getInfo
|
|
58
58
|
|
|
59
59
|
```ts
|
|
60
|
-
const wallet =
|
|
60
|
+
const wallet = useTuringWallet();
|
|
61
61
|
const {name,platform,version} = await wallet.getInfo();
|
|
62
62
|
{Turing,android,1.0.0}示例的返回值
|
|
63
63
|
```
|
|
@@ -65,7 +65,7 @@ const {name,platform,version} = await wallet.getInfo();
|
|
|
65
65
|
## signMessage
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
|
-
const wallet =
|
|
68
|
+
const wallet = useTuringWallet();
|
|
69
69
|
try{
|
|
70
70
|
const { address, pubKey, sig, message } = await wallet.signMessage({ message: "hello world", encoding: "base64" });//encoding可为utf-8,base64,hex
|
|
71
71
|
}catch(error){
|
|
@@ -82,7 +82,7 @@ const true/false = tbc.Message.verify(msg_buf,address,sig);
|
|
|
82
82
|
## encrypt
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
|
-
const wallet =
|
|
85
|
+
const wallet = useTuringWallet();
|
|
86
86
|
try {
|
|
87
87
|
const { encryptedMessage } = await wallet.encrypt({ message });
|
|
88
88
|
if (encryptedMessage) {
|
|
@@ -96,7 +96,7 @@ try {
|
|
|
96
96
|
## decrypt
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
|
-
const wallet =
|
|
99
|
+
const wallet = useTuringWallet();
|
|
100
100
|
try {
|
|
101
101
|
const { decryptedMessage } = await wallet.decrypt({ message });
|
|
102
102
|
if (decryptedMessage) {
|
|
@@ -136,7 +136,7 @@ for (let i = 0; i < utxosB.length; i++) {
|
|
|
136
136
|
utxos_satoshis[1].push(utxosB[i].satoshis);
|
|
137
137
|
script_pubkeys[1].push(utxosB[i].script);
|
|
138
138
|
}
|
|
139
|
-
const wallet =
|
|
139
|
+
const wallet = useTuringWallet();
|
|
140
140
|
const { sigs } = await wallet.signTransaction({
|
|
141
141
|
txraws,
|
|
142
142
|
utxos_satoshis,
|
|
@@ -213,11 +213,13 @@ interface RequestParam = {
|
|
|
213
213
|
lpCostAddress?: string;//设置添加流动性扣款地址
|
|
214
214
|
lpCostAmount?: number;//设置添加流动性扣款TBC数量
|
|
215
215
|
pubKeyLock?: string[];
|
|
216
|
-
poolNFT_version?: number; //
|
|
216
|
+
poolNFT_version?: number; // 废弃字段强制为2,若提供为别的值转为2
|
|
217
217
|
serviceFeeRate?: number; // 0-100 poolNFT_version为2有效 不提供默认为25
|
|
218
218
|
serverProvider_tag?:string; //poolNFT_version为2时为必需字段 poolNFT_version为1无效
|
|
219
|
-
lpPlan?:number //1或2 不提供默认为1 lp手续费方案, 方案1: LP 0.25% swap服务商 0.09% 协议0.01%; 方案2: LP 0.05% swap服务商 0.29% 协议0.01%
|
|
220
|
-
domain?:string // 设置构建及广播交易使用的节点和api服务 只支持https 不提供默认值是
|
|
219
|
+
lpPlan?:number; //1或2 不提供默认为1 lp手续费方案, 方案1: LP 0.25% swap服务商 0.09% 协议0.01%; 方案2: LP 0.05% swap服务商 0.29% 协议0.01%
|
|
220
|
+
domain?:string; // 设置构建及广播交易使用的节点和api服务 只支持https 不提供默认值是api.turingbitchain.io 具体结构为https://${domain}/api/tbc
|
|
221
|
+
isLockTime?: boolean;//是否具备锁仓功能
|
|
222
|
+
lockTime?: number;//锁仓至lockTime区块高度
|
|
221
223
|
};
|
|
222
224
|
|
|
223
225
|
const params = [param:RequestParam] //目前参数里只能放一个对象,有批量发送需求再扩展
|
|
@@ -313,14 +315,15 @@ const { txid } = await wallet.sendTransaction(params);
|
|
|
313
315
|
const params = [{
|
|
314
316
|
flag:"POOLNFT_MINT",
|
|
315
317
|
ft_contract_address:"",
|
|
316
|
-
poolNFT_version
|
|
318
|
+
poolNFT_version?: 2,
|
|
317
319
|
serverProvider_tag?:"",
|
|
318
320
|
serviceFeeRate?:25, // poolNFT_version为2时此参数有效,默认为25
|
|
319
|
-
with_lock?:false //默认值为false,为true则创建带哈希锁的poolNFT
|
|
320
|
-
pubKeyLock?:["pubkey1","pubkey2"]
|
|
321
|
-
lpCostAddress?:""
|
|
322
|
-
lpCostAmount?:5
|
|
323
|
-
lpPlan?:1 //默认值为1
|
|
321
|
+
with_lock?:false, //默认值为false,为true则创建带哈希锁的poolNFT
|
|
322
|
+
pubKeyLock?:["pubkey1","pubkey2"],
|
|
323
|
+
lpCostAddress?:"",//设置添加流动性扣款地址
|
|
324
|
+
lpCostAmount?:5,//设置添加流动性扣款TBC数量
|
|
325
|
+
lpPlan?:1, //默认值为1
|
|
326
|
+
isLockTime?: false, //是否具备锁仓功能 默认为false
|
|
324
327
|
domain?: "",
|
|
325
328
|
}];
|
|
326
329
|
const { txid } = await wallet.sendTransaction(params);
|
|
@@ -335,10 +338,11 @@ const params = [{
|
|
|
335
338
|
address:"",
|
|
336
339
|
tbc_amount:30,
|
|
337
340
|
ft_amount:1000,
|
|
338
|
-
poolNFT_version
|
|
341
|
+
poolNFT_version?: 2,
|
|
342
|
+
locktime?: 900000,锁仓至指定区块高度
|
|
339
343
|
domain?: "",
|
|
340
344
|
}];
|
|
341
|
-
const { txid
|
|
345
|
+
const { txid } = await wallet.sendTransaction(params);
|
|
342
346
|
```
|
|
343
347
|
|
|
344
348
|
### POOLNFT_LP_INCREASE
|
|
@@ -349,10 +353,11 @@ const params = [{
|
|
|
349
353
|
nft_contract_address:"",
|
|
350
354
|
address:"",
|
|
351
355
|
tbc_amount:3,
|
|
352
|
-
poolNFT_version
|
|
356
|
+
poolNFT_version?: 2,
|
|
357
|
+
locktime?: 900000,锁仓至指定区块高度
|
|
353
358
|
domain?: "",
|
|
354
359
|
}];
|
|
355
|
-
const { txid
|
|
360
|
+
const { txid } = await wallet.sendTransaction(params);
|
|
356
361
|
```
|
|
357
362
|
|
|
358
363
|
### POOLNFT_LP_CONSUME
|
|
@@ -363,7 +368,7 @@ const params = [{
|
|
|
363
368
|
nft_contract_address:"",
|
|
364
369
|
address:"",
|
|
365
370
|
ft_amount:100,
|
|
366
|
-
poolNFT_version
|
|
371
|
+
poolNFT_version?: 2,
|
|
367
372
|
domain?: "",
|
|
368
373
|
}];
|
|
369
374
|
const { txid } = await wallet.sendTransaction(params);
|
|
@@ -377,8 +382,8 @@ const params = [{
|
|
|
377
382
|
nft_contract_address:"",
|
|
378
383
|
address:"",
|
|
379
384
|
tbc_amount:10,
|
|
380
|
-
poolNFT_version
|
|
381
|
-
lpPlan?:1 //默认值为1
|
|
385
|
+
poolNFT_version?: 2,
|
|
386
|
+
lpPlan?:1, //默认值为1
|
|
382
387
|
domain?: "",
|
|
383
388
|
}];
|
|
384
389
|
const { txid } = await wallet.sendTransaction(params);
|
|
@@ -392,7 +397,7 @@ const params = [{
|
|
|
392
397
|
nft_contract_address:"",
|
|
393
398
|
address:"",
|
|
394
399
|
ft_amount:10,
|
|
395
|
-
poolNFT_version
|
|
400
|
+
poolNFT_version?: 2,
|
|
396
401
|
lpPlan?:1 //默认值为1,
|
|
397
402
|
domain?: "",
|
|
398
403
|
}];
|
|
@@ -405,7 +410,7 @@ const { txid } = await wallet.sendTransaction(params);
|
|
|
405
410
|
const params = [{
|
|
406
411
|
flag:"POOLNFT_MERGE",
|
|
407
412
|
nft_contract_address:"",
|
|
408
|
-
poolNFT_version
|
|
413
|
+
poolNFT_version?: 2,
|
|
409
414
|
merge_times?:1, //1-10次 默认为10次 不足10次会提前终止
|
|
410
415
|
domain?: "",
|
|
411
416
|
}];
|
|
@@ -418,7 +423,7 @@ const { txid } = await wallet.sendTransaction(params);
|
|
|
418
423
|
const params = [{
|
|
419
424
|
flag:"FTLP_MERGE",
|
|
420
425
|
nft_contract_address:"",
|
|
421
|
-
poolNFT_version
|
|
426
|
+
poolNFT_version?: 2,
|
|
422
427
|
domain?: "",
|
|
423
428
|
}];
|
|
424
429
|
const { txid } = await wallet.sendTransaction(params);
|
|
@@ -14,7 +14,7 @@ export type Info = {
|
|
|
14
14
|
name: string;
|
|
15
15
|
platform: string;
|
|
16
16
|
version: string;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
19
|
export type TransactionFlag =
|
|
20
20
|
| "P2PKH"
|
|
@@ -54,6 +54,8 @@ export type SendTransaction = {
|
|
|
54
54
|
serviceProvider_flag?: string;
|
|
55
55
|
lpPlan?: number;
|
|
56
56
|
domain?: string;
|
|
57
|
+
isLockTime?: boolean;
|
|
58
|
+
locktime?: number;
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
export type SendTransactionResponse = {
|
|
@@ -115,8 +117,12 @@ export type TuringProviderType = {
|
|
|
115
117
|
sendTransaction: (
|
|
116
118
|
params: SendTransaction[]
|
|
117
119
|
) => Promise<SendTransactionResponse | undefined>;
|
|
118
|
-
signTransaction: (
|
|
119
|
-
|
|
120
|
+
signTransaction: (
|
|
121
|
+
params: SignTransaction
|
|
122
|
+
) => Promise<SignTransactionResponse | undefined>;
|
|
123
|
+
signMessage: (
|
|
124
|
+
params: SignMessage
|
|
125
|
+
) => Promise<SignMessageResponse | undefined>;
|
|
120
126
|
encrypt: (params: Encrypt) => Promise<EncryptResponse | undefined>;
|
|
121
127
|
decrypt: (params: Decrypt) => Promise<DecryptResponse | undefined>;
|
|
122
128
|
};
|