algosdk 2.10.0 → 2.11.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 (28) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/client/v2/algod/block.js +21 -0
  5. package/dist/cjs/client/v2/algod/block.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/models/types.js +2 -27
  7. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  8. package/dist/cjs/client/v2/indexer/indexer.js +15 -0
  9. package/dist/cjs/client/v2/indexer/indexer.js.map +1 -1
  10. package/dist/cjs/client/v2/indexer/searchForBlockHeaders.js +209 -0
  11. package/dist/cjs/client/v2/indexer/searchForBlockHeaders.js.map +1 -0
  12. package/dist/esm/client/v2/algod/block.js +21 -0
  13. package/dist/esm/client/v2/algod/block.js.map +1 -1
  14. package/dist/esm/client/v2/algod/models/types.js +0 -24
  15. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  16. package/dist/esm/client/v2/indexer/indexer.js +15 -0
  17. package/dist/esm/client/v2/indexer/indexer.js.map +1 -1
  18. package/dist/esm/client/v2/indexer/searchForBlockHeaders.js +203 -0
  19. package/dist/esm/client/v2/indexer/searchForBlockHeaders.js.map +1 -0
  20. package/dist/types/client/v2/algod/block.d.ts +18 -0
  21. package/dist/types/client/v2/algod/models/types.d.ts +0 -17
  22. package/dist/types/client/v2/indexer/indexer.d.ts +13 -0
  23. package/dist/types/client/v2/indexer/searchForBlockHeaders.d.ts +172 -0
  24. package/package.json +1 -1
  25. package/src/client/v2/algod/block.ts +22 -0
  26. package/src/client/v2/algod/models/types.ts +0 -32
  27. package/src/client/v2/indexer/indexer.ts +16 -0
  28. package/src/client/v2/indexer/searchForBlockHeaders.ts +212 -0
@@ -7,5 +7,23 @@ export default class Block extends JSONRequest {
7
7
  private round;
8
8
  constructor(c: HTTPClient, roundNumber: number);
9
9
  path(): string;
10
+ /**
11
+ * If true, only the block header (exclusive of payset or certificate) may be included in response.
12
+ *
13
+ * #### Example
14
+ * ```typescript
15
+ *
16
+ * const roundNumber = 41000000;
17
+ *
18
+ * const blockResponse = await algodClient
19
+ * .block(roundNumber)
20
+ * .headerOnly(true)
21
+ * .do();
22
+ * ```
23
+ *
24
+ * @param headerOnly - the flag indicating whether exclusively return header in response
25
+ * @category query
26
+ */
27
+ headerOnly(headerOnly: boolean): this;
10
28
  prepare(body: Uint8Array): Record<string, any>;
11
29
  }
@@ -992,23 +992,6 @@ export declare class BlockHashResponse extends BaseModel {
992
992
  });
993
993
  static from_obj_for_encoding(data: Record<string, any>): BlockHashResponse;
994
994
  }
995
- /**
996
- * Block header.
997
- */
998
- export declare class BlockHeaderResponse extends BaseModel {
999
- /**
1000
- * Block header data.
1001
- */
1002
- blockheader?: BlockHeader;
1003
- /**
1004
- * Creates a new `BlockHeaderResponse` object.
1005
- * @param blockheader - Block header data.
1006
- */
1007
- constructor({ blockheader }: {
1008
- blockheader?: BlockHeader;
1009
- });
1010
- static from_obj_for_encoding(data: Record<string, any>): BlockHeaderResponse;
1011
- }
1012
995
  /**
1013
996
  * All logs emitted in the given round. Each app call, whether top-level or inner,
1014
997
  * that contains logs results in a separate AppCallLogs object. Therefore there may
@@ -15,6 +15,7 @@ import LookupApplications from './lookupApplications';
15
15
  import LookupApplicationLogs from './lookupApplicationLogs';
16
16
  import LookupApplicationBoxByIDandName from './lookupApplicationBoxByIDandName';
17
17
  import SearchAccounts from './searchAccounts';
18
+ import SearchForBlockHeaders from './searchForBlockHeaders';
18
19
  import SearchForTransactions from './searchForTransactions';
19
20
  import SearchForAssets from './searchForAssets';
20
21
  import SearchForApplications from './searchForApplications';
@@ -277,6 +278,18 @@ export default class IndexerClient extends ServiceClient {
277
278
  * @category GET
278
279
  */
