algosdk 3.0.0 → 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.
- package/README.md +4 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +43 -2
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/client/v2/indexer/models/types.js +227 -3
- package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
- package/dist/cjs/heartbeat.js +119 -0
- package/dist/cjs/heartbeat.js.map +1 -0
- package/dist/cjs/transaction.js +36 -0
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/cjs/types/transactions/base.js +6 -1
- package/dist/cjs/types/transactions/base.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +40 -0
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/client/v2/indexer/models/types.js +222 -1
- package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
- package/dist/esm/heartbeat.js +114 -0
- package/dist/esm/heartbeat.js.map +1 -0
- package/dist/esm/transaction.js +36 -0
- package/dist/esm/transaction.js.map +1 -1
- package/dist/esm/types/transactions/base.js +6 -1
- package/dist/esm/types/transactions/base.js.map +1 -1
- package/dist/types/client/v2/algod/models/types.d.ts +21 -0
- package/dist/types/client/v2/indexer/models/types.d.ts +146 -1
- package/dist/types/heartbeat.d.ts +39 -0
- package/dist/types/transaction.d.ts +9 -0
- package/dist/types/types/transactions/base.d.ts +32 -1
- package/package.json +1 -1
- package/src/client/v2/algod/models/types.ts +52 -0
- package/src/client/v2/indexer/models/types.ts +375 -0
- package/src/heartbeat.ts +168 -0
- package/src/transaction.ts +46 -0
- package/src/types/transactions/base.ts +43 -1
|
@@ -3,6 +3,7 @@ import * as encoding from './encoding/encoding.js';
|
|
|
3
3
|
import { NamedMapSchema } from './encoding/schema/index.js';
|
|
4
4
|
import { OnApplicationComplete, TransactionParams, TransactionType } from './types/transactions/base.js';
|
|
5
5
|
import { StateProof, StateProofMessage } from './stateproof.js';
|
|
6
|
+
import { HeartbeatProof } from './heartbeat.js';
|
|
6
7
|
export interface TransactionBoxReference {
|
|
7
8
|
readonly appIndex: bigint;
|
|
8
9
|
readonly name: Uint8Array;
|
|
@@ -68,6 +69,13 @@ export interface StateProofTransactionFields {
|
|
|
68
69
|
readonly stateProof?: StateProof;
|
|
69
70
|
readonly message?: StateProofMessage;
|
|
70
71
|
}
|
|
72
|
+
export interface HeartbeatTransactionFields {
|
|
73
|
+
readonly address: Address;
|
|
74
|
+
readonly proof: HeartbeatProof;
|
|
75
|
+
readonly seed: Uint8Array;
|
|
76
|
+
readonly voteID: Uint8Array;
|
|
77
|
+
readonly keyDilution: bigint;
|
|
78
|
+
}
|
|
71
79
|
/**
|
|
72
80
|
* Transaction enables construction of Algorand transactions
|
|
73
81
|
* */
|
|
@@ -95,6 +103,7 @@ export declare class Transaction implements encoding.Encodable {
|
|
|
95
103
|
readonly assetFreeze?: AssetFreezeTransactionFields;
|
|
96
104
|
readonly applicationCall?: ApplicationTransactionFields;
|
|
97
105
|
readonly stateProof?: StateProofTransactionFields;
|
|
106
|
+
readonly heartbeat?: HeartbeatTransactionFields;
|
|
98
107
|
constructor(params: TransactionParams);
|
|
99
108
|
getEncodingSchema(): encoding.Schema;
|
|
100
109
|
toEncodingData(): Map<string, unknown>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Address } from '../../encoding/address.js';
|
|
2
2
|
import { StateProof, StateProofMessage } from '../../stateproof.js';
|
|
3
|
+
import { HeartbeatProof } from '../../heartbeat.js';
|
|
3
4
|
/**
|
|
4
5
|
* Enum for application transaction types.
|
|
5
6
|
*/
|
|
@@ -31,7 +32,11 @@ export declare enum TransactionType {
|
|
|
31
32
|
/**
|
|
32
33
|
* State proof transaction
|
|
33
34
|
*/
|
|
34
|
-
stpf = "stpf"
|
|
35
|
+
stpf = "stpf",
|
|
36
|
+
/**
|
|
37
|
+
* Heartbeat transaction
|
|
38
|
+
*/
|
|
39
|
+
hb = "hb"
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
42
|
* Check if a string is a valid transaction type
|
|
@@ -371,6 +376,28 @@ export interface StateProofTransactionParams {
|
|
|
371
376
|
*/
|
|
372
377
|
message?: StateProofMessage;
|
|
373
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Contains heartbeat transaction parameters.
|
|
381
|
+
*/
|
|
382
|
+
export interface HeartbeatTransactionParams {
|
|
383
|
+
address: Address;
|
|
384
|
+
/**
|
|
385
|
+
* Signature using HeartbeatAddress's partkey, thereby showing it is online.
|
|
386
|
+
*/
|
|
387
|
+
proof: HeartbeatProof;
|
|
388
|
+
/**
|
|
389
|
+
* The block seed for the this transaction's firstValid block.
|
|
390
|
+
*/
|
|
391
|
+
seed: Uint8Array;
|
|
392
|
+
/**
|
|
393
|
+
* Must match the hbAddress account's current VoteID
|
|
394
|
+
*/
|
|
395
|
+
voteID: Uint8Array;
|
|
396
|
+
/**
|
|
397
|
+
* Must match hbAddress account's current KeyDilution.
|
|
398
|
+
*/
|
|
399
|
+
keyDilution: bigint;
|
|
400
|
+
}
|
|
374
401
|
/**
|
|
375
402
|
* A full list of all available transaction parameters
|
|
376
403
|
*
|
|
@@ -433,4 +460,8 @@ export interface TransactionParams {
|
|
|
433
460
|
* State proof transaction parameters. Only set if type is TransactionType.stpf
|
|
434
461
|
*/
|
|
435
462
|
stateProofParams?: StateProofTransactionParams;
|
|
463
|
+
/**
|
|
464
|
+
* Heartbeat transaction parameters. Only set if type is TransactionType.hb
|
|
465
|
+
*/
|
|
466
|
+
heartbeatParams?: HeartbeatTransactionParams;
|
|
436
467
|
}
|
package/package.json
CHANGED
|
@@ -2904,6 +2904,58 @@ export class BlockHashResponse implements Encodable {
|
|
|
2904
2904
|
}
|
|
2905
2905
|
}
|
|
2906
2906
|
|
|
2907
|
+
/**
|
|
2908
|
+
* Block header.
|
|
2909
|
+
*/
|
|
2910
|
+
export class BlockHeaderResponse implements Encodable {
|
|
2911
|
+
private static encodingSchemaValue: Schema | undefined;
|
|
2912
|
+
|
|
2913
|
+
static get encodingSchema(): Schema {
|
|
2914
|
+
if (!this.encodingSchemaValue) {
|
|
2915
|
+
this.encodingSchemaValue = new NamedMapSchema([]);
|
|
2916
|
+
(this.encodingSchemaValue as NamedMapSchema).pushEntries({
|
|
2917
|
+
key: 'blockHeader',
|
|
2918
|
+
valueSchema: Block.encodingSchema,
|
|
2919
|
+
omitEmpty: true,
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
return this.encodingSchemaValue;
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
/**
|
|
2926
|
+
* Block header data.
|
|
2927
|
+
*/
|
|
2928
|
+
public blockheader: Block;
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* Creates a new `BlockHeaderResponse` object.
|
|
2932
|
+
* @param blockheader - Block header data.
|
|
2933
|
+
*/
|
|
2934
|
+
constructor({ blockheader }: { blockheader: Block }) {
|
|
2935
|
+
this.blockheader = blockheader;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2939
|
+
getEncodingSchema(): Schema {
|
|
2940
|
+
return BlockHeaderResponse.encodingSchema;
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
toEncodingData(): Map<string, unknown> {
|
|
2944
|
+
return new Map<string, unknown>([
|
|
2945
|
+
['blockHeader', this.blockheader.toEncodingData()],
|
|
2946
|
+
]);
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
static fromEncodingData(data: unknown): BlockHeaderResponse {
|
|
2950
|
+
if (!(data instanceof Map)) {
|
|
2951
|
+
throw new Error(`Invalid decoded BlockHeaderResponse: ${data}`);
|
|
2952
|
+
}
|
|
2953
|
+
return new BlockHeaderResponse({
|
|
2954
|
+
blockheader: Block.fromEncodingData(data.get('blockHeader') ?? new Map()),
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2907
2959
|
/**
|
|
2908
2960
|
* All logs emitted in the given round. Each app call, whether top-level or inner,
|
|
2909
2961
|
* that contains logs results in a separate AppCallLogs object. Therefore there may
|
|
@@ -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:
|