@ckb-ccc/core 0.0.14-alpha.2 → 0.0.15
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/clientTypes.js +1 -1
- package/dist/client/jsonRpc/index.js +1 -1
- 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/clientTypes.js +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +1 -1
- 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/clientTypes.ts +1 -1
- package/src/client/jsonRpc/index.ts +1 -1
- 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.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8f2560a`](https://github.com/ckb-ecofund/ccc/commit/8f2560ab0e5619654fff7c5eacda8425385f908e) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): typed client errors
|
|
8
|
+
|
|
9
|
+
## 0.0.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`5e942f8`](https://github.com/ckb-ecofund/ccc/commit/5e942f8f1ed678abdb7ab9716f5449f0714cea53) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): numLeFromBytes should not modify args
|
|
14
|
+
|
|
15
|
+
- [`f5b5938`](https://github.com/ckb-ecofund/ccc/commit/f5b5938ab8f9c0a338dfd6765fe717f7ad1b1dd8) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): ErrorClient types
|
|
16
|
+
|
|
17
|
+
- ErrorClientRBFRejected
|
|
18
|
+
- ErrorClientDuplicatedTransaction
|
|
19
|
+
|
|
20
|
+
- [#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
|
|
21
|
+
|
|
22
|
+
- [#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
|
|
23
|
+
|
|
24
|
+
- [`2164efd`](https://github.com/ckb-ecofund/ccc/commit/2164efd6d834c1917ad5f4a514dc25941f937185) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Support ACP addresses for private key signer
|
|
25
|
+
|
|
26
|
+
- [`e5bd2ad`](https://github.com/ckb-ecofund/ccc/commit/e5bd2ad5de4b42a22c422ecfc42056750f69b88b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): since encoding
|
|
27
|
+
|
|
28
|
+
- [#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
|
|
29
|
+
|
|
3
30
|
## 0.0.14-alpha.2
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -52,7 +52,7 @@ export class ClientIndexerSearchKeyTransaction {
|
|
|
52
52
|
}
|
|
53
53
|
export class ErrorClientBase extends Error {
|
|
54
54
|
constructor(origin) {
|
|
55
|
-
super(origin.message);
|
|
55
|
+
super(`Client request error ${origin.message}`);
|
|
56
56
|
this.code = origin.code;
|
|
57
57
|
this.data = origin.data;
|
|
58
58
|
}
|
|
@@ -247,7 +247,7 @@ export class ClientJsonRpc extends Client {
|
|
|
247
247
|
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
248
248
|
}
|
|
249
249
|
if (res.error) {
|
|
250
|
-
throw
|
|
250
|
+
throw res.error;
|
|
251
251
|
}
|
|
252
252
|
return res.result;
|
|
253
253
|
}
|
|
@@ -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,qCAAqC,EACrC,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,GAA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AM,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
|
*
|
|
@@ -58,7 +58,7 @@ class ClientIndexerSearchKeyTransaction {
|
|
|
58
58
|
exports.ClientIndexerSearchKeyTransaction = ClientIndexerSearchKeyTransaction;
|
|
59
59
|
class ErrorClientBase extends Error {
|
|
60
60
|
constructor(origin) {
|
|
61
|
-
super(origin.message);
|
|
61
|
+
super(`Client request error ${origin.message}`);
|
|
62
62
|
this.code = origin.code;
|
|
63
63
|
this.data = origin.data;
|
|
64
64
|
}
|
|
@@ -250,7 +250,7 @@ class ClientJsonRpc extends client_js_1.Client {
|
|
|
250
250
|
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
251
251
|
}
|
|
252
252
|
if (res.error) {
|
|
253
|
-
throw
|
|
253
|
+
throw res.error;
|
|
254
254
|
}
|
|
255
255
|
return res.result;
|
|
256
256
|
}
|
|
@@ -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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AAW,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
|
@@ -249,7 +249,7 @@ export class ErrorClientBase extends Error {
|
|
|
249
249
|
public readonly data: string;
|
|
250
250
|
|
|
251
251
|
constructor(origin: ErrorClientBaseLike) {
|
|
252
|
-
super(origin.message);
|
|
252
|
+
super(`Client request error ${origin.message}`);
|
|
253
253
|
this.code = origin.code;
|
|
254
254
|
this.data = origin.data;
|
|
255
255
|
}
|
|
@@ -421,7 +421,7 @@ export abstract class ClientJsonRpc extends Client {
|
|
|
421
421
|
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
422
422
|
}
|
|
423
423
|
if (res.error) {
|
|
424
|
-
throw
|
|
424
|
+
throw res.error;
|
|
425
425
|
}
|
|
426
426
|
return res.result;
|
|
427
427
|
}
|
|
@@ -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
|
*
|