279
280
  searchForTransactions(): SearchForTransactions;
281
+ /**
282
+ * Returns information about indexed block headers.
283
+ *
284
+ * #### Example
285
+ * ```typescript
286
+ * const txns = await indexerClient.searchForBlockHeaders().do();
287
+ * ```
288
+ *
289
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2block-headers)
290
+ * @category GET
291
+ */
292
+ searchForBlockHeaders(): SearchForBlockHeaders;
280
293
  /**
281
294
  * Returns information about indexed assets.
282
295
  *
@@ -0,0 +1,172 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ /**
3
+ * Returns information about indexed block headers.
4
+ *
5
+ * #### Example
6
+ * ```typescript
7
+ * const bhs = await indexerClient.searchForBlockHeaders().do();
8
+ * ```
9
+ *
10
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2block-headers)
11
+ * @category GET
12
+ */
13
+ export default class SearchForBlockHeaders extends JSONRequest {
14
+ /**
15
+ * @returns `/v2/block-headers`
16
+ */
17
+ path(): string;
18
+ /**
19
+ * Accounts marked as absent in the block header's participation updates.
20
+ *
21
+ * #### Example
22
+ * ```typescript
23
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
24
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
25
+ * const bhs = await indexerClient
26
+ * .searchForBlockHeaders()
27
+ * .absent([address1,address2])
28
+ * .do();
29
+ * ```
30
+ *
31
+ * @param absent - a comma separated list of addresses
32
+ * @category query
33
+ */
34
+ absent(absent: string[]): this;
35
+ /**
36
+ * Include results after the given time.
37
+ *
38
+ * #### Example
39
+ * ```typescript
40
+ * const afterTime = "2022-10-21T00:00:11.55Z";
41
+ * const bhs = await indexerClient
42
+ * .searchForBlockHeaders()
43
+ * .afterTime(afterTime)
44
+ * .do();
45
+ * ```
46
+ *
47
+ * @param after - rfc3339 string
48
+ * @category query
49
+ */
50
+ afterTime(after: string): this;
51
+ /**
52
+ * Include results before the given time.
53
+ *
54
+ * #### Example
55
+ * ```typescript
56
+ * const beforeTime = "2022-02-02T20:20:22.02Z";
57
+ * const bhs = await indexerClient
58
+ * .searchForBlockHeaders()
59
+ * .beforeTime(beforeTime)
60
+ * .do();
61
+ * ```
62
+ *
63
+ * @param before - rfc3339 string
64
+ * @category query
65
+ */
66
+ beforeTime(before: string): this;
67
+ /**
68
+ * Accounts marked as expired in the block header's participation updates.
69
+ *
70
+ * #### Example
71
+ * ```typescript
72
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
73
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
74
+ * const bhs = await indexerClient
75
+ * .searchForBlockHeaders()
76
+ * .expired([address1,address2])
77
+ * .do();
78
+ * ```
79
+ *
80
+ * @param expired - - a comma separated list of addresses
81
+ * @category query
82
+ */
83
+ expired(expired: string[]): this;
84
+ /**
85
+ * Maximum number of results to return.
86
+ *
87
+ * #### Example
88
+ * ```typescript
89
+ * const maxResults = 25;
90
+ * const bhs = await indexerClient
91
+ * .searchForBlockHeaders()
92
+ * .limit(maxResults)
93
+ * .do();
94
+ * ```
95
+ *
96
+ * @param limit
97
+ * @category query
98
+ */
99
+ limit(limit: number): this;
100
+ /**
101
+ * Include results at or before the specified max-round.
102
+ *
103
+ * #### Example
104
+ * ```typescript
105
+ * const maxRound = 18309917;
106
+ * const bhs = await indexerClient
107
+ * .searchForBlockHeaders()
108
+ * .maxRound(maxRound)
109
+ * .do();
110
+ * ```
111
+ *
112
+ * @param round
113
+ * @category query
114
+ */
115
+ maxRound(round: number): this;
116
+ /**
117
+ * Include results at or after the specified min-round.
118
+ *
119
+ * #### Example
120
+ * ```typescript
121
+ * const minRound = 18309917;
122
+ * const bhs = await indexerClient
123
+ * .searchForBlockHeaders()
124
+ * .minRound(minRound)
125
+ * .do();
126
+ * ```
127
+ *
128
+ * @param round
129
+ * @category query
130
+ */
131
+ minRound(round: number): this;
132
+ /**
133
+ * The next page of results.
134
+ *
135
+ * #### Example
136
+ * ```typescript
137
+ * const maxResults = 25;
138
+ *
139
+ * const bh1 = await indexerClient
140
+ * .searchForBlockHeaders()
141
+ * .limit(maxResults)
142
+ * .do();
143
+ *
144
+ * const bh2 = await indexerClient
145
+ * .searchForBlockHeaders()
146
+ * .limit(maxResults)
147
+ * .nextToken(bh1["next-token"])
148
+ * .do();
149
+ * ```
150
+ *
151
+ * @param nextToken - provided by the previous results
152
+ * @category query
153
+ */
154
+ nextToken(nextToken: string): this;
155
+ /**
156
+ * Accounts marked as proposer in the block header's participation updates.
157
+ *
158
+ * #### Example
159
+ * ```typescript
160
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
161
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
162
+ * const bhs = await indexerClient
163
+ * .searchForBlockHeaders()
164
+ * .proposers([address1,address2])
165
+ * .do();
166
+ * ```
167
+ *
168
+ * @param proposers - a comma separated list of addresses
169
+ * @category query
170
+ */
171
+ proposers(proposers: string[]): this;
172
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algosdk",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "The official JavaScript SDK for Algorand",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -20,6 +20,28 @@ export default class Block extends JSONRequest {
20
20
  return `/v2/blocks/${this.round}`;
21
21
  }
