@ckb-ccc/core 0.0.10-alpha.4 → 0.0.10-alpha.6

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.
Files changed (135) hide show
  1. package/dist/address/address.advanced.js +4 -2
  2. package/dist/ckb/transaction.d.ts.map +1 -1
  3. package/dist/ckb/transaction.js +1 -2
  4. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +1 -0
  5. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  6. package/dist/signer/ckb/signerCkbPrivateKey.js +7 -7
  7. package/dist/signer/signer/index.d.ts +0 -9
  8. package/dist/signer/signer/index.d.ts.map +1 -1
  9. package/dist/signer/signer/index.js +6 -13
  10. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  11. package/dist.commonjs/address/address.advanced.js +91 -115
  12. package/dist.commonjs/address/advanced.d.ts +1 -1
  13. package/dist.commonjs/address/advanced.js +14 -30
  14. package/dist.commonjs/address/index.d.ts +44 -51
  15. package/dist.commonjs/address/index.js +65 -84
  16. package/dist.commonjs/advanced.d.ts +1 -1
  17. package/dist.commonjs/advanced.js +22 -47
  18. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  19. package/dist.commonjs/advancedBarrel.js +14 -30
  20. package/dist.commonjs/barrel.d.ts +1 -1
  21. package/dist.commonjs/barrel.js +14 -30
  22. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  23. package/dist.commonjs/bytes/index.d.ts +3 -9
  24. package/dist.commonjs/bytes/index.js +26 -28
  25. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  26. package/dist.commonjs/ckb/advanced.js +22 -47
  27. package/dist.commonjs/ckb/index.d.ts +1 -1
  28. package/dist.commonjs/ckb/index.js +14 -30
  29. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  30. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  31. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  32. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  33. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  34. package/dist.commonjs/ckb/script.advanced.js +9 -12
  35. package/dist.commonjs/ckb/script.d.ts +117 -121
  36. package/dist.commonjs/ckb/script.js +176 -220
  37. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  38. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  39. package/dist.commonjs/ckb/transaction.d.ts +722 -806
  40. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  41. package/dist.commonjs/ckb/transaction.js +1190 -1424
  42. package/dist.commonjs/client/advanced.d.ts +1 -1
  43. package/dist.commonjs/client/advanced.js +14 -30
  44. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  45. package/dist.commonjs/client/client.advanced.js +61 -89
  46. package/dist.commonjs/client/client.d.ts +54 -114
  47. package/dist.commonjs/client/client.js +182 -215
  48. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  49. package/dist.commonjs/client/clientPublicMainnet.advanced.js +189 -215
  50. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  51. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  52. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  53. package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -227
  54. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  55. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  56. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  57. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  58. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  59. package/dist.commonjs/client/clientTypes.js +22 -56
  60. package/dist.commonjs/client/index.d.ts +1 -1
  61. package/dist.commonjs/client/index.js +14 -30
  62. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  63. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  64. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  65. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  66. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  67. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  68. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  69. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  70. package/dist.commonjs/fixedPoint/index.js +20 -26
  71. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  72. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  73. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  74. package/dist.commonjs/hasher/index.d.ts +37 -40
  75. package/dist.commonjs/hasher/index.js +48 -58
  76. package/dist.commonjs/hex/index.d.ts +1 -1
  77. package/dist.commonjs/hex/index.js +1 -1
  78. package/dist.commonjs/index.d.ts +1 -1
  79. package/dist.commonjs/index.js +22 -47
  80. package/dist.commonjs/num/index.d.ts +1 -1
  81. package/dist.commonjs/num/index.js +27 -39
  82. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  83. package/dist.commonjs/signer/btc/index.js +14 -30
  84. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  85. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  86. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  87. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  88. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  89. package/dist.commonjs/signer/btc/verify.js +3 -10
  90. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  91. package/dist.commonjs/signer/ckb/index.js +14 -30
  92. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +6 -5
  93. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  94. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +28 -42
  95. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +11 -11
  96. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +35 -45
  97. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  98. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  99. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +3 -9
  100. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +5 -13
  101. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  102. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  103. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  104. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  105. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  106. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  107. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  108. package/dist.commonjs/signer/dummy/index.js +14 -30
  109. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  110. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  111. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  112. package/dist.commonjs/signer/evm/index.js +14 -30
  113. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  114. package/dist.commonjs/signer/evm/signerEvm.js +70 -105
  115. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  116. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  117. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  118. package/dist.commonjs/signer/evm/verify.js +2 -7
  119. package/dist.commonjs/signer/index.d.ts +1 -1
  120. package/dist.commonjs/signer/index.js +14 -30
  121. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  122. package/dist.commonjs/signer/nostr/index.js +14 -30
  123. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  124. package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
  125. package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
  126. package/dist.commonjs/signer/nostr/verify.js +39 -50
  127. package/dist.commonjs/signer/signer/index.d.ts +153 -171
  128. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  129. package/dist.commonjs/signer/signer/index.js +191 -234
  130. package/dist.commonjs/utils/index.d.ts +9 -42
  131. package/dist.commonjs/utils/index.js +12 -18
  132. package/package.json +3 -3
  133. package/src/address/address.advanced.ts +4 -4
  134. package/src/signer/ckb/signerCkbPrivateKey.ts +8 -8
  135. package/src/signer/signer/index.ts +6 -14
