algosdk 3.0.0 → 3.2.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 (52) 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/abi/abi_type.js +9 -7
  5. package/dist/cjs/abi/abi_type.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/block.js +21 -0
  7. package/dist/cjs/client/v2/algod/block.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/models/types.js +227 -3
  11. package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
  12. package/dist/cjs/client/v2/indexer/searchForBlockHeaders.js +217 -0
  13. package/dist/cjs/client/v2/indexer/searchForBlockHeaders.js.map +1 -0
  14. package/dist/cjs/heartbeat.js +119 -0
  15. package/dist/cjs/heartbeat.js.map +1 -0
  16. package/dist/cjs/transaction.js +36 -0
  17. package/dist/cjs/transaction.js.map +1 -1
  18. package/dist/cjs/types/transactions/base.js +6 -1
  19. package/dist/cjs/types/transactions/base.js.map +1 -1
  20. package/dist/esm/abi/abi_type.js +10 -8
  21. package/dist/esm/abi/abi_type.js.map +1 -1
  22. package/dist/esm/client/v2/algod/block.js +21 -0
  23. package/dist/esm/client/v2/algod/block.js.map +1 -1
  24. package/dist/esm/client/v2/indexer/indexer.js +15 -0
  25. package/dist/esm/client/v2/indexer/indexer.js.map +1 -1
  26. package/dist/esm/client/v2/indexer/models/types.js +222 -1
  27. package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
  28. package/dist/esm/client/v2/indexer/searchForBlockHeaders.js +211 -0
  29. package/dist/esm/client/v2/indexer/searchForBlockHeaders.js.map +1 -0
  30. package/dist/esm/heartbeat.js +114 -0
  31. package/dist/esm/heartbeat.js.map +1 -0
  32. package/dist/esm/transaction.js +36 -0
  33. package/dist/esm/transaction.js.map +1 -1
  34. package/dist/esm/types/transactions/base.js +6 -1
  35. package/dist/esm/types/transactions/base.js.map +1 -1
  36. package/dist/types/abi/abi_type.d.ts +13 -1
  37. package/dist/types/client/v2/algod/block.d.ts +18 -0
  38. package/dist/types/client/v2/indexer/indexer.d.ts +13 -0
  39. package/dist/types/client/v2/indexer/models/types.d.ts +146 -1
  40. package/dist/types/client/v2/indexer/searchForBlockHeaders.d.ts +176 -0
  41. package/dist/types/heartbeat.d.ts +39 -0
  42. package/dist/types/transaction.d.ts +9 -0
  43. package/dist/types/types/transactions/base.d.ts +32 -1
  44. package/package.json +2 -2
  45. package/src/abi/abi_type.ts +16 -9
  46. package/src/client/v2/algod/block.ts +22 -0
  47. package/src/client/v2/indexer/indexer.ts +16 -0
  48. package/src/client/v2/indexer/models/types.ts +375 -0
  49. package/src/client/v2/indexer/searchForBlockHeaders.ts +223 -0
  50. package/src/heartbeat.ts +168 -0
  51. package/src/transaction.ts +46 -0
  52. package/src/types/transactions/base.ts +43 -1
@@ -3410,6 +3410,97 @@ export class Block implements Encodable {
3410
3410
  }
3411
3411
  }
3412
3412
 