22
22
 
23
+ /**
24
+ * If true, only the block header (exclusive of payset or certificate) may be included in response.
25
+ *
26
+ * #### Example
27
+ * ```typescript
28
+ *
29
+ * const roundNumber = 41000000;
30
+ *
31
+ * const blockResponse = await algodClient
32
+ * .block(roundNumber)
33
+ * .headerOnly(true)
34
+ * .do();
35
+ * ```
36
+ *
37
+ * @param headerOnly - the flag indicating whether exclusively return header in response
38
+ * @category query
39
+ */
40
+ headerOnly(headerOnly: boolean) {
41
+ this.query['header-only'] = headerOnly;
42
+ return this;
43
+ }
44
+
23
45
  // eslint-disable-next-line class-methods-use-this
24
46
  prepare(body: Uint8Array) {
25
47
  if (body && body.byteLength > 0) {
@@ -2098,38 +2098,6 @@ export class BlockHashResponse extends BaseModel {
2098
2098
  }
2099
2099
  }
2100
2100
 
2101
- /**
2102
- * Block header.
2103
- */
2104
- export class BlockHeaderResponse extends BaseModel {
2105
- /**
2106
- * Block header data.
2107
- */
2108
- public blockheader?: BlockHeader;
2109
-
2110
- /**
2111
- * Creates a new `BlockHeaderResponse` object.
2112
- * @param blockheader - Block header data.
2113
- */
2114
- constructor({ blockheader }: { blockheader?: BlockHeader }) {
2115
- super();
2116
- this.blockheader = blockheader;
2117
-
2118
- this.attribute_map = {
2119
- blockheader: 'blockHeader',
2120
- };
2121
- }
2122
-
2123
- // eslint-disable-next-line camelcase
2124
- static from_obj_for_encoding(data: Record<string, any>): BlockHeaderResponse {
2125
- /* eslint-disable dot-notation */
2126
- return new BlockHeaderResponse({
2127
- blockheader: data['blockHeader'],
2128
- });
2129
- /* eslint-enable dot-notation */
2130
- }
2131
- }
2132
-
2133
2101
  /**
2134
2102
  * All logs emitted in the given round. Each app call, whether top-level or inner,
2135
2103
  * that contains logs results in a separate AppCallLogs object. Therefore there may
@@ -15,6 +15,7 @@ import LookupApplications from './lookupApplications';
15
15
  import LookupApplicationLogs from './lookupApplicationLogs';
16
16
  import LookupApplicationBoxByIDandName from './lookupApplicationBoxByIDandName';
17
17
  import SearchAccounts from './searchAccounts';
18
+ import SearchForBlockHeaders from './searchForBlockHeaders';
18
19
  import SearchForTransactions from './searchForTransactions';
19
20
  import SearchForAssets from './searchForAssets';
20
21
  import SearchForApplications from './searchForApplications';
@@ -345,6 +346,21 @@ export default class IndexerClient extends ServiceClient {
345
346
  return new SearchForTransactions(this.c, this.intDecoding);
346
347
  }
347
348
 
349
+ /**
350
+ * Returns information about indexed block headers.
351
+ *
352
+ * #### Example
353
+ * ```typescript
354
+ * const txns = await indexerClient.searchForBlockHeaders().do();
355
+ * ```
356
+ *
357
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2block-headers)
358
+ * @category GET
359
+ */
360
+ searchForBlockHeaders() {
361
+ return new SearchForBlockHeaders(this.c, this.intDecoding);
362
+ }
363
+
348
364
  /**
349
365
  * Returns information about indexed assets.
350
366
  *
@@ -0,0 +1,212 @@
1
+ import JSONRequest from '../jsonrequest';
2
+
3
+ /**
4
+ * Returns information about indexed block headers.
5
+ *
6
+ * #### Example
7
+ * ```typescript
8
+ * const bhs = await indexerClient.searchForBlockHeaders().do();
9
+ * ```
10
+ *
11
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2block-headers)
12
+ * @category GET
13
+ */
14
+ export default class SearchForBlockHeaders extends JSONRequest {
15
+ /**
16
+ * @returns `/v2/block-headers`
17
+ */
18
+ // eslint-disable-next-line class-methods-use-this
19
+ path() {
20
+ return '/v2/block-headers';
21
+ }
22
+
23
+ /**
24
+ * Accounts marked as absent in the block header's participation updates.
25
+ *
26
+ * #### Example
27
+ * ```typescript
28
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
29
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
30
+ * const bhs = await indexerClient
31
+ * .searchForBlockHeaders()
32
+ * .absent([address1,address2])
33
+ * .do();
34
+ * ```
35
+ *
36
+ * @param absent - a comma separated list of addresses
37
+ * @category query
38
+ */
39
+ absent(absent: string[]) {
40
+ this.query.absent = absent;
41
+ return this;
42
+ }
43
+
44
+ /**
45
+ * Include results after the given time.
46
+ *
47
+ * #### Example
48
+ * ```typescript
49
+ * const afterTime = "2022-10-21T00:00:11.55Z";
50
+ * const bhs = await indexerClient
51
+ * .searchForBlockHeaders()
52
+ * .afterTime(afterTime)
53
+ * .do();
54
+ * ```
55
+ *
56
+ * @param after - rfc3339 string
57
+ * @category query
58
+ */
59
+ afterTime(after: string) {
60
+ this.query['after-time'] = after;
61
+ return this;
62
+ }
63
+
64
+ /**
65
+ * Include results before the given time.
66
+ *
67
+ * #### Example
68
+ * ```typescript
69
+ * const beforeTime = "2022-02-02T20:20:22.02Z";
70
+ * const bhs = await indexerClient
71
+ * .searchForBlockHeaders()
72
+ * .beforeTime(beforeTime)
73
+ * .do();
74
+ * ```
75
+ *
76
+ * @param before - rfc3339 string
77
+ * @category query
78
+ */
79
+ beforeTime(before: string) {
80
+ this.query['before-time'] = before;
81
+ return this;
82
+ }
83
+
84
+ /**
85
+ * Accounts marked as expired in the block header's participation updates.
86
+ *
87
+ * #### Example
88
+ * ```typescript
89
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
90
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
91
+ * const bhs = await indexerClient
92
+ * .searchForBlockHeaders()
93
+ * .expired([address1,address2])
94
+ * .do();
95
+ * ```
96
+ *
97
+ * @param expired - - a comma separated list of addresses
98
+ * @category query
99
+ */
100
+ expired(expired: string[]) {
101
+ this.query.expired = expired;
102
+ return this;
103
+ }
104
+
105
+ /**
106
+ * Maximum number of results to return.
107
+ *
108
+ * #### Example
109
+ * ```typescript
110
+ * const maxResults = 25;
111
+ * const bhs = await indexerClient
112
+ * .searchForBlockHeaders()
113
+ * .limit(maxResults)
114
+ * .do();
115
+ * ```
116
+ *
117
+ * @param limit
118
+ * @category query
119
+ */
120
+ limit(limit: number) {
121
+ this.query.limit = limit;
122
+ return this;
123
+ }
124
+
125
+ /**
126
+ * Include results at or before the specified max-round.
127
+ *
128
+ * #### Example
129
+ * ```typescript
130
+ * const maxRound = 18309917;
131
+ * const bhs = await indexerClient
132
+ * .searchForBlockHeaders()
133
+ * .maxRound(maxRound)
134
+ * .do();
135
+ * ```
136
+ *
137
+ * @param round
138
+ * @category query
139
+ */
140
+ maxRound(round: number) {
141
+ this.query['max-round'] = round;
142
+ return this;
143
+ }
144
+
145
+ /**
146
+ * Include results at or after the specified min-round.
147
+ *
148
+ * #### Example
149
+ * ```typescript
150
+ * const minRound = 18309917;
151
+ * const bhs = await indexerClient
152
+ * .searchForBlockHeaders()
153
+ * .minRound(minRound)
154
+ * .do();
155
+ * ```
156
+ *
157
+ * @param round
158
+ * @category query
159
+ */
160
+ minRound(round: number) {
161
+ this.query['min-round'] = round;
162
+ return this;
163
+ }
164
+
165
+ /**
166
+ * The next page of results.
167
+ *
168
+ * #### Example
169
+ * ```typescript
170
+ * const maxResults = 25;
171
+ *
172
+ * const bh1 = await indexerClient
173
+ * .searchForBlockHeaders()
174
+ * .limit(maxResults)
175
+ * .do();
176
+ *
177
+ * const bh2 = await indexerClient
178
+ * .searchForBlockHeaders()
179
+ * .limit(maxResults)
180
+ * .nextToken(bh1["next-token"])
181
+ * .do();
182
+ * ```
183
+ *
184
+ * @param nextToken - provided by the previous results
185
+ * @category query
186
+ */
187
+ nextToken(nextToken: string) {
188
+ this.query.next = nextToken;
189
+ return this;
190
+ }
191
+
192
+ /**
193
+ * Accounts marked as proposer in the block header's participation updates.
194
+ *
195
+ * #### Example
196
+ * ```typescript
197
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
198
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
199
+ * const bhs = await indexerClient
200
+ * .searchForBlockHeaders()
201
+ * .proposers([address1,address2])
202
+ * .do();
203
+ * ```
204
+ *
205
+ * @param proposers - a comma separated list of addresses
206
+ * @category query
207
+ */
208
+ proposers(proposers: string[]) {
209
+ this.query.proposers = proposers;
210
+ return this;
211
+ }
212
+ }