algosdk 2.9.0 → 2.10.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 +27 -2
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/client/v2/indexer/models/types.js +168 -3
- package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
- package/dist/cjs/transaction.js +102 -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/cjs/types/transactions/heartbeat.js +3 -0
- package/dist/cjs/types/transactions/heartbeat.js.map +1 -0
- package/dist/cjs/types/transactions/index.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +24 -0
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/client/v2/indexer/models/types.js +163 -1
- package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
- package/dist/esm/transaction.js +102 -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/esm/types/transactions/heartbeat.js +2 -0
- package/dist/esm/types/transactions/heartbeat.js.map +1 -0
- package/dist/esm/types/transactions/index.js.map +1 -1
- package/dist/types/client/v2/algod/models/types.d.ts +17 -0
- package/dist/types/client/v2/indexer/models/types.d.ts +134 -1
- package/dist/types/transaction.d.ts +30 -2
- package/dist/types/types/transactions/base.d.ts +17 -1
- package/dist/types/types/transactions/encoded.d.ts +54 -0
- package/dist/types/types/transactions/heartbeat.d.ts +8 -0
- package/dist/types/types/transactions/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/client/v2/algod/models/types.ts +32 -0
- package/src/client/v2/indexer/models/types.ts +294 -0
- package/src/transaction.ts +131 -0
- package/src/types/transactions/base.ts +20 -1
- package/src/types/transactions/encoded.ts +65 -0
- package/src/types/transactions/heartbeat.ts +14 -0
- package/src/types/transactions/index.ts +4 -1
package/package.json
CHANGED
|
@@ -2098,6 +2098,38 @@ 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
|
+
|
|
2101
2133
|
/**
|
|
2102
2134
|
* All logs emitted in the given round. Each app call, whether top-level or inner,
|
|
2103
2135
|
* that contains logs results in a separate AppCallLogs object. Therefore there may
|
|
@@ -2467,6 +2467,68 @@ export class Block extends BaseModel {
|
|
|
2467
2467
|
}
|
|
2468
2468
|
}
|
|
2469
2469
|
|
|
2470
|
+
/**
|
|
2471
|
+
*
|
|
2472
|
+
*/
|
|
2473
|
+
export class BlockHeadersResponse extends BaseModel {
|
|
2474
|
+
public blocks?: Block[];
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* Round at which the results were computed.
|
|
2478
|
+
*/
|
|
2479
|
+
public currentRound?: number | bigint;
|
|
2480
|
+
|
|
2481
|
+
/**
|
|
2482
|
+
* Used for pagination, when making another request provide this token with the
|
|
2483
|
+
* next parameter.
|
|
2484
|
+
*/
|
|
2485
|
+
public nextToken?: string;
|
|
2486
|
+
|
|
2487
|
+
/**
|
|
2488
|
+
* Creates a new `BlockHeadersResponse` object.
|
|
2489
|
+
* @param blocks -
|
|
2490
|
+
* @param currentRound - Round at which the results were computed.
|
|
2491
|
+
* @param nextToken - Used for pagination, when making another request provide this token with the
|
|
2492
|
+
* next parameter.
|
|
2493
|
+
*/
|
|
2494
|
+
constructor({
|
|
2495
|
+
blocks,
|
|
2496
|
+
currentRound,
|
|
2497
|
+
nextToken,
|
|
2498
|
+
}: {
|
|
2499
|
+
blocks?: Block[];
|
|
2500
|
+
currentRound?: number | bigint;
|
|
2501
|
+
nextToken?: string;
|
|
2502
|
+
}) {
|
|
2503
|
+
super();
|
|
2504
|
+
this.blocks = blocks;
|
|
2505
|
+
this.currentRound = currentRound;
|
|
2506
|
+
this.nextToken = nextToken;
|
|
2507
|
+
|
|
2508
|
+
this.attribute_map = {
|
|
2509
|
+
blocks: 'blocks',
|
|
2510
|
+
currentRound: 'current-round',
|
|
2511
|
+
nextToken: 'next-token',
|
|
2512
|
+
};
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// eslint-disable-next-line camelcase
|
|
2516
|
+
static from_obj_for_encoding(
|
|
2517
|
+
data: Record<string, any>
|
|
2518
|
+
): BlockHeadersResponse {
|
|
2519
|
+
/* eslint-disable dot-notation */
|
|
2520
|
+
return new BlockHeadersResponse({
|
|
2521
|
+
blocks:
|
|
2522
|
+
typeof data['blocks'] !== 'undefined'
|
|
2523
|
+
? data['blocks'].map(Block.from_obj_for_encoding)
|
|
2524
|
+
: undefined,
|
|
2525
|
+
currentRound: data['current-round'],
|
|
2526
|
+
nextToken: data['next-token'],
|
|
2527
|
+
});
|
|
2528
|
+
/* eslint-enable dot-notation */
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2470
2532
|
/**
|
|
2471
2533
|
* Fields relating to rewards,
|
|
2472
2534
|
*/
|
|
@@ -3080,6 +3142,106 @@ export class HashFactory extends BaseModel {
|
|
|
3080
3142
|
}
|
|
3081
3143
|
}
|
|
3082
3144
|
|
|
3145
|
+
/**
|
|
3146
|
+
* (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
|
|
3147
|
+
* it is online.
|
|
3148
|
+
*/
|
|
3149
|
+
export class HbProofFields extends BaseModel {
|
|
3150
|
+
/**
|
|
3151
|
+
* (p) Public key of the heartbeat message.
|
|
3152
|
+
*/
|
|
3153
|
+
public hbPk?: Uint8Array;
|
|
3154
|
+
|
|
3155
|
+
/**
|
|
3156
|
+
* (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the
|
|
3157
|
+
* key PK2.
|
|
3158
|
+
*/
|
|
3159
|
+
public hbPk1sig?: Uint8Array;
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* (p2) Key for new-style two-level ephemeral signature.
|
|
3163
|
+
*/
|
|
3164
|
+
public hbPk2?: Uint8Array;
|
|
3165
|
+
|
|
3166
|
+
/**
|
|
3167
|
+
* (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master
|
|
3168
|
+
* key (OneTimeSignatureVerifier).
|
|
3169
|
+
*/
|
|
3170
|
+
public hbPk2sig?: Uint8Array;
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* (s) Signature of the heartbeat message.
|
|
3174
|
+
*/
|
|
3175
|
+
public hbSig?: Uint8Array;
|
|
3176
|
+
|
|
3177
|
+
/**
|
|
3178
|
+
* Creates a new `HbProofFields` object.
|
|
3179
|
+
* @param hbPk - (p) Public key of the heartbeat message.
|
|
3180
|
+
* @param hbPk1sig - (p1s) Signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the
|
|
3181
|
+
* key PK2.
|
|
3182
|
+
* @param hbPk2 - (p2) Key for new-style two-level ephemeral signature.
|
|
3183
|
+
* @param hbPk2sig - (p2s) Signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master
|
|
3184
|
+
* key (OneTimeSignatureVerifier).
|
|
3185
|
+
* @param hbSig - (s) Signature of the heartbeat message.
|
|
3186
|
+
*/
|
|
3187
|
+
constructor({
|
|
3188
|
+
hbPk,
|
|
3189
|
+
hbPk1sig,
|
|
3190
|
+
hbPk2,
|
|
3191
|
+
hbPk2sig,
|
|
3192
|
+
hbSig,
|
|
3193
|
+
}: {
|
|
3194
|
+
hbPk?: string | Uint8Array;
|
|
3195
|
+
hbPk1sig?: string | Uint8Array;
|
|
3196
|
+
hbPk2?: string | Uint8Array;
|
|
3197
|
+
hbPk2sig?: string | Uint8Array;
|
|
3198
|
+
hbSig?: string | Uint8Array;
|
|
3199
|
+
}) {
|
|
3200
|
+
super();
|
|
3201
|
+
this.hbPk =
|
|
3202
|
+
typeof hbPk === 'string'
|
|
3203
|
+
? new Uint8Array(Buffer.from(hbPk, 'base64'))
|
|
3204
|
+
: hbPk;
|
|
3205
|
+
this.hbPk1sig =
|
|
3206
|
+
typeof hbPk1sig === 'string'
|
|
3207
|
+
? new Uint8Array(Buffer.from(hbPk1sig, 'base64'))
|
|
3208
|
+
: hbPk1sig;
|
|
3209
|
+
this.hbPk2 =
|
|
3210
|
+
typeof hbPk2 === 'string'
|
|
3211
|
+
? new Uint8Array(Buffer.from(hbPk2, 'base64'))
|
|
3212
|
+
: hbPk2;
|
|
3213
|
+
this.hbPk2sig =
|
|
3214
|
+
typeof hbPk2sig === 'string'
|
|
3215
|
+
? new Uint8Array(Buffer.from(hbPk2sig, 'base64'))
|
|
3216
|
+
: hbPk2sig;
|
|
3217
|
+
this.hbSig =
|
|
3218
|
+
typeof hbSig === 'string'
|
|
3219
|
+
? new Uint8Array(Buffer.from(hbSig, 'base64'))
|
|
3220
|
+
: hbSig;
|
|
3221
|
+
|
|
3222
|
+
this.attribute_map = {
|
|
3223
|
+
hbPk: 'hb-pk',
|
|
3224
|
+
hbPk1sig: 'hb-pk1sig',
|
|
3225
|
+
hbPk2: 'hb-pk2',
|
|
3226
|
+
hbPk2sig: 'hb-pk2sig',
|
|
3227
|
+
hbSig: 'hb-sig',
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
// eslint-disable-next-line camelcase
|
|
3232
|
+
static from_obj_for_encoding(data: Record<string, any>): HbProofFields {
|
|
3233
|
+
/* eslint-disable dot-notation */
|
|
3234
|
+
return new HbProofFields({
|
|
3235
|
+
hbPk: data['hb-pk'],
|
|
3236
|
+
hbPk1sig: data['hb-pk1sig'],
|
|
3237
|
+
hbPk2: data['hb-pk2'],
|
|
3238
|
+
hbPk2sig: data['hb-pk2sig'],
|
|
3239
|
+
hbSig: data['hb-sig'],
|
|
3240
|
+
});
|
|
3241
|
+
/* eslint-enable dot-notation */
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3083
3245
|
/**
|
|
3084
3246
|
* A health check response.
|
|
3085
3247
|
*/
|
|
@@ -4195,6 +4357,13 @@ export class Transaction extends BaseModel {
|
|
|
4195
4357
|
*/
|
|
4196
4358
|
public group?: Uint8Array;
|
|
4197
4359
|
|
|
4360
|
+
/**
|
|
4361
|
+
* Fields for a heartbeat transaction.
|
|
4362
|
+
* Definition:
|
|
4363
|
+
* data/transactions/heartbeat.go : HeartbeatTxnFields
|
|
4364
|
+
*/
|
|
4365
|
+
public heartbeatTransaction?: TransactionHeartbeat;
|
|
4366
|
+
|
|
4198
4367
|
/**
|
|
4199
4368
|
* Transaction ID
|
|
4200
4369
|
*/
|
|
@@ -4295,6 +4464,7 @@ export class Transaction extends BaseModel {
|
|
|
4295
4464
|
* * (afrz) asset-freeze-transaction
|
|
4296
4465
|
* * (appl) application-transaction
|
|
4297
4466
|
* * (stpf) state-proof-transaction
|
|
4467
|
+
* * (hb) heartbeat-transaction
|
|
4298
4468
|
*/
|
|
4299
4469
|
public txType?: string;
|
|
4300
4470
|
|
|
@@ -4334,6 +4504,9 @@ export class Transaction extends BaseModel {
|
|
|
4334
4504
|
* @param group - (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates
|
|
4335
4505
|
* that this transaction is part of a transaction group and the value is the
|
|
4336
4506
|
* sha512/256 hash of the transactions in that group.
|
|
4507
|
+
* @param heartbeatTransaction - Fields for a heartbeat transaction.
|
|
4508
|
+
* Definition:
|
|
4509
|
+
* data/transactions/heartbeat.go : HeartbeatTxnFields
|
|
4337
4510
|
* @param id - Transaction ID
|
|
4338
4511
|
* @param innerTxns - Inner transactions produced by application execution.
|
|
4339
4512
|
* @param intraRoundOffset - Offset into the round where this transaction was confirmed.
|
|
@@ -4373,6 +4546,7 @@ export class Transaction extends BaseModel {
|
|
|
4373
4546
|
* * (afrz) asset-freeze-transaction
|
|
4374
4547
|
* * (appl) application-transaction
|
|
4375
4548
|
* * (stpf) state-proof-transaction
|
|
4549
|
+
* * (hb) heartbeat-transaction
|
|
4376
4550
|
*/
|
|
4377
4551
|
constructor({
|
|
4378
4552
|
fee,
|
|
@@ -4393,6 +4567,7 @@ export class Transaction extends BaseModel {
|
|
|
4393
4567
|
genesisId,
|
|
4394
4568
|
globalStateDelta,
|
|
4395
4569
|
group,
|
|
4570
|
+
heartbeatTransaction,
|
|
4396
4571
|
id,
|
|
4397
4572
|
innerTxns,
|
|
4398
4573
|
intraRoundOffset,
|
|
@@ -4428,6 +4603,7 @@ export class Transaction extends BaseModel {
|
|
|
4428
4603
|
genesisId?: string;
|
|
4429
4604
|
globalStateDelta?: EvalDeltaKeyValue[];
|
|
4430
4605
|
group?: string | Uint8Array;
|
|
4606
|
+
heartbeatTransaction?: TransactionHeartbeat;
|
|
4431
4607
|
id?: string;
|
|
4432
4608
|
innerTxns?: Transaction[];
|
|
4433
4609
|
intraRoundOffset?: number | bigint;
|
|
@@ -4470,6 +4646,7 @@ export class Transaction extends BaseModel {
|
|
|
4470
4646
|
typeof group === 'string'
|
|
4471
4647
|
? new Uint8Array(Buffer.from(group, 'base64'))
|
|
4472
4648
|
: group;
|
|
4649
|
+
this.heartbeatTransaction = heartbeatTransaction;
|
|
4473
4650
|
this.id = id;
|
|
4474
4651
|
this.innerTxns = innerTxns;
|
|
4475
4652
|
this.intraRoundOffset = intraRoundOffset;
|
|
@@ -4512,6 +4689,7 @@ export class Transaction extends BaseModel {
|
|
|
4512
4689
|
genesisId: 'genesis-id',
|
|
4513
4690
|
globalStateDelta: 'global-state-delta',
|
|
4514
4691
|
group: 'group',
|
|
4692
|
+
heartbeatTransaction: 'heartbeat-transaction',
|
|
4515
4693
|
id: 'id',
|
|
4516
4694
|
innerTxns: 'inner-txns',
|
|
4517
4695
|
intraRoundOffset: 'intra-round-offset',
|
|
@@ -4590,6 +4768,12 @@ export class Transaction extends BaseModel {
|
|
|
4590
4768
|
)
|
|
4591
4769
|
: undefined,
|
|
4592
4770
|
group: data['group'],
|
|
4771
|
+
heartbeatTransaction:
|
|
4772
|
+
typeof data['heartbeat-transaction'] !== 'undefined'
|
|
4773
|
+
? TransactionHeartbeat.from_obj_for_encoding(
|
|
4774
|
+
data['heartbeat-transaction']
|
|
4775
|
+
)
|
|
4776
|
+
: undefined,
|
|
4593
4777
|
id: data['id'],
|
|
4594
4778
|
innerTxns:
|
|
4595
4779
|
typeof data['inner-txns'] !== 'undefined'
|
|
@@ -5094,6 +5278,116 @@ export class TransactionAssetTransfer extends BaseModel {
|
|
|
5094
5278
|
}
|
|
5095
5279
|
}
|
|
5096
5280
|
|
|
5281
|
+
/**
|
|
5282
|
+
* Fields for a heartbeat transaction.
|
|
5283
|
+
* Definition:
|
|
5284
|
+
* data/transactions/heartbeat.go : HeartbeatTxnFields
|
|
5285
|
+
*/
|
|
5286
|
+
export class TransactionHeartbeat extends BaseModel {
|
|
5287
|
+
/**
|
|
5288
|
+
* (hbad) HbAddress is the account this txn is proving onlineness for.
|
|
5289
|
+
*/
|
|
5290
|
+
public hbAddress: string;
|
|
5291
|
+
|
|
5292
|
+
/**
|
|
5293
|
+
* (hbkd) HbKeyDilution must match HbAddress account's current KeyDilution.
|
|
5294
|
+
*/
|
|
5295
|
+
public hbKeyDilution: number | bigint;
|
|
5296
|
+
|
|
5297
|
+
/**
|
|
5298
|
+
* (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
|
|
5299
|
+
* it is online.
|
|
5300
|
+
*/
|
|
5301
|
+
public hbProof: HbProofFields;
|
|
5302
|
+
|
|
5303
|
+
/**
|
|
5304
|
+
* (hbsd) HbSeed must be the block seed for the this transaction's firstValid
|
|
5305
|
+
* block.
|
|
5306
|
+
*/
|
|
5307
|
+
public hbSeed: Uint8Array;
|
|
5308
|
+
|
|
5309
|
+
/**
|
|
5310
|
+
* (hbvid) HbVoteID must match the HbAddress account's current VoteID.
|
|
5311
|
+
*/
|
|
5312
|
+
public hbVoteId: Uint8Array;
|
|
5313
|
+
|
|
5314
|
+
/**
|
|
5315
|
+
* Creates a new `TransactionHeartbeat` object.
|
|
5316
|
+
* @param hbAddress - (hbad) HbAddress is the account this txn is proving onlineness for.
|
|
5317
|
+
* @param hbKeyDilution - (hbkd) HbKeyDilution must match HbAddress account's current KeyDilution.
|
|
5318
|
+
* @param hbProof - (hbprf) HbProof is a signature using HeartbeatAddress's partkey, thereby showing
|
|
5319
|
+
* it is online.
|
|
5320
|
+
* @param hbSeed - (hbsd) HbSeed must be the block seed for the this transaction's firstValid
|
|
5321
|
+
* block.
|
|
5322
|
+
* @param hbVoteId - (hbvid) HbVoteID must match the HbAddress account's current VoteID.
|
|
5323
|
+
*/
|
|
5324
|
+
constructor({
|
|
5325
|
+
hbAddress,
|
|
5326
|
+
hbKeyDilution,
|
|
5327
|
+
hbProof,
|
|
5328
|
+
hbSeed,
|
|
5329
|
+
hbVoteId,
|
|
5330
|
+
}: {
|
|
5331
|
+
hbAddress: string;
|
|
5332
|
+
hbKeyDilution: number | bigint;
|
|
5333
|
+
hbProof: HbProofFields;
|
|
5334
|
+
hbSeed: string | Uint8Array;
|
|
5335
|
+
hbVoteId: string | Uint8Array;
|
|
5336
|
+
}) {
|
|
5337
|
+
super();
|
|
5338
|
+
this.hbAddress = hbAddress;
|
|
5339
|
+
this.hbKeyDilution = hbKeyDilution;
|
|
5340
|
+
this.hbProof = hbProof;
|
|
5341
|
+
this.hbSeed =
|
|
5342
|
+
typeof hbSeed === 'string'
|
|
5343
|
+
? new Uint8Array(Buffer.from(hbSeed, 'base64'))
|
|
5344
|
+
: hbSeed;
|
|
5345
|
+
this.hbVoteId =
|
|
5346
|
+
typeof hbVoteId === 'string'
|
|
5347
|
+
? new Uint8Array(Buffer.from(hbVoteId, 'base64'))
|
|
5348
|
+
: hbVoteId;
|
|
5349
|
+
|
|
5350
|
+
this.attribute_map = {
|
|
5351
|
+
hbAddress: 'hb-address',
|
|
5352
|
+
hbKeyDilution: 'hb-key-dilution',
|
|
5353
|
+
hbProof: 'hb-proof',
|
|
5354
|
+
hbSeed: 'hb-seed',
|
|
5355
|
+
hbVoteId: 'hb-vote-id',
|
|
5356
|
+
};
|
|
5357
|
+
}
|
|
5358
|
+
|
|
5359
|
+
// eslint-disable-next-line camelcase
|
|
5360
|
+
static from_obj_for_encoding(
|
|
5361
|
+
data: Record<string, any>
|
|
5362
|
+
): TransactionHeartbeat {
|
|
5363
|
+
/* eslint-disable dot-notation */
|
|
5364
|
+
if (typeof data['hb-address'] === 'undefined')
|
|
5365
|
+
throw new Error(
|
|
5366
|
+
`Response is missing required field 'hb-address': ${data}`
|
|
5367
|
+
);
|
|
5368
|
+
if (typeof data['hb-key-dilution'] === 'undefined')
|
|
5369
|
+
throw new Error(
|
|
5370
|
+
`Response is missing required field 'hb-key-dilution': ${data}`
|
|
5371
|
+
);
|
|
5372
|
+
if (typeof data['hb-proof'] === 'undefined')
|
|
5373
|
+
throw new Error(`Response is missing required field 'hb-proof': ${data}`);
|
|
5374
|
+
if (typeof data['hb-seed'] === 'undefined')
|
|
5375
|
+
throw new Error(`Response is missing required field 'hb-seed': ${data}`);
|
|
5376
|
+
if (typeof data['hb-vote-id'] === 'undefined')
|
|
5377
|
+
throw new Error(
|
|
5378
|
+
`Response is missing required field 'hb-vote-id': ${data}`
|
|
5379
|
+
);
|
|
5380
|
+
return new TransactionHeartbeat({
|
|
5381
|
+
hbAddress: data['hb-address'],
|
|
5382
|
+
hbKeyDilution: data['hb-key-dilution'],
|
|
5383
|
+
hbProof: HbProofFields.from_obj_for_encoding(data['hb-proof']),
|
|
5384
|
+
hbSeed: data['hb-seed'],
|
|
5385
|
+
hbVoteId: data['hb-vote-id'],
|
|
5386
|
+
});
|
|
5387
|
+
/* eslint-enable dot-notation */
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
|
|
5097
5391
|
/**
|
|
5098
5392
|
* Fields for a keyreg transaction.
|
|
5099
5393
|
* Definition:
|
package/src/transaction.ts
CHANGED
|
@@ -19,6 +19,8 @@ import AnyTransaction, {
|
|
|
19
19
|
EncodedSignedTransaction,
|
|
20
20
|
EncodedMultisig,
|
|
21
21
|
EncodedLogicSig,
|
|
22
|
+
EncodedHeartbeatFields,
|
|
23
|
+
EncodedHeartbeatProof,
|
|
22
24
|
} from './types/transactions';
|
|
23
25
|
import { Address } from './types/address';
|
|
24
26
|
|
|
@@ -38,6 +40,100 @@ const KEYREG_STATE_PROOF_KEY_LENGTH = 64;
|
|
|
38
40
|
type AnyTransactionWithParams = MustHaveSuggestedParams<AnyTransaction>;
|
|
39
41
|
type AnyTransactionWithParamsInline = MustHaveSuggestedParamsInline<AnyTransaction>;
|
|
40
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Object representing a heartbeat proof
|
|
45
|
+
*/
|
|
46
|
+
class HeartbeatProof {
|
|
47
|
+
s: Buffer;
|
|
48
|
+
p: Buffer;
|
|
49
|
+
p2: Buffer;
|
|
50
|
+
p1s: Buffer;
|
|
51
|
+
p2s: Buffer;
|
|
52
|
+
|
|
53
|
+
constructor(sig: Buffer, pk: Buffer, pk2: Buffer, p1s: Buffer, p2s: Buffer) {
|
|
54
|
+
this.s = sig;
|
|
55
|
+
this.p = pk;
|
|
56
|
+
this.p2 = pk2;
|
|
57
|
+
this.p1s = p1s;
|
|
58
|
+
this.p2s = p2s;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line camelcase
|
|
62
|
+
static from_obj_for_encoding(
|
|
63
|
+
encHbFields: EncodedHeartbeatProof
|
|
64
|
+
): HeartbeatProof {
|
|
65
|
+
const proof = Object.create(this.prototype) as HeartbeatProof;
|
|
66
|
+
proof.s = encHbFields.s;
|
|
67
|
+
proof.p = encHbFields.p;
|
|
68
|
+
proof.p2 = encHbFields.p2;
|
|
69
|
+
proof.p1s = encHbFields.p1s;
|
|
70
|
+
proof.p2s = encHbFields.p2s;
|
|
71
|
+
return proof;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line camelcase
|
|
75
|
+
get_obj_for_encoding() {
|
|
76
|
+
const fields: EncodedHeartbeatProof = {
|
|
77
|
+
s: this.s,
|
|
78
|
+
p: this.p,
|
|
79
|
+
p2: this.p2,
|
|
80
|
+
p1s: this.p1s,
|
|
81
|
+
p2s: this.p2s,
|
|
82
|
+
};
|
|
83
|
+
return fields;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Object representing a heartbeat transaction
|
|
89
|
+
*/
|
|
90
|
+
class HeartbeatFields {
|
|
91
|
+
a: string | Address;
|
|
92
|
+
prf: HeartbeatProof;
|
|
93
|
+
sd: Buffer;
|
|
94
|
+
vid: Buffer;
|
|
95
|
+
kd: number;
|
|
96
|
+
|
|
97
|
+
constructor(
|
|
98
|
+
addr: string | Address,
|
|
99
|
+
proof: EncodedHeartbeatProof,
|
|
100
|
+
seed: Buffer,
|
|
101
|
+
voteID: Buffer,
|
|
102
|
+
kd: number
|
|
103
|
+
) {
|
|
104
|
+
this.a = addr;
|
|
105
|
+
this.prf = HeartbeatProof.from_obj_for_encoding(proof);
|
|
106
|
+
this.sd = seed;
|
|
107
|
+
this.vid = voteID;
|
|
108
|
+
this.kd = kd;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// eslint-disable-next-line camelcase
|
|
112
|
+
static from_obj_for_encoding(
|
|
113
|
+
encHbFields: EncodedHeartbeatFields
|
|
114
|
+
): HeartbeatFields {
|
|
115
|
+
const fields = Object.create(this.prototype) as HeartbeatFields;
|
|
116
|
+
fields.a = address.decodeAddress(address.encodeAddress(encHbFields.a));
|
|
117
|
+
fields.prf = HeartbeatProof.from_obj_for_encoding(encHbFields.prf);
|
|
118
|
+
fields.sd = Buffer.from(encHbFields.sd);
|
|
119
|
+
fields.vid = Buffer.from(encHbFields.vid);
|
|
120
|
+
fields.kd = encHbFields.kd;
|
|
121
|
+
return fields;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// eslint-disable-next-line camelcase
|
|
125
|
+
get_obj_for_encoding() {
|
|
126
|
+
const fields: EncodedHeartbeatFields = {
|
|
127
|
+
a: Buffer.from((this.a as Address).publicKey),
|
|
128
|
+
prf: this.prf.get_obj_for_encoding(),
|
|
129
|
+
sd: this.sd,
|
|
130
|
+
vid: this.vid,
|
|
131
|
+
kd: this.kd,
|
|
132
|
+
};
|
|
133
|
+
return fields;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
41
137
|
/**
|
|
42
138
|
* A modified version of the transaction params. Represents the internal structure that the Transaction class uses
|
|
43
139
|
* to store inputted transaction objects.
|
|
@@ -62,6 +158,7 @@ interface TransactionStorageStructure
|
|
|
62
158
|
| 'appAccounts'
|
|
63
159
|
| 'suggestedParams'
|
|
64
160
|
| 'reKeyTo'
|
|
161
|
+
| 'heartbeatFields' // redefine type to silent TS error about 'string | Address' and 'string' incompatibility
|
|
65
162
|
> {
|
|
66
163
|
from: string | Address;
|
|
67
164
|
to: string | Address;
|
|
@@ -117,6 +214,7 @@ interface TransactionStorageStructure
|
|
|
117
214
|
stateProofType?: number | bigint;
|
|
118
215
|
stateProof?: Uint8Array;
|
|
119
216
|
stateProofMessage?: Uint8Array;
|
|
217
|
+
heartbeatFields?: HeartbeatFields;
|
|
120
218
|
}
|
|
121
219
|
|
|
122
220
|
function getKeyregKey(
|
|
@@ -209,6 +307,7 @@ export class Transaction implements TransactionStorageStructure {
|
|
|
209
307
|
stateProofType?: number | bigint;
|
|
210
308
|
stateProof?: Uint8Array;
|
|
211
309
|
stateProofMessage?: Uint8Array;
|
|
310
|
+
heartbeatFields?: HeartbeatFields;
|
|
212
311
|
|
|
213
312
|
constructor({ ...transaction }: AnyTransaction) {
|
|
214
313
|
// Populate defaults
|
|
@@ -574,6 +673,10 @@ export class Transaction implements TransactionStorageStructure {
|
|
|
574
673
|
} else {
|
|
575
674
|
txn.stateProof = new Uint8Array(0);
|
|
576
675
|
}
|
|
676
|
+
if (txn.heartbeatFields !== undefined) {
|
|
677
|
+
if (txn.heartbeatFields.constructor !== HeartbeatFields)
|
|
678
|
+
throw Error('heartbeatFields must be a HeartbeatFields.');
|
|
679
|
+
}
|
|
577
680
|
}
|
|
578
681
|
|
|
579
682
|
// eslint-disable-next-line camelcase
|
|
@@ -918,6 +1021,28 @@ export class Transaction implements TransactionStorageStructure {
|
|
|
918
1021
|
if (txn.grp === undefined) delete txn.grp;
|
|
919
1022
|
return txn;
|
|
920
1023
|
}
|
|
1024
|
+
if (this.type === 'hb') {
|
|
1025
|
+
// heartbeat txn
|
|
1026
|
+
const txn: EncodedTransaction = {
|
|
1027
|
+
fee: this.fee,
|
|
1028
|
+
fv: this.firstRound,
|
|
1029
|
+
lv: this.lastRound,
|
|
1030
|
+
note: Buffer.from(this.note),
|
|
1031
|
+
snd: Buffer.from(this.from.publicKey),
|
|
1032
|
+
type: this.type,
|
|
1033
|
+
gen: this.genesisID,
|
|
1034
|
+
gh: this.genesisHash,
|
|
1035
|
+
lx: Buffer.from(this.lease),
|
|
1036
|
+
hb: this.heartbeatFields.get_obj_for_encoding(),
|
|
1037
|
+
};
|
|
1038
|
+
// allowed zero values
|
|
1039
|
+
if (!txn.note.length) delete txn.note;
|
|
1040
|
+
if (!txn.lx.length) delete txn.lx;
|
|
1041
|
+
if (!txn.fee) delete txn.fee;
|
|
1042
|
+
if (!txn.gen) delete txn.gen;
|
|
1043
|
+
if (txn.grp === undefined) delete txn.grp;
|
|
1044
|
+
return txn;
|
|
1045
|
+
}
|
|
921
1046
|
|
|
922
1047
|
return undefined;
|
|
923
1048
|
}
|
|
@@ -1105,6 +1230,12 @@ export class Transaction implements TransactionStorageStructure {
|
|
|
1105
1230
|
if (txnForEnc.spmsg !== undefined) {
|
|
1106
1231
|
txn.stateProofMessage = txnForEnc.spmsg;
|
|
1107
1232
|
}
|
|
1233
|
+
} else if (txnForEnc.type === 'hb') {
|
|
1234
|
+
if (txnForEnc.hb !== undefined) {
|
|
1235
|
+
txn.heartbeatFields = HeartbeatFields.from_obj_for_encoding(
|
|
1236
|
+
txnForEnc.hb
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1108
1239
|
}
|
|
1109
1240
|
return txn;
|
|
1110
1241
|
}
|
|
@@ -37,6 +37,11 @@ export enum TransactionType {
|
|
|
37
37
|
* State proof transaction
|
|
38
38
|
*/
|
|
39
39
|
stpf = 'stpf',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Heartbeat transaction
|
|
43
|
+
*/
|
|
44
|
+
hb = 'hb',
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
export function isTransactionType(s: string): s is TransactionType {
|
|
@@ -47,7 +52,8 @@ export function isTransactionType(s: string): s is TransactionType {
|
|
|
47
52
|
s === TransactionType.axfer ||
|
|
48
53
|
s === TransactionType.afrz ||
|
|
49
54
|
s === TransactionType.appl ||
|
|
50
|
-
s === TransactionType.stpf
|
|
55
|
+
s === TransactionType.stpf ||
|
|
56
|
+
s === TransactionType.hb
|
|
51
57
|
);
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -152,6 +158,14 @@ export interface BoxReference {
|
|
|
152
158
|
name: Uint8Array;
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
interface heartbeatFields {
|
|
162
|
+
a: string;
|
|
163
|
+
prf: Uint8Array;
|
|
164
|
+
sd: Uint8Array;
|
|
165
|
+
vid: Uint8Array;
|
|
166
|
+
kd: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
155
169
|
/**
|
|
156
170
|
* A full list of all available transaction parameters
|
|
157
171
|
*
|
|
@@ -432,4 +446,9 @@ export interface TransactionParams {
|
|
|
432
446
|
* Byte array containing the state proof message.
|
|
433
447
|
*/
|
|
434
448
|
stateProofMessage?: Uint8Array;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* HeartbeatFields fields
|
|
452
|
+
*/
|
|
453
|
+
heartbeatFields?: heartbeatFields;
|
|
435
454
|
}
|