@ckb-ccc/core 0.0.14-alpha.1 → 0.0.14
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/CHANGELOG.md +27 -0
- package/dist/client/jsonRpc/index.d.ts +2 -1
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +4 -3
- package/dist/signer/signer/index.d.ts +25 -2
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +26 -2
- package/dist.commonjs/client/jsonRpc/index.d.ts +2 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +4 -3
- package/dist.commonjs/signer/signer/index.d.ts +25 -2
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +26 -2
- package/package.json +1 -1
- package/src/client/jsonRpc/index.ts +4 -3
- package/src/signer/signer/index.ts +91 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @ckb-ccc/core
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5e942f8`](https://github.com/ckb-ecofund/ccc/commit/5e942f8f1ed678abdb7ab9716f5449f0714cea53) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): numLeFromBytes should not modify args
|
|
8
|
+
|
|
9
|
+
- [`f5b5938`](https://github.com/ckb-ecofund/ccc/commit/f5b5938ab8f9c0a338dfd6765fe717f7ad1b1dd8) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): ErrorClient types
|
|
10
|
+
|
|
11
|
+
- ErrorClientRBFRejected
|
|
12
|
+
- ErrorClientDuplicatedTransaction
|
|
13
|
+
|
|
14
|
+
- [#56](https://github.com/ckb-ecofund/ccc/pull/56) [`f13f4d3`](https://github.com/ckb-ecofund/ccc/commit/f13f4d319ca66b571029a65e945e3a038bfeea25) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findTransactions
|
|
15
|
+
|
|
16
|
+
- [#50](https://github.com/ckb-ecofund/ccc/pull/50) [`7ba62a0`](https://github.com/ckb-ecofund/ccc/commit/7ba62a056f17808fe5684786c00c2dff80bb7d1d) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): jsonrpc id conflict
|
|
17
|
+
|
|
18
|
+
- [`2164efd`](https://github.com/ckb-ecofund/ccc/commit/2164efd6d834c1917ad5f4a514dc25941f937185) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Support ACP addresses for private key signer
|
|
19
|
+
|
|
20
|
+
- [`e5bd2ad`](https://github.com/ckb-ecofund/ccc/commit/e5bd2ad5de4b42a22c422ecfc42056750f69b88b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): since encoding
|
|
21
|
+
|
|
22
|
+
- [#48](https://github.com/ckb-ecofund/ccc/pull/48) [`aae3e06`](https://github.com/ckb-ecofund/ccc/commit/aae3e0679fb940dd8c12ac9be12a4b53277a339d) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): readable client error
|
|
23
|
+
|
|
24
|
+
## 0.0.14-alpha.2
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#50](https://github.com/ckb-ecofund/ccc/pull/50) [`7ba62a0`](https://github.com/ckb-ecofund/ccc/commit/7ba62a056f17808fe5684786c00c2dff80bb7d1d) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): jsonrpc id conflict
|
|
29
|
+
|
|
3
30
|
## 0.0.14-alpha.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -11,6 +11,7 @@ import { JsonRpcPayload } from "../transports/advanced.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare abstract class ClientJsonRpc extends Client {
|
|
13
13
|
private readonly url_;
|
|
14
|
+
private id;
|
|
14
15
|
private readonly transport;
|
|
15
16
|
/**
|
|
16
17
|
* Creates an instance of ClientJsonRpc.
|
|
@@ -174,6 +175,6 @@ export declare abstract class ClientJsonRpc extends Client {
|
|
|
174
175
|
* @param req - The parameters for the JSON-RPC method.
|
|
175
176
|
* @returns The JSON-RPC payload.
|
|
176
177
|
*/
|
|
177
|
-
|
|
178
|
+
buildPayload(method: string, req: unknown[]): JsonRpcPayload;
|
|
178
179
|
}
|
|
179
180
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EAOzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EAGf,MAAM,2BAA2B,CAAC;AA8DnC;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM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AO,GAAG,IAAI;IA+BhC;;;;;;;;OAQG;IAEH,qBAAqB,QASd,0BAA0B,UACvB,KAAK,GAAG,MAAM,UACd,OAAO,UACP,MAAM,KACX,QAAQ,uBAAuB,CAAC,CAAC;IAEtC;;;;;;;;OAQG;IAEH,qBAAqB;;;;;;;;MAQgB;IAErC;;;;;OAKG;IAEH,gBAAgB,QAIL,0BAA0B,KAAK,QAAQ,GAAG,CAAC,CAAC;IAEvD;;;;;;;OAOG;IAEH,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,GACnC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC;IAwC1C;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAerD;;;;;;OAMG;IAEH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQ7D"}
|
|
@@ -61,6 +61,7 @@ export class ClientJsonRpc extends Client {
|
|
|
61
61
|
constructor(url_, config) {
|
|
62
62
|
super(config);
|
|
63
63
|
this.url_ = url_;
|
|
64
|
+
this.id = 0;
|
|
64
65
|
/**
|
|
65
66
|
* Get tip block number
|
|
66
67
|
*
|
|
@@ -208,7 +209,7 @@ export class ClientJsonRpc extends Client {
|
|
|
208
209
|
*/
|
|
209
210
|
buildSender(rpcMethod, inTransformers, outTransformer) {
|
|
210
211
|
return async (...req) => {
|
|
211
|
-
const payload =
|
|
212
|
+
const payload = this.buildPayload(rpcMethod, await Promise.all(req
|
|
212
213
|
.concat(Array.from(new Array(Math.max(inTransformers.length - req.length, 0))))
|
|
213
214
|
.map((v, i) => transform(v, inTransformers[i]))));
|
|
214
215
|
try {
|
|
@@ -257,9 +258,9 @@ export class ClientJsonRpc extends Client {
|
|
|
257
258
|
* @param req - The parameters for the JSON-RPC method.
|
|
258
259
|
* @returns The JSON-RPC payload.
|
|
259
260
|
*/
|
|
260
|
-
|
|
261
|
+
buildPayload(method, req) {
|
|
261
262
|
return {
|
|
262
|
-
id:
|
|
263
|
+
id: this.id++,
|
|
263
264
|
method,
|
|
264
265
|
params: req,
|
|
265
266
|
jsonrpc: "2.0",
|
|
@@ -2,7 +2,7 @@ import { Address } from "../../address/index.js";
|
|
|
2
2
|
import { ClientCollectableSearchKeyFilterLike } from "../../advancedBarrel.js";
|
|
3
3
|
import { BytesLike } from "../../bytes/index.js";
|
|
4
4
|
import { Cell, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
5
|
-
import { Client } from "../../client/index.js";
|
|
5
|
+
import { Client, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse } from "../../client/index.js";
|
|
6
6
|
import { Hex } from "../../hex/index.js";
|
|
7
7
|
import { Num } from "../../num/index.js";
|
|
8
8
|
/**
|
|
@@ -129,7 +129,30 @@ export declare abstract class Signer {
|
|
|
129
129
|
* @returns A promise that resolves to an array of addresses as strings.
|
|
130
130
|
*/
|
|
131
131
|
getAddresses(): Promise<string[]>;
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Find cells of this signer
|
|
134
|
+
*
|
|
135
|
+
* @returns A async generator that yields all matches cells
|
|
136
|
+
*/
|
|
137
|
+
findCells(filter: ClientCollectableSearchKeyFilterLike, withData?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
|
|
138
|
+
/**
|
|
139
|
+
* Find transactions of this signer
|
|
140
|
+
*
|
|
141
|
+
* @returns A async generator that yields all matches transactions
|
|
142
|
+
*/
|
|
143
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
|
|
144
|
+
/**
|
|
145
|
+
* Find transactions of this signer
|
|
146
|
+
*
|
|
147
|
+
* @returns A async generator that yields all matches transactions
|
|
148
|
+
*/
|
|
149
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
|
|
150
|
+
/**
|
|
151
|
+
* Find transactions of this signer
|
|
152
|
+
*
|
|
153
|
+
* @returns A async generator that yields all matches transactions
|
|
154
|
+
*/
|
|
155
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
|
|
133
156
|
/**
|
|
134
157
|
* Gets balance of all addresses
|
|
135
158
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,MAAM,EACN,qCA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AM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -125,7 +125,12 @@ export class Signer {
|
|
|
125
125
|
async getAddresses() {
|
|
126
126
|
return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Find cells of this signer
|
|
130
|
+
*
|
|
131
|
+
* @returns A async generator that yields all matches cells
|
|
132
|
+
*/
|
|
133
|
+
async *findCells(filter, withData, order, limit) {
|
|
129
134
|
const scripts = await this.getAddressObjs();
|
|
130
135
|
for (const { script } of scripts) {
|
|
131
136
|
for await (const cell of this.client.findCells({
|
|
@@ -134,11 +139,30 @@ export class Signer {
|
|
|
134
139
|
filter,
|
|
135
140
|
scriptSearchMode: "exact",
|
|
136
141
|
withData,
|
|
137
|
-
})) {
|
|
142
|
+
}, order, limit)) {
|
|
138
143
|
yield cell;
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Find transactions of this signer
|
|
149
|
+
*
|
|
150
|
+
* @returns A async generator that yields all matches transactions
|
|
151
|
+
*/
|
|
152
|
+
async *findTransactions(filter, groupByTransaction, order, limit) {
|
|
153
|
+
const scripts = await this.getAddressObjs();
|
|
154
|
+
for (const { script } of scripts) {
|
|
155
|
+
for await (const transaction of this.client.findTransactions({
|
|
156
|
+
script,
|
|
157
|
+
scriptType: "lock",
|
|
158
|
+
filter,
|
|
159
|
+
scriptSearchMode: "exact",
|
|
160
|
+
groupByTransaction,
|
|
161
|
+
}, order, limit)) {
|
|
162
|
+
yield transaction;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
142
166
|
/**
|
|
143
167
|
* Gets balance of all addresses
|
|
144
168
|
*
|
|
@@ -11,6 +11,7 @@ import { JsonRpcPayload } from "../transports/advanced.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare abstract class ClientJsonRpc extends Client {
|
|
13
13
|
private readonly url_;
|
|
14
|
+
private id;
|
|
14
15
|
private readonly transport;
|
|
15
16
|
/**
|
|
16
17
|
* Creates an instance of ClientJsonRpc.
|
|
@@ -174,6 +175,6 @@ export declare abstract class ClientJsonRpc extends Client {
|
|
|
174
175
|
* @param req - The parameters for the JSON-RPC method.
|
|
175
176
|
* @returns The JSON-RPC payload.
|
|
176
177
|
*/
|
|
177
|
-
|
|
178
|
+
buildPayload(method: string, req: unknown[]): JsonRpcPayload;
|
|
178
179
|
}
|
|
179
180
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EAOzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EAGf,MAAM,2BAA2B,CAAC;AA8DnC;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,YAAY,EACZ,eAAe,EAChB,MAAM,oBAAoB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K,QAAQ,yBAAyB,GAAG,SAAS,CAAC,CAAC;IAEzE;;;;;;;OAOG;IACH,kBAAkB,CAChB,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,EACzB,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI;IA+BhC;;;;;;;;OAQG;IAEH,qBAAqB,QASd,0BAA0B,UACvB,KAAK,GAAG,MAAM,UACd,OAAO,UACP,MAAM,KACX,QAAQ,uBAAuB,CAAC,CAAC;IAEtC;;;;;;;;OAQG;IAEH,qBAAqB;;;;;;;;MAQgB;IAErC;;;;;OAKG;IAEH,gBAAgB,QAIL,0BAA0B,KAAK,QAAQ,GAAG,CAAC,CAAC;IAEvD;;;;;;;OAOG;IAEH,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,GACnC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC;IAwC1C;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAerD;;;;;;OAMG;IAEH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQ7D"}
|
|
@@ -64,6 +64,7 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
64
64
|
constructor(url_, config) {
|
|
65
65
|
super(config);
|
|
66
66
|
this.url_ = url_;
|
|
67
|
+
this.id = 0;
|
|
67
68
|
/**
|
|
68
69
|
* Get tip block number
|
|
69
70
|
*
|
|
@@ -211,7 +212,7 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
211
212
|
*/
|
|
212
213
|
buildSender(rpcMethod, inTransformers, outTransformer) {
|
|
213
214
|
return async (...req) => {
|
|
214
|
-
const payload =
|
|
215
|
+
const payload = this.buildPayload(rpcMethod, await Promise.all(req
|
|
215
216
|
.concat(Array.from(new Array(Math.max(inTransformers.length - req.length, 0))))
|
|
216
217
|
.map((v, i) => transform(v, inTransformers[i]))));
|
|
217
218
|
try {
|
|
@@ -260,9 +261,9 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
260
261
|
* @param req - The parameters for the JSON-RPC method.
|
|
261
262
|
* @returns The JSON-RPC payload.
|
|
262
263
|
*/
|
|
263
|
-
|
|
264
|
+
buildPayload(method, req) {
|
|
264
265
|
return {
|
|
265
|
-
id:
|
|
266
|
+
id: this.id++,
|
|
266
267
|
method,
|
|
267
268
|
params: req,
|
|
268
269
|
jsonrpc: "2.0",
|
|
@@ -2,7 +2,7 @@ import { Address } from "../../address/index.js";
|
|
|
2
2
|
import { ClientCollectableSearchKeyFilterLike } from "../../advancedBarrel.js";
|
|
3
3
|
import { BytesLike } from "../../bytes/index.js";
|
|
4
4
|
import { Cell, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
5
|
-
import { Client } from "../../client/index.js";
|
|
5
|
+
import { Client, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse } from "../../client/index.js";
|
|
6
6
|
import { Hex } from "../../hex/index.js";
|
|
7
7
|
import { Num } from "../../num/index.js";
|
|
8
8
|
/**
|
|
@@ -129,7 +129,30 @@ export declare abstract class Signer {
|
|
|
129
129
|
* @returns A promise that resolves to an array of addresses as strings.
|
|
130
130
|
*/
|
|
131
131
|
getAddresses(): Promise<string[]>;
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Find cells of this signer
|
|
134
|
+
*
|
|
135
|
+
* @returns A async generator that yields all matches cells
|
|
136
|
+
*/
|
|
137
|
+
findCells(filter: ClientCollectableSearchKeyFilterLike, withData?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<Cell>;
|
|
138
|
+
/**
|
|
139
|
+
* Find transactions of this signer
|
|
140
|
+
*
|
|
141
|
+
* @returns A async generator that yields all matches transactions
|
|
142
|
+
*/
|
|
143
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction?: false | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
|
|
144
|
+
/**
|
|
145
|
+
* Find transactions of this signer
|
|
146
|
+
*
|
|
147
|
+
* @returns A async generator that yields all matches transactions
|
|
148
|
+
*/
|
|
149
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction: true, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
|
|
150
|
+
/**
|
|
151
|
+
* Find transactions of this signer
|
|
152
|
+
*
|
|
153
|
+
* @returns A async generator that yields all matches transactions
|
|
154
|
+
*/
|
|
155
|
+
findTransactions(filter: ClientCollectableSearchKeyFilterLike, groupByTransaction?: boolean | null, order?: "asc" | "desc", limit?: number): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0] | ClientFindTransactionsGroupedResponse["transactions"][0]>;
|
|
133
156
|
/**
|
|
134
157
|
* Gets balance of all addresses
|
|
135
158
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCA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CAAC,WAAW,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;;GAGG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -129,7 +129,12 @@ class Signer {
|
|
|
129
129
|
async getAddresses() {
|
|
130
130
|
return this.getAddressObjs().then((addresses) => addresses.map((address) => address.toString()));
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Find cells of this signer
|
|
134
|
+
*
|
|
135
|
+
* @returns A async generator that yields all matches cells
|
|
136
|
+
*/
|
|
137
|
+
async *findCells(filter, withData, order, limit) {
|
|
133
138
|
const scripts = await this.getAddressObjs();
|
|
134
139
|
for (const { script } of scripts) {
|
|
135
140
|
for await (const cell of this.client.findCells({
|
|
@@ -138,11 +143,30 @@ class Signer {
|
|
|
138
143
|
filter,
|
|
139
144
|
scriptSearchMode: "exact",
|
|
140
145
|
withData,
|
|
141
|
-
})) {
|
|
146
|
+
}, order, limit)) {
|
|
142
147
|
yield cell;
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Find transactions of this signer
|
|
153
|
+
*
|
|
154
|
+
* @returns A async generator that yields all matches transactions
|
|
155
|
+
*/
|
|
156
|
+
async *findTransactions(filter, groupByTransaction, order, limit) {
|
|
157
|
+
const scripts = await this.getAddressObjs();
|
|
158
|
+
for (const { script } of scripts) {
|
|
159
|
+
for await (const transaction of this.client.findTransactions({
|
|
160
|
+
script,
|
|
161
|
+
scriptType: "lock",
|
|
162
|
+
filter,
|
|
163
|
+
scriptSearchMode: "exact",
|
|
164
|
+
groupByTransaction,
|
|
165
|
+
}, order, limit)) {
|
|
166
|
+
yield transaction;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
146
170
|
/**
|
|
147
171
|
* Gets balance of all addresses
|
|
148
172
|
*
|
package/package.json
CHANGED
|
@@ -93,6 +93,7 @@ const ERROR_PARSERS: [
|
|
|
93
93
|
*/
|
|
94
94
|
|
|
95
95
|
export abstract class ClientJsonRpc extends Client {
|
|
96
|
+
private id = 0;
|
|
96
97
|
private readonly transport: Transport;
|
|
97
98
|
|
|
98
99
|
/**
|
|
@@ -364,7 +365,7 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
364
365
|
outTransformer?: (_: any) => unknown,
|
|
365
366
|
): (...req: unknown[]) => Promise<unknown> {
|
|
366
367
|
return async (...req: unknown[]) => {
|
|
367
|
-
const payload =
|
|
368
|
+
const payload = this.buildPayload(
|
|
368
369
|
rpcMethod,
|
|
369
370
|
await Promise.all(
|
|
370
371
|
req
|
|
@@ -433,9 +434,9 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
433
434
|
* @returns The JSON-RPC payload.
|
|
434
435
|
*/
|
|
435
436
|
|
|
436
|
-
|
|
437
|
+
buildPayload(method: string, req: unknown[]): JsonRpcPayload {
|
|
437
438
|
return {
|
|
438
|
-
id:
|
|
439
|
+
id: this.id++,
|
|
439
440
|
method,
|
|
440
441
|
params: req,
|
|
441
442
|
jsonrpc: "2.0",
|
|
@@ -2,7 +2,11 @@ import { Address } from "../../address/index.js";
|
|
|
2
2
|
import { ClientCollectableSearchKeyFilterLike } from "../../advancedBarrel.js";
|
|
3
3
|
import { BytesLike } from "../../bytes/index.js";
|
|
4
4
|
import { Cell, Transaction, TransactionLike } from "../../ckb/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Client,
|
|
7
|
+
ClientFindTransactionsGroupedResponse,
|
|
8
|
+
ClientFindTransactionsResponse,
|
|
9
|
+
} from "../../client/index.js";
|
|
6
10
|
import { Hex } from "../../hex/index.js";
|
|
7
11
|
import { Num } from "../../num/index.js";
|
|
8
12
|
import { verifyMessageBtcEcdsa } from "../btc/index.js";
|
|
@@ -226,24 +230,103 @@ export abstract class Signer {
|
|
|
226
230
|
);
|
|
227
231
|
}
|
|
228
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Find cells of this signer
|
|
235
|
+
*
|
|
236
|
+
* @returns A async generator that yields all matches cells
|
|
237
|
+
*/
|
|
229
238
|
async *findCells(
|
|
230
239
|
filter: ClientCollectableSearchKeyFilterLike,
|
|
231
240
|
withData?: boolean | null,
|
|
241
|
+
order?: "asc" | "desc",
|
|
242
|
+
limit?: number,
|
|
232
243
|
): AsyncGenerator<Cell> {
|
|
233
244
|
const scripts = await this.getAddressObjs();
|
|
234
245
|
for (const { script } of scripts) {
|
|
235
|
-
for await (const cell of this.client.findCells(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
for await (const cell of this.client.findCells(
|
|
247
|
+
{
|
|
248
|
+
script,
|
|
249
|
+
scriptType: "lock",
|
|
250
|
+
filter,
|
|
251
|
+
scriptSearchMode: "exact",
|
|
252
|
+
withData,
|
|
253
|
+
},
|
|
254
|
+
order,
|
|
255
|
+
limit,
|
|
256
|
+
)) {
|
|
242
257
|
yield cell;
|
|
243
258
|
}
|
|
244
259
|
}
|
|
245
260
|
}
|
|
246
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Find transactions of this signer
|
|
264
|
+
*
|
|
265
|
+
* @returns A async generator that yields all matches transactions
|
|
266
|
+
*/
|
|
267
|
+
findTransactions(
|
|
268
|
+
filter: ClientCollectableSearchKeyFilterLike,
|
|
269
|
+
groupByTransaction?: false | null,
|
|
270
|
+
order?: "asc" | "desc",
|
|
271
|
+
limit?: number,
|
|
272
|
+
): AsyncGenerator<ClientFindTransactionsResponse["transactions"][0]>;
|
|
273
|
+
/**
|
|
274
|
+
* Find transactions of this signer
|
|
275
|
+
*
|
|
276
|
+
* @returns A async generator that yields all matches transactions
|
|
277
|
+
*/
|
|
278
|
+
findTransactions(
|
|
279
|
+
filter: ClientCollectableSearchKeyFilterLike,
|
|
280
|
+
groupByTransaction: true,
|
|
281
|
+
order?: "asc" | "desc",
|
|
282
|
+
limit?: number,
|
|
283
|
+
): AsyncGenerator<ClientFindTransactionsGroupedResponse["transactions"][0]>;
|
|
284
|
+
/**
|
|
285
|
+
* Find transactions of this signer
|
|
286
|
+
*
|
|
287
|
+
* @returns A async generator that yields all matches transactions
|
|
288
|
+
*/
|
|
289
|
+
findTransactions(
|
|
290
|
+
filter: ClientCollectableSearchKeyFilterLike,
|
|
291
|
+
groupByTransaction?: boolean | null,
|
|
292
|
+
order?: "asc" | "desc",
|
|
293
|
+
limit?: number,
|
|
294
|
+
): AsyncGenerator<
|
|
295
|
+
| ClientFindTransactionsResponse["transactions"][0]
|
|
296
|
+
| ClientFindTransactionsGroupedResponse["transactions"][0]
|
|
297
|
+
>;
|
|
298
|
+
/**
|
|
299
|
+
* Find transactions of this signer
|
|
300
|
+
*
|
|
301
|
+
* @returns A async generator that yields all matches transactions
|
|
302
|
+
*/
|
|
303
|
+
async *findTransactions(
|
|
304
|
+
filter: ClientCollectableSearchKeyFilterLike,
|
|
305
|
+
groupByTransaction?: boolean | null,
|
|
306
|
+
order?: "asc" | "desc",
|
|
307
|
+
limit?: number,
|
|
308
|
+
): AsyncGenerator<
|
|
309
|
+
| ClientFindTransactionsResponse["transactions"][0]
|
|
310
|
+
| ClientFindTransactionsGroupedResponse["transactions"][0]
|
|
311
|
+
> {
|
|
312
|
+
const scripts = await this.getAddressObjs();
|
|
313
|
+
for (const { script } of scripts) {
|
|
314
|
+
for await (const transaction of this.client.findTransactions(
|
|
315
|
+
{
|
|
316
|
+
script,
|
|
317
|
+
scriptType: "lock",
|
|
318
|
+
filter,
|
|
319
|
+
scriptSearchMode: "exact",
|
|
320
|
+
groupByTransaction,
|
|
321
|
+
},
|
|
322
|
+
order,
|
|
323
|
+
limit,
|
|
324
|
+
)) {
|
|
325
|
+
yield transaction;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
247
330
|
/**
|
|
248
331
|
* Gets balance of all addresses
|
|
249
332
|
*
|