@@ -10,228 +10,195 @@ const client_advanced_1 = require("./client.advanced");
10
10
  const clientTypes_1 = require("./clientTypes");
11
11
  var KnownScript;
12
12
  (function (KnownScript) {
13
- KnownScript["Secp256k1Blake160"] = "Secp256k1Blake160";
14
- KnownScript["Secp256k1Multisig"] = "Secp256k1Multisig";
15
- KnownScript["AnyoneCanPay"] = "AnyoneCanPay";
16
- KnownScript["TypeId"] = "TypeId";
17
- KnownScript["XUdt"] = "XUdt";
18
- KnownScript["JoyId"] = "JoyId";
19
- KnownScript["COTA"] = "COTA";
20
- KnownScript["OmniLock"] = "OmniLock";
21
- KnownScript["NostrLock"] = "NostrLock";
22
- KnownScript["UniqueType"] = "UniqueType";
23
- KnownScript["SingleUseLock"] = "SingleUseLock";
24
- KnownScript["OutputTypeProxyLock"] = "OutputTypeProxyLock";
13
+ KnownScript["Secp256k1Blake160"] = "Secp256k1Blake160";
14
+ KnownScript["Secp256k1Multisig"] = "Secp256k1Multisig";
15
+ KnownScript["AnyoneCanPay"] = "AnyoneCanPay";
16
+ KnownScript["TypeId"] = "TypeId";
17
+ KnownScript["XUdt"] = "XUdt";
18
+ KnownScript["JoyId"] = "JoyId";
19
+ KnownScript["COTA"] = "COTA";
20
+ KnownScript["OmniLock"] = "OmniLock";
21
+ KnownScript["NostrLock"] = "NostrLock";
22
+ KnownScript["UniqueType"] = "UniqueType";
23
+ KnownScript["SingleUseLock"] = "SingleUseLock";
24
+ KnownScript["OutputTypeProxyLock"] = "OutputTypeProxyLock";
25
25
  })(KnownScript || (exports.KnownScript = KnownScript = {}));
26
26
  class CellDepInfo {
27
- constructor(cellDep, type) {
28
- this.cellDep = cellDep;
29
- this.type = type;
30
- }
31
- static from(cellDepInfoLike) {
32
- return new CellDepInfo(
33
- ckb_1.CellDep.from(cellDepInfoLike.cellDep),
34
- (0, utils_1.apply)(ckb_1.Script.from, cellDepInfoLike.type),
35
- );
36
- }
27
+ constructor(cellDep, type) {
28
+ this.cellDep = cellDep;
29
+ this.type = type;
30
+ }
31
+ static from(cellDepInfoLike) {
32
+ return new CellDepInfo(ckb_1.CellDep.from(cellDepInfoLike.cellDep), (0, utils_1.apply)(ckb_1.Script.from, cellDepInfoLike.type));
33
+ }
37
34
  }
38
35
  exports.CellDepInfo = CellDepInfo;
