algosdk 3.0.0-beta.2 → 3.1.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 (34) 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/models/types.js +43 -2
  5. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  6. package/dist/cjs/client/v2/indexer/models/types.js +227 -3
  7. package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
  8. package/dist/cjs/heartbeat.js +119 -0
  9. package/dist/cjs/heartbeat.js.map +1 -0
  10. package/dist/cjs/transaction.js +36 -0
  11. package/dist/cjs/transaction.js.map +1 -1
  12. package/dist/cjs/types/transactions/base.js +6 -1
  13. package/dist/cjs/types/transactions/base.js.map +1 -1
  14. package/dist/esm/client/v2/algod/models/types.js +40 -0
  15. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  16. package/dist/esm/client/v2/indexer/models/types.js +222 -1
  17. package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
  18. package/dist/esm/heartbeat.js +114 -0
  19. package/dist/esm/heartbeat.js.map +1 -0
  20. package/dist/esm/transaction.js +36 -0
  21. package/dist/esm/transaction.js.map +1 -1
  22. package/dist/esm/types/transactions/base.js +6 -1
  23. package/dist/esm/types/transactions/base.js.map +1 -1
  24. package/dist/types/client/v2/algod/models/types.d.ts +21 -0
  25. package/dist/types/client/v2/indexer/models/types.d.ts +146 -1
  26. package/dist/types/heartbeat.d.ts +39 -0
  27. package/dist/types/transaction.d.ts +9 -0
  28. package/dist/types/types/transactions/base.d.ts +32 -1
  29. package/package.json +1 -1
  30. package/src/client/v2/algod/models/types.ts +52 -0
  31. package/src/client/v2/indexer/models/types.ts +375 -0
  32. package/src/heartbeat.ts +168 -0
  33. package/src/transaction.ts +46 -0
  34. package/src/types/transactions/base.ts +43 -1
@@ -2011,6 +2011,63 @@ export class Block {
2011
2011
  });
2012
2012
  }
2013
2013
  }
2014
+ /**
2015
+ *
2016
+ */
2017
+ export class BlockHeadersResponse {
2018
+ static get encodingSchema() {
2019
+ if (!this.encodingSchemaValue) {
2020
+ this.encodingSchemaValue = new NamedMapSchema([]);
2021
+ this.encodingSchemaValue.pushEntries({
2022
+ key: 'blocks',
2023
+ valueSchema: new ArraySchema(Block.encodingSchema),
2024
+ omitEmpty: true,
2025
+ }, {
2026
+ key: 'current-round',
2027
+ valueSchema: new Uint64Schema(),
2028
+ omitEmpty: true,
2029
+ }, {
2030
+ key: 'next-token',
2031
+ valueSchema: new OptionalSchema(new StringSchema()),
2032
+ omitEmpty: true,
2033
+ });
2034
+ }
2035
+ return this.encodingSchemaValue;
2036
+ }
2037
+ /**
2038
+ * Creates a new `BlockHeadersResponse` object.
2039
+ * @param blocks -
2040
+ * @param currentRound - Round at which the results were computed.
2041
+ * @param nextToken - Used for pagination, when making another request provide this token with the
2042
+ * next parameter.
2043
+ */
2044
+ constructor({ blocks, currentRound, nextToken, }) {
2045
+ this.blocks = blocks;
2046
+ this.currentRound = ensureBigInt(currentRound);
2047
+ this.nextToken = nextToken;
2048
+ }
2049
+ // eslint-disable-next-line class-methods-use-this
2050
+ getEncodingSchema() {
2051
+ return BlockHeadersResponse.encodingSchema;
2052
+ }
2053
+ toEncodingData() {
2054
+ return new Map([
2055
+ ['blocks', this.blocks.map((v) => v.toEncodingData())],
2056
+ ['current-round', this.currentRound],
2057
+ ['next-token', this.nextToken],
2058
+ ]);
2059
+ }
2060
+ static fromEncodingData(data) {
2061
+ if (!(data instanceof Map)) {
2062
+ throw new Error(`Invalid decoded BlockHeadersResponse: ${data}`);
2063
+ }
2064
+ return new BlockHeadersResponse({
2065
+ blocks: (data.get('blocks') ?? []).map((v) => Block.fromEncodingData(v)),
2066
+ currentRound: data.get('current-round'),
2067
+ nextToken: data.get('next-token'),
2068
+ });
2069
+ }
2070
+ }
2014
2071
  /**
2015
2072
  * Fields relating to rewards,
2016
2073
  */