3413
+ /**
3414
+ *
3415
+ */
3416
+ export class BlockHeadersResponse implements Encodable {
3417
+ private static encodingSchemaValue: Schema | undefined;
3418
+
3419
+ static get encodingSchema(): Schema {
3420
+ if (!this.encodingSchemaValue) {
3421
+ this.encodingSchemaValue = new NamedMapSchema([]);
3422
+ (this.encodingSchemaValue as NamedMapSchema).pushEntries(
3423
+ {
3424
+ key: 'blocks',
3425
+ valueSchema: new ArraySchema(Block.encodingSchema),
3426
+ omitEmpty: true,
3427
+ },
3428
+ {
3429
+ key: 'current-round',
3430
+ valueSchema: new Uint64Schema(),
3431
+ omitEmpty: true,
3432
+ },
3433
+ {
3434
+ key: 'next-token',
3435
+ valueSchema: new OptionalSchema(new StringSchema()),
3436
+ omitEmpty: true,
3437
+ }
3438
+ );
3439
+ }
3440
+ return this.encodingSchemaValue;
3441
+ }
3442
+
3443
+ public blocks: Block[];
3444
+
3445
+ /**
3446
+ * Round at which the results were computed.
3447
+ */
3448
+ public currentRound: bigint;
3449
+
3450
+ /**
3451
+ * Used for pagination, when making another request provide this token with the
3452
+ * next parameter.
3453
+ */
3454
+ public nextToken?: string;
3455
+
3456
+ /**
3457
+ * Creates a new `BlockHeadersResponse` object.
3458
+ * @param blocks -
3459
+ * @param currentRound - Round at which the results were computed.
3460
+ * @param nextToken - Used for pagination, when making another request provide this token with the
3461
+ * next parameter.
3462
+ */
3463
+ constructor({
3464
+ blocks,
3465
+ currentRound,
3466
+ nextToken,
3467
+ }: {
3468
+ blocks: Block[];
3469
+ currentRound: number | bigint;
3470
+ nextToken?: string;
3471
+ }) {
3472
+ this.blocks = blocks;
3473
+ this.currentRound = ensureBigInt(currentRound);
3474
+ this.nextToken = nextToken;
3475
+ }
3476
+
3477
+ // eslint-disable-next-line class-methods-use-this
3478
+ getEncodingSchema(): Schema {
3479
+ return BlockHeadersResponse.encodingSchema;
3480
+ }
3481
+
3482
+ toEncodingData(): Map<string, unknown> {
3483
+ return new Map<string, unknown>([
3484
+ ['blocks', this.blocks.map((v) => v.toEncodingData())],
3485
+ ['current-round', this.currentRound],
3486
+ ['next-token', this.nextToken],
3487
+ ]);
3488
+ }
3489
+
3490
+ static fromEncodingData(data: unknown): BlockHeadersResponse {
3491
+ if (!(data instanceof Map)) {
3492
+ throw new Error(`Invalid decoded BlockHeadersResponse: ${data}`);
3493
+ }
3494
+ return new BlockHeadersResponse({
3495
+ blocks: (data.get('blocks') ?? []).map((v: unknown) =>
3496
+ Block.fromEncodingData(v)
3497
+ ),
3498
+ currentRound: data.get('current-round'),
3499
+ nextToken: data.get('next-token'),
3500
+ });
3501
+ }
3502
+ }
3503
+
3413
3504
  /**
3414
3505
  * Fields relating to rewards,
3415
3506
  */
@@ -4256,6 +4347,135 @@ export class HashFactory implements Encodable {
4256
4347
  }
4257
4348
  }
4258
4349
 
4350
+ /**
4351
+ * (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
4352
+ * it is online.
4353
+ */
4354
+ export class HbProofFields implements Encodable {
4355
+ private static encodingSchemaValue: Schema | undefined;
4356
+
4357
+ static get encodingSchema(): Schema {
4358
+ if (!this.encodingSchemaValue) {
4359
+ this.encodingSchemaValue = new NamedMapSchema([]);
4360
+ (this.encodingSchemaValue as NamedMapSchema).pushEntries(
4361
+ {
4362
+ key: 'hb-pk',
4363
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
4364
+ omitEmpty: true,
4365
+ },
4366
+ {
4367
+ key: 'hb-pk1sig',
4368
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
4369
+ omitEmpty: true,
4370
+ },
4371
+ {
4372
+ key: 'hb-pk2',
4373
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
4374
+ omitEmpty: true,
4375
+ },
4376
+ {
4377
+ key: 'hb-pk2sig',
4378
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
4379
+ omitEmpty: true,
4380
+ },
4381
+ {
4382
+ key: 'hb-sig',
4383
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
4384
+ omitEmpty: true,
4385
+ }
4386
+ );
4387
+ }
4388
+ return this.encodingSchemaValue;
4389
+ }
4390
+
4391
+ /**
4392
+ * (p) Public key of the heartbeat message.
4393
+ */
4394
+ public hbPk?: Uint8Array;
4395
+
4396
+ /**
4397
+ * (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the
4398
+ * key PK2.
4399
+ */
4400
+ public hbPk1sig?: Uint8Array;
4401
+
4402
+ /**
4403
+ * (p2) Key for new-style two-level ephemeral signature.
4404
+ */
4405
+ public hbPk2?: Uint8Array;
4406
+
4407
+ /**
4408
+ * (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master
4409
+ * key (OneTimeSignatureVerifier).
4410
+ */
4411
+ public hbPk2sig?: Uint8Array;
4412
+
4413
+ /**
4414
+ * (s) Signature of the heartbeat message.
4415
+ */
4416
+ public hbSig?: Uint8Array;
4417
+
4418
+ /**
4419
+ * Creates a new `HbProofFields` object.
4420
+ * @param hbPk - (p) Public key of the heartbeat message.
4421
+ * @param hbPk1sig - (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the
4422
+ * key PK2.
4423
+ * @param hbPk2 - (p2) Key for new-style two-level ephemeral signature.
4424
+ * @param hbPk2sig - (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master
4425
+ * key (OneTimeSignatureVerifier).
4426
+ * @param hbSig - (s) Signature of the heartbeat message.
4427
+ */
4428
+ constructor({
4429
+ hbPk,
4430
+ hbPk1sig,
4431
+ hbPk2,
4432
+ hbPk2sig,
4433
+ hbSig,
4434
+ }: {
4435
+ hbPk?: string | Uint8Array;
4436
+ hbPk1sig?: string | Uint8Array;
4437
+ hbPk2?: string | Uint8Array;
4438
+ hbPk2sig?: string | Uint8Array;
4439
+ hbSig?: string | Uint8Array;
4440
+ }) {
4441
+ this.hbPk = typeof hbPk === 'string' ? base64ToBytes(hbPk) : hbPk;
4442
+ this.hbPk1sig =
4443
+ typeof hbPk1sig === 'string' ? base64ToBytes(hbPk1sig) : hbPk1sig;
4444
+ this.hbPk2 = typeof hbPk2 === 'string' ? base64ToBytes(hbPk2) : hbPk2;
4445
+ this.hbPk2sig =
4446
+ typeof hbPk2sig === 'string' ? base64ToBytes(hbPk2sig) : hbPk2sig;
4447
+ this.hbSig = typeof hbSig === 'string' ? base64ToBytes(hbSig) : hbSig;
4448
+ }
4449
+
4450
+ // eslint-disable-next-line class-methods-use-this
4451
+ getEncodingSchema(): Schema {
4452
+ return HbProofFields.encodingSchema;
4453
+ }
4454
+
4455
+ toEncodingData(): Map<string, unknown> {
4456
+ return new Map<string, unknown>([
4457
+ ['hb-pk', this.hbPk],
4458
+ ['hb-pk1sig', this.hbPk1sig],
4459
+ ['hb-pk2', this.hbPk2],
4460
+ ['hb-pk2sig', this.hbPk2sig],
4461
+ ['hb-sig', this.hbSig],
4462
+ ]);
4463
+ }
4464
+
4465
+ static fromEncodingData(data: unknown): HbProofFields {
4466
+ if (!(data instanceof Map)) {
4467
+ throw new Error(`Invalid decoded HbProofFields: ${data}`);
4468
+ }
4469
+ return new HbProofFields({
4470
+ hbPk: data.get('hb-pk'),
4471
+ hbPk1sig: data.get('hb-pk1sig'),
4472
+ hbPk2: data.get('hb-pk2'),
4473
+ hbPk2sig: data.get('hb-pk2sig'),
4474
+ hbSig: data.get('hb-sig'),
4475
+ });
4476
+ }
4477
+ }
4478
+
4259
4479
  /**
4260
4480
  * A health check response.
4261
4481
  */
@@ -5890,6 +6110,11 @@ export class Transaction implements Encodable {
5890
6110
  valueSchema: new OptionalSchema(new ByteArraySchema()),
5891
6111
  omitEmpty: true,
5892
6112
  },
6113
+ {
6114
+ key: 'heartbeat-transaction',
6115
+ valueSchema: new OptionalSchema(TransactionHeartbeat.encodingSchema),
6116
+ omitEmpty: true,
6117
+ },
5893
6118
  {
5894
6119
  key: 'id',
5895
6120
  valueSchema: new OptionalSchema(new StringSchema()),
@@ -6087,6 +6312,13 @@ export class Transaction implements Encodable {
6087
6312
  */
6088
6313
  public group?: Uint8Array;
6089
6314
 
6315
+ /**
6316
+ * Fields for a heartbeat transaction.
6317
+ * Definition:
6318
+ * data/transactions/heartbeat.go : HeartbeatTxnFields
6319
+ */
6320
+ public heartbeatTransaction?: TransactionHeartbeat;
6321
+
6090
6322
  /**
6091
6323
  * Transaction ID
6092
6324
  */
@@ -6187,6 +6419,7 @@ export class Transaction implements Encodable {
6187
6419
  * * (afrz) asset-freeze-transaction
6188
6420
  * * (appl) application-transaction
6189
6421
  * * (stpf) state-proof-transaction
6422
+ * * (hb) heartbeat-transaction
6190
6423
  */
6191
6424
  public txType?: string;
6192
6425
 
@@ -6226,6 +6459,9 @@ export class Transaction implements Encodable {
6226
6459
  * @param group - (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates
6227
6460
  * that this transaction is part of a transaction group and the value is the
6228
6461
  * sha512/256 hash of the transactions in that group.
6462
+ * @param heartbeatTransaction - Fields for a heartbeat transaction.
6463
+ * Definition:
6464
+ * data/transactions/heartbeat.go : HeartbeatTxnFields
6229
6465
  * @param id - Transaction ID
6230
6466
  * @param innerTxns - Inner transactions produced by application execution.
6231
6467
  * @param intraRoundOffset - Offset into the round where this transaction was confirmed.
@@ -6265,6 +6501,7 @@ export class Transaction implements Encodable {
6265
6501
  * * (afrz) asset-freeze-transaction
6266
6502
  * * (appl) application-transaction
6267
6503
  * * (stpf) state-proof-transaction
6504
+ * * (hb) heartbeat-transaction
6268
6505
  */
6269
6506
  constructor({
6270
6507
  fee,
@@ -6285,6 +6522,7 @@ export class Transaction implements Encodable {
6285
6522
  genesisId,
6286
6523
  globalStateDelta,
6287
6524
  group,
6525
+ heartbeatTransaction,
6288
6526
  id,
6289
6527
  innerTxns,
6290
6528
  intraRoundOffset,
@@ -6320,6 +6558,7 @@ export class Transaction implements Encodable {
6320
6558
  genesisId?: string;
6321
6559
  globalStateDelta?: EvalDeltaKeyValue[];
6322
6560
  group?: string | Uint8Array;
6561
+ heartbeatTransaction?: TransactionHeartbeat;
6323
6562
  id?: string;
6324
6563
  innerTxns?: Transaction[];
6325
6564
  intraRoundOffset?: number | bigint;
@@ -6374,6 +6613,7 @@ export class Transaction implements Encodable {
6374
6613
  this.genesisId = genesisId;
6375
6614
  this.globalStateDelta = globalStateDelta;
6376
6615
  this.group = typeof group === 'string' ? base64ToBytes(group) : group;
6616
+ this.heartbeatTransaction = heartbeatTransaction;
6377
6617
  this.id = id;
6378
6618
  this.innerTxns = innerTxns;
6379
6619
  this.intraRoundOffset =
@@ -6460,6 +6700,12 @@ export class Transaction implements Encodable {
6460
6700
  : undefined,
6461
6701
  ],
6462
6702
  ['group', this.group],
6703
+ [
6704
+ 'heartbeat-transaction',
6705
+ typeof this.heartbeatTransaction !== 'undefined'
6706
+ ? this.heartbeatTransaction.toEncodingData()
6707
+ : undefined,
6708
+ ],
6463
6709
  ['id', this.id],
6464
6710
  [
6465
6711
  'inner-txns',
@@ -6562,6 +6808,12 @@ export class Transaction implements Encodable {
6562
6808
  .map((v: unknown) => EvalDeltaKeyValue.fromEncodingData(v))
6563
6809
  : undefined,
6564
6810
  group: data.get('group'),
6811
+ heartbeatTransaction:
6812
+ typeof data.get('heartbeat-transaction') !== 'undefined'
6813
+ ? TransactionHeartbeat.fromEncodingData(
6814
+ data.get('heartbeat-transaction')
6815
+ )
6816
+ : undefined,
6565
6817
  id: data.get('id'),
6566
6818
  innerTxns:
6567
6819
  typeof data.get('inner-txns') !== 'undefined'
@@ -7237,6 +7489,129 @@ export class TransactionAssetTransfer implements Encodable {
7237
7489
  }
7238
7490
  }
7239
7491
 
7492
+ /**
7493
+ * Fields for a heartbeat transaction.
7494
+ * Definition:
7495
+ * data/transactions/heartbeat.go : HeartbeatTxnFields
7496
+ */
7497
+ export class TransactionHeartbeat implements Encodable {
7498
+ private static encodingSchemaValue: Schema | undefined;
7499
+
7500
+ static get encodingSchema(): Schema {
7501
+ if (!this.encodingSchemaValue) {
7502
+ this.encodingSchemaValue = new NamedMapSchema([]);
7503
+ (this.encodingSchemaValue as NamedMapSchema).pushEntries(
7504
+ { key: 'hb-address', valueSchema: new StringSchema(), omitEmpty: true },
7505
+ {
7506
+ key: 'hb-key-dilution',
7507
+ valueSchema: new Uint64Schema(),
7508
+ omitEmpty: true,
7509
+ },
7510
+ {
7511
+ key: 'hb-proof',
7512
+ valueSchema: HbProofFields.encodingSchema,
7513
+ omitEmpty: true,
7514
+ },
7515
+ { key: 'hb-seed', valueSchema: new ByteArraySchema(), omitEmpty: true },
7516
+ {
7517
+ key: 'hb-vote-id',
7518
+ valueSchema: new ByteArraySchema(),
7519
+ omitEmpty: true,
7520
+ }
7521
+ );
7522
+ }
7523
+ return this.encodingSchemaValue;
7524
+ }
7525
+
7526
+ /**
7527
+ * (hbad) HbAddress is the account this txn is proving onlineness for.
7528
+ */
7529
+ public hbAddress: string;
7530
+
7531
+ /**
7532
+ * (hbkd) HbKeyDilution must match HbAddress account's current KeyDilution.
7533
+ */
7534
+ public hbKeyDilution: bigint;
7535
+
7536
+ /**
7537
+ * (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
7538
+ * it is online.
7539
+ */
7540
+ public hbProof: HbProofFields;
7541
+
7542
+ /**
7543
+ * (hbsd) HbSeed must be the block seed for the this transaction's firstValid
7544
+ * block.
7545
+ */
7546
+ public hbSeed: Uint8Array;
7547
+
7548
+ /**
7549
+ * (hbvid) HbVoteID must match the HbAddress account's current VoteID.
7550
+ */
7551
+ public hbVoteId: Uint8Array;
7552
+
7553
+ /**
7554
+ * Creates a new `TransactionHeartbeat` object.
7555
+ * @param hbAddress - (hbad) HbAddress is the account this txn is proving onlineness for.
7556
+ * @param hbKeyDilution - (hbkd) HbKeyDilution must match HbAddress account's current KeyDilution.
7557
+ * @param hbProof - (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
7558
+ * it is online.
7559
+ * @param hbSeed - (hbsd) HbSeed must be the block seed for the this transaction's firstValid
7560
+ * block.
7561
+ * @param hbVoteId - (hbvid) HbVoteID must match the HbAddress account's current VoteID.
7562
+ */
7563
+ constructor({
7564
+ hbAddress,
7565
+ hbKeyDilution,
7566
+ hbProof,
7567
+ hbSeed,
7568
+ hbVoteId,
7569
+ }: {
7570
+ hbAddress: string;
7571
+ hbKeyDilution: number | bigint;
7572
+ hbProof: HbProofFields;
7573
+ hbSeed: string | Uint8Array;
7574
+ hbVoteId: string | Uint8Array;
7575
+ }) {
7576
+ this.hbAddress = hbAddress;
7577
+ this.hbKeyDilution = ensureBigInt(hbKeyDilution);
7578
+ this.hbProof = hbProof;
7579
+ this.hbSeed = typeof hbSeed === 'string' ? base64ToBytes(hbSeed) : hbSeed;
7580
+ this.hbVoteId =
7581
+ typeof hbVoteId === 'string' ? base64ToBytes(hbVoteId) : hbVoteId;
7582
+ }
7583
+
7584
+ // eslint-disable-next-line class-methods-use-this
7585
+ getEncodingSchema(): Schema {
7586
+ return TransactionHeartbeat.encodingSchema;
7587
+ }
7588
+
7589
+ toEncodingData(): Map<string, unknown> {
7590
+ return new Map<string, unknown>([
7591
+ ['hb-address', this.hbAddress],
7592
+ ['hb-key-dilution', this.hbKeyDilution],
7593
+ ['hb-proof', this.hbProof.toEncodingData()],
7594
+ ['hb-seed', this.hbSeed],
7595
+ ['hb-vote-id', this.hbVoteId],
7596
+ ]);
7597
+ }
7598
+
7599
+ static fromEncodingData(data: unknown): TransactionHeartbeat {
7600
+ if (!(data instanceof Map)) {
7601
+ throw new Error(`Invalid decoded TransactionHeartbeat: ${data}`);
7602
+ }
7603
+ return new TransactionHeartbeat({
7604
+ hbAddress: data.get('hb-address'),
7605
+ hbKeyDilution: data.get('hb-key-dilution'),
7606
+ hbProof: HbProofFields.fromEncodingData(
7607
+ data.get('hb-proof') ?? new Map()
7608
+ ),
7609
+ hbSeed: data.get('hb-seed'),
7610
+ hbVoteId: data.get('hb-vote-id'),
7611
+ });
7612
+ }
7613
+ }
7614
+
7240
7615
  /**
7241
7616
  * Fields for a keyreg transaction.
7242
7617
  * Definition:
@@ -0,0 +1,223 @@
1
+ import JSONRequest from '../jsonrequest.js';
2
+ import { HTTPClientResponse } from '../../client.js';
3
+ import { decodeJSON } from '../../../encoding/encoding.js';
4
+ import { Address } from '../../../encoding/address.js';
5
+ import { BlockHeadersResponse } from './models/types.js';
6
+
7
+ /**
8
+ * Returns information about indexed block headers.
9
+ *
10
+ * #### Example
11
+ * ```typescript
12
+ * const bhs = await indexerClient.searchForBlockHeaders().do();
13
+ * ```
14
+ *
15
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2block-headers)
16
+ * @category GET
17
+ */
18
+ export default class SearchForBlockHeaders extends JSONRequest<BlockHeadersResponse> {
19
+ /**
20
+ * @returns `/v2/block-headers`
21
+ */
22
+ // eslint-disable-next-line class-methods-use-this
23
+ path() {
24
+ return '/v2/block-headers';
25
+ }
26
+
27
+ /**
28
+ * Accounts marked as absent in the block header's participation updates.
29
+ *
30
+ * #### Example
31
+ * ```typescript
32
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
33
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
34
+ * const bhs = await indexerClient
35
+ * .searchForBlockHeaders()
36
+ * .absent([address1,address2])
37
+ * .do();
38
+ * ```
39
+ *
40
+ * @param absent - a comma separated list of addresses
41
+ * @category query
42
+ */
43
+ absent(absent: (string | Address)[]) {
44
+ this.query.absent = absent;
45
+ return this;
46
+ }
47
+
48
+ /**
49
+ * Include results after the given time.
50
+ *
51
+ * #### Example
52
+ * ```typescript
53
+ * const afterTime = "2022-10-21T00:00:11.55Z";
54
+ * const bhs = await indexerClient
55
+ * .searchForBlockHeaders()
56
+ * .afterTime(afterTime)
57
+ * .do();
58
+ * ```
59
+ *
60
+ * @param after - rfc3339 string or Date object
61
+ * @category query
62
+ */
63
+ afterTime(after: string | Date) {
64
+ this.query['after-time'] =
65
+ after instanceof Date ? after.toISOString() : after;
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Include results before the given time.
71
+ *
72
+ * #### Example
73
+ * ```typescript
74
+ * const beforeTime = "2022-02-02T20:20:22.02Z";
75
+ * const bhs = await indexerClient
76
+ * .searchForBlockHeaders()
77
+ * .beforeTime(beforeTime)
78
+ * .do();
79
+ * ```
80
+ *
81
+ * @param before - rfc3339 string or Date object
82
+ * @category query
83
+ */
84
+ beforeTime(before: string | Date) {
85
+ this.query['before-time'] =
86
+ before instanceof Date ? before.toISOString() : before;
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Accounts marked as expired in the block header's participation updates.
92
+ *
93
+ * #### Example
94
+ * ```typescript
95
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
96
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
97
+ * const bhs = await indexerClient
98
+ * .searchForBlockHeaders()
99
+ * .expired([address1,address2])
100
+ * .do();
101
+ * ```
102
+ *
103
+ * @param expired - - a comma separated list of addresses
104
+ * @category query
105
+ */
106
+ expired(expired: (string | Address)[]) {
107
+ this.query.expired = expired;
108
+ return this;
109
+ }
110
+
111
+ /**
112
+ * Maximum number of results to return.
113
+ *
114
+ * #### Example
115
+ * ```typescript
116
+ * const maxResults = 25;
117
+ * const bhs = await indexerClient
118
+ * .searchForBlockHeaders()
119
+ * .limit(maxResults)
120
+ * .do();
121
+ * ```
122
+ *
123
+ * @param limit
124
+ * @category query
125
+ */
126
+ limit(limit: number) {
127
+ this.query.limit = limit;
128
+ return this;
129
+ }
130
+
131
+ /**
132
+ * Include results at or before the specified max-round.
133
+ *
134
+ * #### Example
135
+ * ```typescript
136
+ * const maxRound = 18309917;
137
+ * const bhs = await indexerClient
138
+ * .searchForBlockHeaders()
139
+ * .maxRound(maxRound)
140
+ * .do();
141
+ * ```
142
+ *
143
+ * @param round
144
+ * @category query
145
+ */
146
+ maxRound(round: number | bigint) {
147
+ this.query['max-round'] = round;
148
+ return this;
149
+ }
150
+
151
+ /**
152
+ * Include results at or after the specified min-round.
153
+ *
154
+ * #### Example
155
+ * ```typescript
156
+ * const minRound = 18309917;
157
+ * const bhs = await indexerClient
158
+ * .searchForBlockHeaders()
159
+ * .minRound(minRound)
160
+ * .do();
161
+ * ```
162
+ *
163
+ * @param round
164
+ * @category query
165
+ */
166
+ minRound(round: number | bigint) {
167
+ this.query['min-round'] = round;
168
+ return this;
169
+ }
170
+
171
+ /**
172
+ * The next page of results.
173
+ *
174
+ * #### Example
175
+ * ```typescript
176
+ * const maxResults = 25;
177
+ *
178
+ * const bh1 = await indexerClient
179
+ * .searchForBlockHeaders()
180
+ * .limit(maxResults)
181
+ * .do();
182
+ *
183
+ * const bh2 = await indexerClient
184
+ * .searchForBlockHeaders()
185
+ * .limit(maxResults)
186
+ * .nextToken(bh1["next-token"])
187
+ * .do();
188
+ * ```
189
+ *
190
+ * @param nextToken - provided by the previous results
191
+ * @category query
192
+ */
193
+ nextToken(nextToken: string) {
194
+ this.query.next = nextToken;
195
+ return this;
196
+ }
197
+
198
+ /**
199
+ * Accounts marked as proposer in the block header's participation updates.
200
+ *
201
+ * #### Example
202
+ * ```typescript
203
+ * const address1 = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
204
+ * const address2 = "4H5UNRBJ2Q6JENAXQ6HNTGKLKINP4J4VTQBEPK5F3I6RDICMZBPGNH6KD4";
205
+ * const bhs = await indexerClient
206
+ * .searchForBlockHeaders()
207
+ * .proposers([address1,address2])
208
+ * .do();
209
+ * ```
210
+ *
211
+ * @param proposers - a comma separated list of addresses
212
+ * @category query
213
+ */
214
+ proposers(proposers: (string | Address)[]) {
215
+ this.query.proposers = proposers;
216
+ return this;
217
+ }
218
+
219
+ // eslint-disable-next-line class-methods-use-this
220
+ prepare(response: HTTPClientResponse): BlockHeadersResponse {
221
+ return decodeJSON(response.getJSONText(), BlockHeadersResponse);
222
+ }
223
+ }