algosdk 2.8.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/abi/contract.js +2 -0
- package/dist/cjs/abi/contract.js.map +1 -1
- package/dist/cjs/abi/event.js +3 -0
- package/dist/cjs/abi/event.js.map +1 -0
- package/dist/cjs/abi/method.js +4 -0
- package/dist/cjs/abi/method.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +45 -5
- 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/makeTxn.js +26 -0
- package/dist/cjs/makeTxn.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/abi/contract.js +2 -0
- package/dist/esm/abi/contract.js.map +1 -1
- package/dist/esm/abi/event.js +2 -0
- package/dist/esm/abi/event.js.map +1 -0
- package/dist/esm/abi/method.js +4 -0
- package/dist/esm/abi/method.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +42 -3
- 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/makeTxn.js +26 -0
- package/dist/esm/makeTxn.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/abi/contract.d.ts +4 -0
- package/dist/types/abi/event.d.ts +16 -0
- package/dist/types/abi/method.d.ts +7 -0
- package/dist/types/client/v2/algod/models/types.d.ts +44 -3
- package/dist/types/client/v2/indexer/models/types.d.ts +134 -1
- package/dist/types/makeTxn.d.ts +28 -0
- 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/abi/contract.ts +6 -0
- package/src/abi/event.ts +16 -0
- package/src/abi/method.ts +12 -0
- package/src/client/v2/algod/models/types.ts +71 -0
- package/src/client/v2/indexer/models/types.ts +294 -0
- package/src/makeTxn.ts +28 -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/src/makeTxn.ts
CHANGED
|
@@ -39,6 +39,8 @@ import { RenameProperties, RenameProperty, Expand } from './types/utils';
|
|
|
39
39
|
* genesisHash - string specifies hash genesis block of network in use
|
|
40
40
|
* genesisID - string specifies genesis ID of network in use
|
|
41
41
|
* @param rekeyTo - rekeyTo address, optional
|
|
42
|
+
*
|
|
43
|
+
* @deprecated This function will be removed in v3 in favor of {@link makePaymentTxnWithSuggestedParamsFromObject}
|
|
42
44
|
*/
|
|
43
45
|
export function makePaymentTxnWithSuggestedParams(
|
|
44
46
|
from: PaymentTxn['from'],
|
|
@@ -111,6 +113,8 @@ export function makePaymentTxnWithSuggestedParamsFromObject(
|
|
|
111
113
|
* @param nonParticipation - configure whether the address wants to stop participating. If true,
|
|
112
114
|
* voteKey, selectionKey, voteFirst, voteLast, and voteKeyDilution must be undefined.
|
|
113
115
|
* @param stateProofKey - state proof key. for key deregistration, leave undefined
|
|
116
|
+
*
|
|
117
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeKeyRegistrationTxnWithSuggestedParamsFromObject}
|
|
114
118
|
*/
|
|
115
119
|
export function makeKeyRegistrationTxnWithSuggestedParams(
|
|
116
120
|
from: KeyRegistrationTxn['from'],
|
|
@@ -245,6 +249,8 @@ export function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o: any) {
|
|
|
245
249
|
* genesisHash - string specifies hash genesis block of network in use
|
|
246
250
|
* genesisID - string specifies genesis ID of network in use
|
|
247
251
|
* @param rekeyTo - rekeyTo address, optional
|
|
252
|
+
*
|
|
253
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeAssetCreateTxnWithSuggestedParamsFromObject}
|
|
248
254
|
*/
|
|
249
255
|
export function makeAssetCreateTxnWithSuggestedParams(
|
|
250
256
|
from: AssetCreateTxn['from'],
|
|
@@ -360,6 +366,8 @@ export function makeAssetCreateTxnWithSuggestedParamsFromObject(
|
|
|
360
366
|
* genesisHash - string specifies hash genesis block of network in use
|
|
361
367
|
* genesisID - string specifies genesis ID of network in use
|
|
362
368
|
* @param rekeyTo - rekeyTo address, optional
|
|
369
|
+
*
|
|
370
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeAssetConfigTxnWithSuggestedParamsFromObject}
|
|
363
371
|
*/
|
|
364
372
|
export function makeAssetConfigTxnWithSuggestedParams(
|
|
365
373
|
from: AssetConfigTxn['from'],
|
|
@@ -456,6 +464,8 @@ export function makeAssetConfigTxnWithSuggestedParamsFromObject(
|
|
|
456
464
|
* genesisHash - string specifies hash genesis block of network in use
|
|
457
465
|
* genesisID - string specifies genesis ID of network in use
|
|
458
466
|
* @param rekeyTo - rekeyTo address, optional
|
|
467
|
+
*
|
|
468
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeAssetDestroyTxnWithSuggestedParamsFromObject}
|
|
459
469
|
*/
|
|
460
470
|
export function makeAssetDestroyTxnWithSuggestedParams(
|
|
461
471
|
from: AssetDestroyTxn['from'],
|
|
@@ -514,6 +524,8 @@ export function makeAssetDestroyTxnWithSuggestedParamsFromObject(
|
|
|
514
524
|
* genesisHash - string specifies hash genesis block of network in use
|
|
515
525
|
* genesisID - string specifies genesis ID of network in use
|
|
516
526
|
* @param rekeyTo - rekeyTo address, optional
|
|
527
|
+
*
|
|
528
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeAssetFreezeTxnWithSuggestedParamsFromObject}
|
|
517
529
|
*/
|
|
518
530
|
export function makeAssetFreezeTxnWithSuggestedParams(
|
|
519
531
|
from: AssetFreezeTxn['from'],
|
|
@@ -592,6 +604,8 @@ export function makeAssetFreezeTxnWithSuggestedParamsFromObject(
|
|
|
592
604
|
* genesisHash - string specifies hash genesis block of network in use
|
|
593
605
|
* genesisID - string specifies genesis ID of network in use
|
|
594
606
|
* @param rekeyTo - rekeyTo address, optional
|
|
607
|
+
*
|
|
608
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeAssetTransferTxnWithSuggestedParamsFromObject}
|
|
595
609
|
*/
|
|
596
610
|
export function makeAssetTransferTxnWithSuggestedParams(
|
|
597
611
|
from: AssetTransferTxn['from'],
|
|
@@ -682,6 +696,8 @@ export function makeAssetTransferTxnWithSuggestedParamsFromObject(
|
|
|
682
696
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
683
697
|
* @param extraPages - integer extra pages of memory to rent on creation of application
|
|
684
698
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
699
|
+
*
|
|
700
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationCreateTxnFromObject}
|
|
685
701
|
*/
|
|
686
702
|
export function makeApplicationCreateTxn(
|
|
687
703
|
from: AppCreateTxn['from'],
|
|
@@ -813,6 +829,8 @@ export function makeApplicationCreateTxnFromObject(
|
|
|
813
829
|
* @param lease - Lease a transaction
|
|
814
830
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
815
831
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
832
|
+
*
|
|
833
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationUpdateTxnFromObject}
|
|
816
834
|
*/
|
|
817
835
|
export function makeApplicationUpdateTxn(
|
|
818
836
|
from: AppUpdateTxn['from'],
|
|
@@ -917,6 +935,8 @@ export function makeApplicationUpdateTxnFromObject(
|
|
|
917
935
|
* @param lease - Lease a transaction
|
|
918
936
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
919
937
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
938
|
+
*
|
|
939
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationDeleteTxnFromObject}
|
|
920
940
|
*/
|
|
921
941
|
export function makeApplicationDeleteTxn(
|
|
922
942
|
from: AppDeleteTxn['from'],
|
|
@@ -1011,6 +1031,8 @@ export function makeApplicationDeleteTxnFromObject(
|
|
|
1011
1031
|
* @param lease - Lease a transaction
|
|
1012
1032
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
1013
1033
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
1034
|
+
*
|
|
1035
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationOptInTxnFromObject}
|
|
1014
1036
|
*/
|
|
1015
1037
|
export function makeApplicationOptInTxn(
|
|
1016
1038
|
from: AppOptInTxn['from'],
|
|
@@ -1105,6 +1127,8 @@ export function makeApplicationOptInTxnFromObject(
|
|
|
1105
1127
|
* @param lease - Lease a transaction
|
|
1106
1128
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
1107
1129
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
1130
|
+
*
|
|
1131
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationCloseOutTxnFromObject}
|
|
1108
1132
|
*/
|
|
1109
1133
|
export function makeApplicationCloseOutTxn(
|
|
1110
1134
|
from: AppCloseOutTxn['from'],
|
|
@@ -1199,6 +1223,8 @@ export function makeApplicationCloseOutTxnFromObject(
|
|
|
1199
1223
|
* @param lease - Lease a transaction
|
|
1200
1224
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
1201
1225
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
1226
|
+
*
|
|
1227
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationClearStateTxnFromObject}
|
|
1202
1228
|
*/
|
|
1203
1229
|
export function makeApplicationClearStateTxn(
|
|
1204
1230
|
from: AppClearStateTxn['from'],
|
|
@@ -1293,6 +1319,8 @@ export function makeApplicationClearStateTxnFromObject(
|
|
|
1293
1319
|
* @param lease - Lease a transaction
|
|
1294
1320
|
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
|
|
1295
1321
|
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
|
|
1322
|
+
*
|
|
1323
|
+
* @deprecated This function will be removed in v3 in favor of {@link makeApplicationNoOpTxnFromObject}
|
|
1296
1324
|
*/
|
|
1297
1325
|
export function makeApplicationNoOpTxn(
|
|
1298
1326
|
from: AppNoOpTxn['from'],
|
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
|
}
|
|
@@ -97,6 +97,66 @@ export interface EncodedBoxReference {
|
|
|
97
97
|
n: Uint8Array;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* A structure for an encoded heartbeat proof fields object
|
|
102
|
+
*/
|
|
103
|
+
export interface EncodedHeartbeatProof {
|
|
104
|
+
/**
|
|
105
|
+
* Sig
|
|
106
|
+
*/
|
|
107
|
+
s: Buffer;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* PK
|
|
111
|
+
*/
|
|
112
|
+
p: Buffer;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* PK2
|
|
116
|
+
*/
|
|
117
|
+
p2: Buffer;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* PK1Sig
|
|
121
|
+
*/
|
|
122
|
+
p1s: Buffer;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* PK2Sig
|
|
126
|
+
*/
|
|
127
|
+
p2s: Buffer;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A structure for an encoded heartbeat fields object
|
|
132
|
+
*/
|
|
133
|
+
export interface EncodedHeartbeatFields {
|
|
134
|
+
/**
|
|
135
|
+
* HbAddress
|
|
136
|
+
*/
|
|
137
|
+
a: Buffer;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* HbProof
|
|
141
|
+
*/
|
|
142
|
+
prf: EncodedHeartbeatProof;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* HbSeed
|
|
146
|
+
*/
|
|
147
|
+
sd: Buffer;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* HbVoteID
|
|
151
|
+
*/
|
|
152
|
+
vid: Buffer;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* HbKeyDilution
|
|
156
|
+
*/
|
|
157
|
+
kd: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
100
160
|
/**
|
|
101
161
|
* A rough structure for the encoded transaction object. Every property is labelled with its associated Transaction type property
|
|
102
162
|
*/
|
|
@@ -330,6 +390,11 @@ export interface EncodedTransaction {
|
|
|
330
390
|
* stateProofMessage
|
|
331
391
|
*/
|
|
332
392
|
spmsg?: Buffer;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* heartbeat fields
|
|
396
|
+
*/
|
|
397
|
+
hb?: EncodedHeartbeatFields;
|
|
333
398
|
}
|
|
334
399
|
|
|
335
400
|
export interface EncodedSubsig {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransactionType, TransactionParams } from './base';
|
|
2
|
+
import { ConstructTransaction } from './builder';
|
|
3
|
+
|
|
4
|
+
type SpecificParameters = Pick<TransactionParams, 'heartbeatFields'>;
|
|
5
|
+
|
|
6
|
+
interface Overwrites {
|
|
7
|
+
type?: TransactionType.hb;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type HeartbeatTransaction = ConstructTransaction<
|
|
11
|
+
SpecificParameters,
|
|
12
|
+
Overwrites
|
|
13
|
+
>;
|
|
14
|
+
export default HeartbeatTransaction;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
ApplicationNoOpTransaction as AppNoOpTxn,
|
|
18
18
|
} from './application';
|
|
19
19
|
import StateProofTxn from './stateproof';
|
|
20
|
+
import HeartbeatTxn from './heartbeat';
|
|
20
21
|
|
|
21
22
|
// Utilities
|
|
22
23
|
export {
|
|
@@ -51,6 +52,7 @@ export {
|
|
|
51
52
|
ApplicationNoOpTransaction as AppNoOpTxn,
|
|
52
53
|
} from './application';
|
|
53
54
|
export { default as StateProofTxn } from './stateproof';
|
|
55
|
+
export { default as HeartbeatTransaction } from './heartbeat';
|
|
54
56
|
|
|
55
57
|
// All possible transaction types
|
|
56
58
|
type AnyTransaction =
|
|
@@ -68,5 +70,6 @@ type AnyTransaction =
|
|
|
68
70
|
| AppCloseOutTxn
|
|
69
71
|
| AppClearStateTxn
|
|
70
72
|
| AppNoOpTxn
|
|
71
|
-
| StateProofTxn
|
|
73
|
+
| StateProofTxn
|
|
74
|
+
| HeartbeatTxn;
|
|
72
75
|
export default AnyTransaction;
|