@@ -2551,6 +2608,83 @@ export class HashFactory {
2551
2608
  });
2552
2609
  }
2553
2610
  }
2611
+ /**
2612
+ * (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
2613
+ * it is online.
2614
+ */
2615
+ export class HbProofFields {
2616
+ static get encodingSchema() {
2617
+ if (!this.encodingSchemaValue) {
2618
+ this.encodingSchemaValue = new NamedMapSchema([]);
2619
+ this.encodingSchemaValue.pushEntries({
2620
+ key: 'hb-pk',
2621
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
2622
+ omitEmpty: true,
2623
+ }, {
2624
+ key: 'hb-pk1sig',
2625
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
2626
+ omitEmpty: true,
2627
+ }, {
2628
+ key: 'hb-pk2',
2629
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
2630
+ omitEmpty: true,
2631
+ }, {
2632
+ key: 'hb-pk2sig',
2633
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
2634
+ omitEmpty: true,
2635
+ }, {
2636
+ key: 'hb-sig',
2637
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
2638
+ omitEmpty: true,
2639
+ });
2640
+ }
2641
+ return this.encodingSchemaValue;
2642
+ }
2643
+ /**
2644
+ * Creates a new `HbProofFields` object.
2645
+ * @param hbPk - (p) Public key of the heartbeat message.
2646
+ * @param hbPk1sig - (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the
2647
+ * key PK2.
2648
+ * @param hbPk2 - (p2) Key for new-style two-level ephemeral signature.
2649
+ * @param hbPk2sig - (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master
2650
+ * key (OneTimeSignatureVerifier).
2651
+ * @param hbSig - (s) Signature of the heartbeat message.
2652
+ */
2653
+ constructor({ hbPk, hbPk1sig, hbPk2, hbPk2sig, hbSig, }) {
2654
+ this.hbPk = typeof hbPk === 'string' ? base64ToBytes(hbPk) : hbPk;
2655
+ this.hbPk1sig =
2656
+ typeof hbPk1sig === 'string' ? base64ToBytes(hbPk1sig) : hbPk1sig;
2657
+ this.hbPk2 = typeof hbPk2 === 'string' ? base64ToBytes(hbPk2) : hbPk2;
2658
+ this.hbPk2sig =
2659
+ typeof hbPk2sig === 'string' ? base64ToBytes(hbPk2sig) : hbPk2sig;
2660
+ this.hbSig = typeof hbSig === 'string' ? base64ToBytes(hbSig) : hbSig;
2661
+ }
2662
+ // eslint-disable-next-line class-methods-use-this
2663
+ getEncodingSchema() {
2664
+ return HbProofFields.encodingSchema;
2665
+ }
2666
+ toEncodingData() {
2667
+ return new Map([
2668
+ ['hb-pk', this.hbPk],
2669
+ ['hb-pk1sig', this.hbPk1sig],
2670
+ ['hb-pk2', this.hbPk2],
2671
+ ['hb-pk2sig', this.hbPk2sig],
2672
+ ['hb-sig', this.hbSig],
2673
+ ]);
2674
+ }
2675
+ static fromEncodingData(data) {
2676
+ if (!(data instanceof Map)) {
2677
+ throw new Error(`Invalid decoded HbProofFields: ${data}`);
2678
+ }
2679
+ return new HbProofFields({
2680
+ hbPk: data.get('hb-pk'),
2681
+ hbPk1sig: data.get('hb-pk1sig'),
2682
+ hbPk2: data.get('hb-pk2'),
2683
+ hbPk2sig: data.get('hb-pk2sig'),
2684
+ hbSig: data.get('hb-sig'),
2685
+ });
2686
+ }
2687
+ }
2554
2688
  /**
2555
2689
  * A health check response.
2556
2690
  */