39
36
  class Client {
40
- constructor() {
41
- this.cachedTransactions = [];
42
- this.unusableOutPoints = [];
43
- this.usableCells = [];
44
- this.knownCells = [];
45
- }
46
- async markUsable(cellLike) {
47
- const cell = ckb_1.Cell.from(cellLike).clone();
48
- this.usableCells.push(cell);
49
- this.knownCells.push(cell);
50
- const index = this.unusableOutPoints.findIndex((o) => cell.outPoint.eq(o));
51
- if (index !== -1) {
52
- this.unusableOutPoints.splice(index, 1);
53
- }
54
- }
55
- async markUnusable(outPointLike) {
56
- const outPoint = ckb_1.OutPoint.from(outPointLike);
57
- this.unusableOutPoints.push(outPoint.clone());
58
- const index = this.usableCells.findIndex((c) => c.outPoint.eq(outPoint));
59
- if (index !== -1) {
60
- this.usableCells.splice(index, 1);
61
- }
62
- }
63
- async getCell(outPointLike) {
64
- const outPoint = ckb_1.OutPoint.from(outPointLike);
65
- const cached = this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
66
- if (cached) {
67
- return cached.clone();
68
- }
69
- const transaction = await this.getTransactionNoCache(outPoint.txHash);
70
- if (!transaction) {
71
- return null;
72
- }
73
- const index = Number((0, num_1.numFrom)(outPoint.index));
74
- if (index >= transaction.transaction.outputs.length) {
75
- return null;
76
- }
77
- const cell = ckb_1.Cell.from({
78
- outPoint,
79
- cellOutput: transaction.transaction.outputs[index],
80
- outputData: transaction.transaction.outputsData[index] ?? "0x",
81
- });
82
- this.knownCells.push(cell);
83
- return cell.clone();
84
- }
85
- async findCellsPaged(key, order, limit, after) {
86
- const res = await this.findCellsPagedNoCache(key, order, limit, after);
87
- this.knownCells.push(...res.cells);
88
- return res;
89
- }
90
- async *findCells(key, order, limit = 10) {
91
- let last = undefined;
92
- while (true) {
93
- const { cells, lastCursor } = await this.findCellsPaged(
94
- key,
95
- order,
96
- limit,
97
- last,
98
- );
99
- for (const cell of cells) {
100
- yield cell;
101
- }
102
- if (cells.length === 0 || cells.length < limit) {
103
- return;
104
- }
105
- last = lastCursor;
106
- }
107
- }
108
- /**
109
- * Find cells by search key designed for collectable cells.
110
- *
111
- * @param key - The search key.
112
- * @returns A async generator for yielding cells.
113
- */
114
- async *findCellsByCollectableSearchKey(keyLike, order, limit = 10) {
115
- const key = clientTypes_1.ClientIndexerSearchKey.from(keyLike);
116
- for (const cell of this.usableCells) {
117
- if ((0, client_advanced_1.filterCell)(key, cell)) {
118
- yield cell;
119
- }
120
- }
121
- for await (const cell of this.findCells(key, order, limit)) {
122
- if (!this.unusableOutPoints.some((o) => o.eq(cell.outPoint))) {
123
- yield cell;
124
- }
125
- }
126
- }
127
- findCellsByLockAndType(lock, type, withData = true, order, limit = 10) {
128
- return this.findCellsByCollectableSearchKey(
129
- {
130
- script: lock,
131
- scriptType: "lock",
132
- scriptSearchMode: "exact",
133
- filter: {
134
- script: type,
135
- },
136
- withData,
137
- },
138
- order,
139
- limit,
140
- );
141
- }
142
- findCellsByType(type, withData = true, order, limit = 10) {
143
- return this.findCellsByCollectableSearchKey(
144
- {
145
- script: type,
146
- scriptType: "type",
147
- scriptSearchMode: "exact",
148
- withData,
149
- },
150
- order,
151
- limit,
152
- );
153
- }
154
- async findSingletonCellByType(type, withData = false) {
155
- for await (const cell of this.findCellsByType(
156
- type,
157
- withData,
158
- undefined,
159
- 1,
160
- )) {
161
- return cell;
162
- }
163
- }
164
- async getCellDeps(...cellDepsInfoLike) {
165
- return Promise.all(
166
- cellDepsInfoLike.flat().map(async (infoLike) => {
167
- const { cellDep, type } = CellDepInfo.from(infoLike);
168
- if (type === undefined) {
169
- return cellDep;
37
+ constructor() {
38
+ this.cachedTransactions = [];
39
+ this.unusableOutPoints = [];
40
+ this.usableCells = [];
41
+ this.knownCells = [];
42
+ }
43
+ async markUsable(cellLike) {
44
+ const cell = ckb_1.Cell.from(cellLike).clone();
45
+ this.usableCells.push(cell);
46
+ this.knownCells.push(cell);
47
+ const index = this.unusableOutPoints.findIndex((o) => cell.outPoint.eq(o));
48
+ if (index !== -1) {
49
+ this.unusableOutPoints.splice(index, 1);
50
+ }
51
+ }
52
+ async markUnusable(outPointLike) {
53
+ const outPoint = ckb_1.OutPoint.from(outPointLike);
54
+ this.unusableOutPoints.push(outPoint.clone());
55
+ const index = this.usableCells.findIndex((c) => c.outPoint.eq(outPoint));
56
+ if (index !== -1) {
57
+ this.usableCells.splice(index, 1);
58
+ }
59
+ }
60
+ async getCell(outPointLike) {
61
+ const outPoint = ckb_1.OutPoint.from(outPointLike);
62
+ const cached = this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
63
+ if (cached) {
64
+ return cached.clone();
170
65
  }
171
- const found = await this.findSingletonCellByType(type);
172
- if (!found) {
173
- return cellDep;
66
+ const transaction = await this.getTransactionNoCache(outPoint.txHash);
67
+ if (!transaction) {
68
+ return null;
174
69
  }
175
- return ckb_1.CellDep.from({
176
- outPoint: found.outPoint,
177
- depType: cellDep.depType,
70
+ const index = Number((0, num_1.numFrom)(outPoint.index));
71
+ if (index >= transaction.transaction.outputs.length) {
72
+ return null;
73
+ }
74
+ const cell = ckb_1.Cell.from({
75
+ outPoint,
76
+ cellOutput: transaction.transaction.outputs[index],
77
+ outputData: transaction.transaction.outputsData[index] ?? "0x",
178
78
  });
179
- }),
180
- );
181
- }
182
- async getBalanceSingle(lock) {
183
- return this.getCellsCapacity({
184
- script: lock,
185
- scriptType: "lock",
186
- scriptSearchMode: "exact",
187
- filter: {
188
- scriptLenRange: [0, 1],
189
- outputDataLenRange: [0, 1],
190
- },
191
- });
192
- }
193
- async getBalance(locks) {
194
- return (0, utils_1.reduceAsync)(
195
- locks,
196
- async (acc, lock) => acc + (await this.getBalanceSingle(lock)),
197
- fixedPoint_1.Zero,
198
- );
199
- }
200
- async sendTransaction(transaction, validator) {
201
- const tx = ckb_1.Transaction.from(transaction);
202
- const txHash = await this.sendTransactionNoCache(tx, validator);
203
- this.cachedTransactions.push(tx.clone());
204
- await Promise.all(
205
- tx.inputs.map((i) => this.markUnusable(i.previousOutput)),
206
- );
207
- await Promise.all(
208
- tx.outputs.map((o, i) =>
209
- this.markUsable({
210
- cellOutput: o,
211
- outputData: tx.outputsData[i],
212
- outPoint: {
213
- txHash,
214
- index: i,
215
- },
216
- }),
217
- ),
218
- );
219
- return txHash;
220
- }
221
- async getTransaction(txHashLike) {
222
- const txHash = (0, hex_1.hexFrom)(txHashLike);
223
- const res = await this.getTransactionNoCache(txHash);
224
- if (res !== null) {
225
- return res;
226
- }
227
- const tx = this.cachedTransactions.find((t) => t.hash() === txHash);
228
- if (!tx) {
229
- return null;
230
- }
231
- return {
232
- transaction: tx,
233
- status: "proposed",
234
- };
235
- }
79
+ this.knownCells.push(cell);
80
+ return cell.clone();
81
+ }
82
+ async findCellsPaged(key, order, limit, after) {
83
+ const res = await this.findCellsPagedNoCache(key, order, limit, after);
84
+ this.knownCells.push(...res.cells);
85
+ return res;
86
+ }
87
+ async *findCells(key, order, limit = 10) {
88
+ let last = undefined;
89
+ while (true) {
90
+ const { cells, lastCursor } = await this.findCellsPaged(key, order, limit, last);
91
+ for (const cell of cells) {
92
+ yield cell;
93
+ }
94
+ if (cells.length === 0 || cells.length < limit) {
95
+ return;
96
+ }
97
+ last = lastCursor;
98
+ }
99
+ }
100
+ /**
101
+ * Find cells by search key designed for collectable cells.
102
+ *
103
+ * @param key - The search key.
104
+ * @returns A async generator for yielding cells.
105
+ */
106
+ async *findCellsByCollectableSearchKey(keyLike, order, limit = 10) {
107
+ const key = clientTypes_1.ClientIndexerSearchKey.from(keyLike);
108
+ for (const cell of this.usableCells) {
109
+ if ((0, client_advanced_1.filterCell)(key, cell)) {
110
+ yield cell;
111
+ }
112
+ }
113
+ for await (const cell of this.findCells(key, order, limit)) {
114
+ if (!this.unusableOutPoints.some((o) => o.eq(cell.outPoint))) {
115
+ yield cell;
116
+ }
117
+ }
118
+ }
119
+ findCellsByLockAndType(lock, type, withData = true, order, limit = 10) {
120
+ return this.findCellsByCollectableSearchKey({
121
+ script: lock,
122
+ scriptType: "lock",
123
+ scriptSearchMode: "exact",
124
+ filter: {
125
+ script: type,
126
+ },
127
+ withData,
128
+ }, order, limit);
129
+ }
130
+ findCellsByType(type, withData = true, order, limit = 10) {
131
+ return this.findCellsByCollectableSearchKey({
132
+ script: type,
133
+ scriptType: "type",
134
+ scriptSearchMode: "exact",
135
+ withData,
136
+ }, order, limit);
137
+ }
138
+ async findSingletonCellByType(type, withData = false) {
139
+ for await (const cell of this.findCellsByType(type, withData, undefined, 1)) {
140
+ return cell;
141
+ }
142
+ }
143
+ async getCellDeps(...cellDepsInfoLike) {
144
+ return Promise.all(cellDepsInfoLike.flat().map(async (infoLike) => {
145
+ const { cellDep, type } = CellDepInfo.from(infoLike);
146
+ if (type === undefined) {
147
+ return cellDep;
148
+ }
149
+ const found = await this.findSingletonCellByType(type);
150
+ if (!found) {
151
+ return cellDep;
152
+ }
153
+ return ckb_1.CellDep.from({
154
+ outPoint: found.outPoint,
155
+ depType: cellDep.depType,
156
+ });
157
+ }));
158
+ }
159
+ async getBalanceSingle(lock) {
160
+ return this.getCellsCapacity({
161
+ script: lock,
162
+ scriptType: "lock",
163
+ scriptSearchMode: "exact",
164
+ filter: {
165
+ scriptLenRange: [0, 1],
166
+ outputDataLenRange: [0, 1],
167
+ },
168
+ });
169
+ }
170
+ async getBalance(locks) {
171
+ return (0, utils_1.reduceAsync)(locks, async (acc, lock) => acc + (await this.getBalanceSingle(lock)), fixedPoint_1.Zero);
172
+ }
173
+ async sendTransaction(transaction, validator) {
174
+ const tx = ckb_1.Transaction.from(transaction);
175
+ const txHash = await this.sendTransactionNoCache(tx, validator);
176
+ this.cachedTransactions.push(tx.clone());
177
+ await Promise.all(tx.inputs.map((i) => this.markUnusable(i.previousOutput)));
178
+ await Promise.all(tx.outputs.map((o, i) => this.markUsable({
179
+ cellOutput: o,
180
+ outputData: tx.outputsData[i],
181
+ outPoint: {
182
+ txHash,
183
+ index: i,
184
+ },
185
+ })));
186
+ return txHash;
187
+ }
188
+ async getTransaction(txHashLike) {
189
+ const txHash = (0, hex_1.hexFrom)(txHashLike);
190
+ const res = await this.getTransactionNoCache(txHash);
191
+ if (res !== null) {
192
+ return res;
193
+ }
194
+ const tx = this.cachedTransactions.find((t) => t.hash() === txHash);
195
+ if (!tx) {
196
+ return null;
197
+ }
198
+ return {
199
+ transaction: tx,
200
+ status: "proposed",
201
+ };
202
+ }
236
203
  }
237
204
  exports.Client = Client;
@@ -1,10 +1,6 @@
1
1
  import { Script } from "../ckb";
2
2
  import { CellDepInfoLike, KnownScript } from "./client";
3
- export declare const MAINNET_SCRIPTS: Record<
4
- KnownScript,
5
- | (Pick<Script, "codeHash" | "hashType"> & {
6
- cellDeps: CellDepInfoLike[];
7
- })
8
- | undefined
9
- >;
10
- //# sourceMappingURL=clientPublicMainnet.advanced.d.ts.map
3
+ export declare const MAINNET_SCRIPTS: Record<KnownScript, (Pick<Script, "codeHash" | "hashType"> & {
4
+ cellDeps: CellDepInfoLike[];
5
+ }) | undefined>;
6
+ //# sourceMappingURL=clientPublicMainnet.advanced.d.ts.map