@ckb-ccc/core 0.0.8-alpha.3 → 0.0.9-alpha.0

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