@@ -3604,6 +3738,10 @@ export class Transaction {
3604
3738
  key: 'group',
3605
3739
  valueSchema: new OptionalSchema(new ByteArraySchema()),
3606
3740
  omitEmpty: true,
3741
+ }, {
3742
+ key: 'heartbeat-transaction',
3743
+ valueSchema: new OptionalSchema(TransactionHeartbeat.encodingSchema),
3744
+ omitEmpty: true,
3607
3745
  }, {
3608
3746
  key: 'id',
3609
3747
  valueSchema: new OptionalSchema(new StringSchema()),
@@ -3708,6 +3846,9 @@ export class Transaction {
3708
3846
  * @param group - (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates
3709
3847
  * that this transaction is part of a transaction group and the value is the
3710
3848
  * sha512/256 hash of the transactions in that group.
3849
+ * @param heartbeatTransaction - Fields for a heartbeat transaction.
3850
+ * Definition:
3851
+ * data/transactions/heartbeat.go : HeartbeatTxnFields
3711
3852
  * @param id - Transaction ID
3712
3853
  * @param innerTxns - Inner transactions produced by application execution.
3713
3854
  * @param intraRoundOffset - Offset into the round where this transaction was confirmed.
@@ -3747,8 +3888,9 @@ export class Transaction {
3747
3888
  * * (afrz) asset-freeze-transaction
3748
3889
  * * (appl) application-transaction
3749
3890
  * * (stpf) state-proof-transaction
3891
+ * * (hb) heartbeat-transaction
3750
3892
  */
3751
- constructor({ fee, firstValid, lastValid, sender, applicationTransaction, assetConfigTransaction, assetFreezeTransaction, assetTransferTransaction, authAddr, closeRewards, closingAmount, confirmedRound, createdApplicationIndex, createdAssetIndex, genesisHash, genesisId, globalStateDelta, group, id, innerTxns, intraRoundOffset, keyregTransaction, lease, localStateDelta, logs, note, paymentTransaction, receiverRewards, rekeyTo, roundTime, senderRewards, signature, stateProofTransaction, txType, }) {
3893
+ constructor({ fee, firstValid, lastValid, sender, applicationTransaction, assetConfigTransaction, assetFreezeTransaction, assetTransferTransaction, authAddr, closeRewards, closingAmount, confirmedRound, createdApplicationIndex, createdAssetIndex, genesisHash, genesisId, globalStateDelta, group, heartbeatTransaction, id, innerTxns, intraRoundOffset, keyregTransaction, lease, localStateDelta, logs, note, paymentTransaction, receiverRewards, rekeyTo, roundTime, senderRewards, signature, stateProofTransaction, txType, }) {
3752
3894
  this.fee = ensureBigInt(fee);
3753
3895
  this.firstValid = ensureBigInt(firstValid);
3754
3896
  this.lastValid = ensureBigInt(lastValid);
@@ -3786,6 +3928,7 @@ export class Transaction {
3786
3928
  this.genesisId = genesisId;
3787
3929
  this.globalStateDelta = globalStateDelta;
3788
3930
  this.group = typeof group === 'string' ? base64ToBytes(group) : group;
3931
+ this.heartbeatTransaction = heartbeatTransaction;
3789
3932
  this.id = id;
3790
3933
  this.innerTxns = innerTxns;
3791
3934
  this.intraRoundOffset =
@@ -3870,6 +4013,12 @@ export class Transaction {
3870
4013
  : undefined,
3871
4014
  ],
3872
4015
  ['group', this.group],
4016
+ [
4017
+ 'heartbeat-transaction',
4018
+ typeof this.heartbeatTransaction !== 'undefined'
4019
+ ? this.heartbeatTransaction.toEncodingData()
4020
+ : undefined,
4021
+ ],
3873
4022
  ['id', this.id],
3874
4023
  [
3875
4024
  'inner-txns',
@@ -3958,6 +4107,9 @@ export class Transaction {
3958
4107
  .map((v) => EvalDeltaKeyValue.fromEncodingData(v))
3959
4108
  : undefined,
3960
4109
  group: data.get('group'),
4110
+ heartbeatTransaction: typeof data.get('heartbeat-transaction') !== 'undefined'
4111
+ ? TransactionHeartbeat.fromEncodingData(data.get('heartbeat-transaction'))
4112
+ : undefined,
3961
4113
  id: data.get('id'),
3962
4114
  innerTxns: typeof data.get('inner-txns') !== 'undefined'
3963
4115
  ? data
@@ -4368,6 +4520,75 @@ export class TransactionAssetTransfer {
4368
4520
  });
4369
4521
  }
4370
4522
  }
4523
+ /**
4524
+ * Fields for a heartbeat transaction.
4525
+ * Definition:
4526
+ * data/transactions/heartbeat.go : HeartbeatTxnFields
4527
+ */
4528
+ export class TransactionHeartbeat {
4529
+ static get encodingSchema() {
4530
+ if (!this.encodingSchemaValue) {
4531
+ this.encodingSchemaValue = new NamedMapSchema([]);
4532
+ this.encodingSchemaValue.pushEntries({ key: 'hb-address', valueSchema: new StringSchema(), omitEmpty: true }, {
4533
+ key: 'hb-key-dilution',
4534
+ valueSchema: new Uint64Schema(),
4535
+ omitEmpty: true,
4536
+ }, {
4537
+ key: 'hb-proof',
4538
+ valueSchema: HbProofFields.encodingSchema,
4539
+ omitEmpty: true,
4540
+ }, { key: 'hb-seed', valueSchema: new ByteArraySchema(), omitEmpty: true }, {
4541
+ key: 'hb-vote-id',
4542
+ valueSchema: new ByteArraySchema(),
4543
+ omitEmpty: true,
4544
+ });
4545
+ }
4546
+ return this.encodingSchemaValue;
4547
+ }
4548
+ /**
4549
+ * Creates a new `TransactionHeartbeat` object.
4550
+ * @param hbAddress - (hbad) HbAddress is the account this txn is proving onlineness for.
4551
+ * @param hbKeyDilution - (hbkd) HbKeyDilution must match HbAddress account's current KeyDilution.
4552
+ * @param hbProof - (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
4553
+ * it is online.
4554
+ * @param hbSeed - (hbsd) HbSeed must be the block seed for the this transaction's firstValid
4555
+ * block.
4556
+ * @param hbVoteId - (hbvid) HbVoteID must match the HbAddress account's current VoteID.
4557
+ */
4558
+ constructor({ hbAddress, hbKeyDilution, hbProof, hbSeed, hbVoteId, }) {
4559
+ this.hbAddress = hbAddress;
4560
+ this.hbKeyDilution = ensureBigInt(hbKeyDilution);
4561
+ this.hbProof = hbProof;
4562
+ this.hbSeed = typeof hbSeed === 'string' ? base64ToBytes(hbSeed) : hbSeed;
4563
+ this.hbVoteId =
4564
+ typeof hbVoteId === 'string' ? base64ToBytes(hbVoteId) : hbVoteId;
4565
+ }
4566
+ // eslint-disable-next-line class-methods-use-this
4567
+ getEncodingSchema() {
4568
+ return TransactionHeartbeat.encodingSchema;
4569
+ }
4570
+ toEncodingData() {
4571
+ return new Map([
4572
+ ['hb-address', this.hbAddress],
4573
+ ['hb-key-dilution', this.hbKeyDilution],
4574
+ ['hb-proof', this.hbProof.toEncodingData()],
4575
+ ['hb-seed', this.hbSeed],
4576
+ ['hb-vote-id', this.hbVoteId],
4577
+ ]);
4578
+ }
4579
+ static fromEncodingData(data) {
4580
+ if (!(data instanceof Map)) {
4581
+ throw new Error(`Invalid decoded TransactionHeartbeat: ${data}`);
4582
+ }
4583
+ return new TransactionHeartbeat({
4584
+ hbAddress: data.get('hb-address'),
4585
+ hbKeyDilution: data.get('hb-key-dilution'),
4586
+ hbProof: HbProofFields.fromEncodingData(data.get('hb-proof') ?? new Map()),
4587
+ hbSeed: data.get('hb-seed'),
4588
+ hbVoteId: data.get('hb-vote-id'),
4589
+ });
4590
+ }
4591
+ }
4371
4592
  /**
4372
4593
  * Fields for a keyreg transaction.
4373
4594
  * Definition: