turing-wallet-provider 1.5.4 → 1.5.5

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 CHANGED
@@ -267,11 +267,10 @@ interface Input {
267
267
  | "tbc20" // 普通 FT 转账解锁
268
268
  | "tbc20_contract" // 普通 FT 在合约/swap 场景下的解锁
269
269
  | "tbc20_coin" // 稳定币转账解锁(FT.getFTunlock + isCoin)
270
- | "tbc20_coin_contract" // 稳定币在合约/swap 场景下的解锁(FT.getFTunlockSwap + isCoin)
271
270
  | "other"; // 脚本签名类型
272
271
  unfinishedScriptSig?: string; // "other" 类型的自定义脚本模板(hex 格式),签名部分用 097369676e6174757265 替代
273
- ftVersion?: 1 | 2; // "tbc20_contract"/"tbc20_coin_contract" 类型的 FT 版本
274
- contractTxId?: string; // "tbc20_contract"/"tbc20_coin_contract" 类型的合约交易 ID
272
+ ftVersion?: 1 | 2; // "tbc20_contract" 类型的 FT 版本
273
+ contractTxId?: string; // "tbc20_contract" 类型的合约交易 ID
275
274
  }
276
275
 
277
276
  interface Output {
@@ -394,16 +393,15 @@ const { txraws } = await Turing.signAssociatedTransaction({
394
393
  });
395
394
  ```
396
395
 
397
- ### 稳定币 (tbc20_coin / tbc20_coin_contract)
396
+ ### 稳定币转移 (tbc20_coin)
398
397
 
399
- 稳定币是一种特殊的 FT,解锁脚本与普通 FT 不同,所以提供了专用的 `scriptSigType`:
398
+ 稳定币是一种特殊的 FT,转移时的解锁脚本与普通 FT 不同,所以提供了专用的 `scriptSigType`:
400
399
 
401
400
  - `"tbc20_coin"`:稳定币普通转账解锁
402
- - `"tbc20_coin_contract"`:稳定币参与合约 / swap 场景的解锁(同时需要 `contractTxId` 与 `ftVersion`)
403
401
 
404
402
  #### 子交易 (`inputs` / `outputs`)
405
403
 
406
- 只要把对应输入的 `scriptSigType` 标成 `"tbc20_coin"` 或 `"tbc20_coin_contract"` 即可,**其它字段与普通 FT 写法完全一致**,无需关心 sequence / nLockTime。
404
+ 只要把对应输入的 `scriptSigType` 标成 `"tbc20_coin"` 即可,**其它字段与普通 FT 写法完全一致**,无需关心 sequence / nLockTime。
407
405
 
408
406
  #### 源交易 (`sourceTxraw`)
409
407
 
@@ -437,7 +435,7 @@ tx.setLockTime(lockTimeMax);
437
435
  const sourceTxraw = tx.uncheckedSerialize();
438
436
  ```
439
437
 
440
- > 对应的 `sourceUtxos` 条目仍要填 `"tbc20_coin"` 或 `"tbc20_coin_contract"`。
438
+ > 对应的 `sourceUtxos` 条目仍要填 `"tbc20_coin"`。
441
439
 
442
440
  #### 稳定币示例
443
441
 
@@ -484,17 +482,6 @@ const { txraws } = await Turing.signAssociatedTransaction({
484
482
  });
485
483
  ```
486
484
 
487
- 如果稳定币要走合约 / swap 路径,把 `scriptSigType` 改成 `"tbc20_coin_contract"`,并附上 `contractTxId` 与 `ftVersion`:
488
-
489
- ```ts
490
- {
491
- outputIndex: 0,
492
- scriptSigType: "tbc20_coin_contract",
493
- contractTxId: "<合约交易 ID>",
494
- ftVersion: 2,
495
- }
496
- ```
497
-
498
485
  ## sendTransaction
499
486
 
500
487
  使用钱包发送交易。支持多种交易类型,包括 P2PKH、NFT 操作、FT 操作和 PoolNFT 操作。
@@ -525,7 +512,7 @@ interface NFTData {
525
512
  }
526
513
 
527
514
  interface RequestParam {
528
- flag: "P2PKH" | "COLLECTION_CREATE" | "NFT_CREATE" | "NFT_TRANSFER" | "FT_MINT" | "FT_TRANSFER" | "FT_MERGE" | "POOLNFT_MINT" | "POOLNFT_INIT" | "POOLNFT_LP_INCREASE" | "POOLNFT_LP_CONSUME" | "POOLNFT_LP_BURN" | "POOLNFT_SWAP_TO_TOKEN" | "POOLNFT_SWAP_TO_TBC" | "POOLNFT_MERGE" | "FTLP_MERGE" | "STABLECOIN_CREATE" | "STABLECOIN_MINT" | "STABLECOIN_TRANSFER" | "STABLECOIN_FREEZE" | "STABLECOIN_UNFREEZE" | "STABLECOIN_MERGE";
515
+ flag: "P2PKH" | "COLLECTION_CREATE" | "NFT_CREATE" | "NFT_TRANSFER" | "FT_MINT" | "FT_TRANSFER" | "FT_MERGE" | "POOLNFT_MINT" | "POOLNFT_INIT" | "POOLNFT_LP_INCREASE" | "POOLNFT_LP_CONSUME" | "POOLNFT_LP_BURN" | "POOLNFT_SWAP_TO_TOKEN" | "POOLNFT_SWAP_TO_TBC" | "POOLNFT_MERGE" | "FTLP_MERGE" | "STABLECOIN_TRANSFER" | "STABLECOIN_MERGE";
529
516
  address?: string;
530
517
  satoshis?: number | string; // 单位为 satoshis,大数请使用 string
531
518
  collection_data?: string;
@@ -533,7 +520,7 @@ interface RequestParam {
533
520
  nft_data?: string;
534
521
  collection_id?: string;
535
522
  nft_contract_address?: string;
536
- ft_contract_address?: string; // FT 或稳定币合约交易 ID(稳定币的合约 ID 为 STABLECOIN_CREATE 返回的第一个 txid)
523
+ ft_contract_address?: string; // FT 或稳定币合约交易 ID
537
524
  tbc_amount?: number | string; // 大数请使用 string
538
525
  ft_amount?: number | string; // 大数请使用 string
539
526
  merge_times?: number;
@@ -547,11 +534,8 @@ interface RequestParam {
547
534
  lpPlan?: 1 | 2 | 3 | 4 | 5; // 默认 1
548
535
  domain?: string;
549
536
  isLockTime?: boolean;
550
- lockTime?: number | string; // 锁仓至指定区块高度(POOLNFT 相关),或冻结至指定 unix 时间戳(STABLECOIN_FREEZE),大数请使用 string
537
+ lockTime?: number | string; // 锁仓至指定区块高度(POOLNFT 相关),大数请使用 string
551
538
  broadcastEnabled?: boolean;
552
- mint_message?: string; // 铸造/增发跨链信息(STABLECOIN_CREATE / STABLECOIN_MINT 使用)
553
- utxo_txid?: string; // 目标 UTXO 的交易 ID(STABLECOIN_FREEZE / STABLECOIN_UNFREEZE 使用)
554
- utxo_index?: number; // 目标 UTXO 的输出索引(STABLECOIN_FREEZE / STABLECOIN_UNFREEZE 使用)
555
539
  }
556
540
 
557
541
  const params = [param: RequestParam];
@@ -902,54 +886,6 @@ const { txid } = await wallet.sendTransaction(params); // txid 为多个 Merge
902
886
  // const { error } = await wallet.sendTransaction(params); // 发生错误时
903
887
  ```
904
888
 
905
- ### STABLECOIN_CREATE
906
-
907
- 发行稳定币合约(仅需执行一次)。稳定币继承自 FT,构造方式与 FT 相同。
908
-
909
- ```ts
910
- const params = [
911
- {
912
- flag: "STABLECOIN_CREATE", // 必填
913
- ft_data: JSON.stringify({ // 必填,JSON 格式的 FTData
914
- name: "USD Test",
915
- symbol: "USDT",
916
- decimal: 6,
917
- amount: 100000000,
918
- }),
919
- address: "", // 必填,初始接收地址(一般是管理员自身)
920
- mint_message: "SourceChain: BSC, TXID: 34434...", // 必填,跨链信息,起始链名称和交易 id
921
- broadcastEnabled: true, // 可选,默认 true
922
- domain: "", // 可选
923
- },
924
- ];
925
-
926
- const { txid } = await wallet.sendTransaction(params); // txid 有两个,用逗号隔开,第一个 txid 即为稳定币合约 ID
927
- // const { txraw } = await wallet.sendTransaction(params); // broadcastEnabled 为 false 时,返回的 txraw 有两个,用逗号隔开,第一个 txraw 对应的 txid 即为稳定币合约 ID,需批量广播,保证前面的 txraw 先广播
928
- // const { error } = await wallet.sendTransaction(params); // 发生错误时
929
- ```
930
-
931
- ### STABLECOIN_MINT
932
-
933
- 增发稳定币(仅管理员可操作)。
934
-
935
- ```ts
936
- const params = [
937
- {
938
- flag: "STABLECOIN_MINT", // 必填
939
- ft_contract_address: "", // 必填,稳定币合约交易 ID(STABLECOIN_CREATE 返回的第一个 txid)
940
- address: "", // 必填,接收新铸稳定币的地址
941
- ft_amount: 50000, // 必填,增发数量,大数请使用 string
942
- mint_message: "SourceChain: BSC, TXID: 34434...", // 必填,跨链信息,起始链名称和交易 id
943
- broadcastEnabled: true, // 可选,默认 true
944
- domain: "", // 可选
945
- },
946
- ];
947
-
948
- const { txid } = await wallet.sendTransaction(params);
949
- // const { txraw } = await wallet.sendTransaction(params); // broadcastEnabled 为 false 时
950
- // const { error } = await wallet.sendTransaction(params); // 发生错误时
951
- ```
952
-
953
889
  ### STABLECOIN_TRANSFER
954
890
 
955
891
  转移稳定币。
@@ -958,7 +894,7 @@ const { txid } = await wallet.sendTransaction(params);
958
894
  const params = [
959
895
  {
960
896
  flag: "STABLECOIN_TRANSFER", // 必填
961
- ft_contract_address: "", // 必填,稳定币合约交易 ID(STABLECOIN_CREATE 返回的第一个 txid)
897
+ ft_contract_address: "", // 必填,稳定币合约交易 ID
962
898
  address: "", // 必填,接收地址
963
899
  ft_amount: 1000, // 必填,转移数量,大数请使用 string
964
900
  tbc_amount: 0, // 可选,同时转 TBC 和稳定币时设置此值
@@ -972,51 +908,6 @@ const { txid } = await wallet.sendTransaction(params);
972
908
  // const { error } = await wallet.sendTransaction(params); // 发生错误时
973
909
  ```
974
910
 
975
- ### STABLECOIN_FREEZE
976
-
977
- 冻结指定地址的稳定币 UTXO(仅管理员可操作)。冻结后,持有者须等到冻结到期才能使用该 UTXO。
978
-
979
- ```ts
980
- const params = [
981
- {
982
- flag: "STABLECOIN_FREEZE", // 必填
983
- ft_contract_address: "", // 必填,稳定币合约交易 ID(STABLECOIN_CREATE 返回的第一个 txid)
984
- address: "", // 必填,被冻结的目标地址
985
- utxo_txid: "", // 必填,目标稳定币 UTXO 的交易 ID
986
- utxo_index: 0, // 必填,目标稳定币 UTXO 的输出索引
987
- lockTime: 1774410989, // 必填,冻结至指定 unix 时间戳
988
- broadcastEnabled: true, // 可选,默认 true
989
- domain: "", // 可选
990
- },
991
- ];
992
-
993
- const { txid } = await wallet.sendTransaction(params);
994
- // const { txraw } = await wallet.sendTransaction(params); // broadcastEnabled 为 false 时
995
- // const { error } = await wallet.sendTransaction(params); // 发生错误时
996
- ```
997
-
998
- ### STABLECOIN_UNFREEZE
999
-
1000
- 解冻指定地址的稳定币 UTXO(仅管理员可操作)。
1001
-
1002
- ```ts
1003
- const params = [
1004
- {
1005
- flag: "STABLECOIN_UNFREEZE", // 必填
1006
- ft_contract_address: "", // 必填,稳定币合约交易 ID(STABLECOIN_CREATE 返回的第一个 txid)
1007
- address: "", // 必填,被解冻的目标地址
1008
- utxo_txid: "", // 必填,目标稳定币 UTXO 的交易 ID
1009
- utxo_index: 0, // 必填,目标稳定币 UTXO 的输出索引
1010
- broadcastEnabled: true, // 可选,默认 true
1011
- domain: "", // 可选
1012
- },
1013
- ];
1014
-
1015
- const { txid } = await wallet.sendTransaction(params);
1016
- // const { txraw } = await wallet.sendTransaction(params); // broadcastEnabled 为 false 时
1017
- // const { error } = await wallet.sendTransaction(params); // 发生错误时
1018
- ```
1019
-
1020
911
  ### STABLECOIN_MERGE
1021
912
 
1022
913
  合并稳定币 UTXO(要求所有 coinutxo 均已上链)。
@@ -1025,7 +916,7 @@ const { txid } = await wallet.sendTransaction(params);
1025
916
  const params = [
1026
917
  {
1027
918
  flag: "STABLECOIN_MERGE", // 必填
1028
- ft_contract_address: "", // 必填,稳定币合约交易 ID(STABLECOIN_CREATE 返回的第一个 txid)
919
+ ft_contract_address: "", // 必填,稳定币合约交易 ID
1029
920
  domain: "", // 可选
1030
921
  },
1031
922
  ];
@@ -1241,15 +1132,10 @@ const requests = [
1241
1132
  {
1242
1133
  method: "sendTransaction",
1243
1134
  params: {
1244
- flag: "STABLECOIN_CREATE",
1245
- ft_data: JSON.stringify({
1246
- name: "USD Test",
1247
- symbol: "USDT",
1248
- decimal: 6,
1249
- amount: 100000000,
1250
- }),
1135
+ flag: "STABLECOIN_TRANSFER",
1136
+ ft_contract_address: "",
1251
1137
  address: "",
1252
- mint_message: "SourceChain: BSC, TXID: 34434...",
1138
+ ft_amount: 1000,
1253
1139
  broadcastEnabled: true,
1254
1140
  domain: "",
1255
1141
  },
@@ -1258,7 +1144,7 @@ const requests = [
1258
1144
  method: "signMessage",
1259
1145
  params: {
1260
1146
  message: JSON.stringify({
1261
- action: "create_stablecoin",
1147
+ action: "transfer_stablecoin",
1262
1148
  }),
1263
1149
  encoding: "utf8",
1264
1150
  },
@@ -1268,10 +1154,10 @@ const requests = [
1268
1154
 
1269
1155
  const results = await wallet.sendBatchRequest(requests);
1270
1156
 
1271
- // results[0] => sendTransaction 的结果: { txid: "txid1,txid2" }
1157
+ // results[0] => sendTransaction 的结果: { txid: "txid1" }
1272
1158
  // results[1] => signMessage 的结果: { address, pubkey, sig, message }
1273
1159
  // 其中 message 为包含 txids 的完整 JSON,例如:
1274
- // { "action": "create_stablecoin", "txids": ["txid1", "txid2"] }
1160
+ // { "action": "transfer_stablecoin", "txids": ["txid1"] }
1275
1161
  ```
1276
1162
 
1277
1163
  #### 执行流程
@@ -43,11 +43,7 @@ export type TransactionFlag =
43
43
  | "POOLNFT_SWAP_TO_TBC"
44
44
  | "POOLNFT_MERGE"
45
45
  | "FTLP_MERGE"
46
- | "STABLECOIN_CREATE"
47
- | "STABLECOIN_MINT"
48
46
  | "STABLECOIN_TRANSFER"
49
- | "STABLECOIN_FREEZE"
50
- | "STABLECOIN_UNFREEZE"
51
47
  | "STABLECOIN_MERGE";
52
48
 
53
49
 
@@ -76,9 +72,6 @@ export type SendTransaction = {
76
72
  isLockTime?: boolean;
77
73
  lockTime?: number | string;
78
74
  broadcastEnabled?: boolean;
79
- mint_message?: string;
80
- utxo_txid?: string;
81
- utxo_index?: number;
82
75
  };
83
76
 
84
77
  export type SendTransactionResponse = {
@@ -134,7 +127,7 @@ export type Input = {
134
127
  script?: string;
135
128
  satoshis?: number;
136
129
  outputIndex: number;
137
- scriptSigType: "p2pkh" | "tbc20" | "tbc20_contract" | "tbc20_coin" | "tbc20_coin_contract" | "other";
130
+ scriptSigType: "p2pkh" | "tbc20" | "tbc20_contract" | "tbc20_coin" | "other";
138
131
  unfinishedScriptSig?: string;
139
132
  ftVersion?: 1 | 2;
140
133
  contractTxId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turing-wallet-provider",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [