/
types.ts
5728 lines (5236 loc) · 171 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* NOTICE: This file was generated. Editing this file manually is not recommended.
*/
/* eslint-disable no-use-before-define */
import { Buffer } from 'buffer';
import BaseModel from '../../basemodel';
import { EncodedSignedTransaction } from '../../../../types/transactions/encoded';
import BlockHeader from '../../../../types/blockHeader';
/**
* Account information at a given round.
* Definition:
* data/basics/userBalance.go : AccountData
*/
export class Account extends BaseModel {
/**
* the account public key
*/
public address: string;
/**
* (algo) total number of MicroAlgos in the account
*/
public amount: number | bigint;
/**
* specifies the amount of MicroAlgos in the account, without the pending rewards.
*/
public amountWithoutPendingRewards: number | bigint;
/**
* MicroAlgo balance required by the account.
* The requirement grows based on asset and application usage.
*/
public minBalance: number | bigint;
/**
* amount of MicroAlgos of pending rewards in this account.
*/
public pendingRewards: number | bigint;
/**
* (ern) total rewards of MicroAlgos the account has received, including pending
* rewards.
*/
public rewards: number | bigint;
/**
* The round for which this information is relevant.
*/
public round: number | bigint;
/**
* (onl) delegation status of the account's MicroAlgos
* * Offline - indicates that the associated account is delegated.
* * Online - indicates that the associated account used as part of the delegation
* pool.
* * NotParticipating - indicates that the associated account is neither a
* delegator nor a delegate.
*/
public status: string;
/**
* The count of all applications that have been opted in, equivalent to the count
* of application local data (AppLocalState objects) stored in this account.
*/
public totalAppsOptedIn: number | bigint;
/**
* The count of all assets that have been opted in, equivalent to the count of
* AssetHolding objects held by this account.
*/
public totalAssetsOptedIn: number | bigint;
/**
* The count of all apps (AppParams objects) created by this account.
*/
public totalCreatedApps: number | bigint;
/**
* The count of all assets (AssetParams objects) created by this account.
*/
public totalCreatedAssets: number | bigint;
/**
* (appl) applications local data stored in this account.
* Note the raw object uses `map[int] -> AppLocalState` for this type.
*/
public appsLocalState?: ApplicationLocalState[];
/**
* (teap) the sum of all extra application program pages for this account.
*/
public appsTotalExtraPages?: number | bigint;
/**
* (tsch) stores the sum of all of the local schemas and global schemas in this
* account.
* Note: the raw account uses `StateSchema` for this type.
*/
public appsTotalSchema?: ApplicationStateSchema;
/**
* (asset) assets held by this account.
* Note the raw object uses `map[int] -> AssetHolding` for this type.
*/
public assets?: AssetHolding[];
/**
* (spend) the address against which signing should be checked. If empty, the
* address of the current account is used. This field can be updated in any
* transaction by setting the RekeyTo field.
*/
public authAddr?: string;
/**
* (appp) parameters of applications created by this account including app global
* data.
* Note: the raw account uses `map[int] -> AppParams` for this type.
*/
public createdApps?: Application[];
/**
* (apar) parameters of assets created by this account.
* Note: the raw account uses `map[int] -> Asset` for this type.
*/
public createdAssets?: Asset[];
/**
* AccountParticipation describes the parameters used by this account in consensus
* protocol.
*/
public participation?: AccountParticipation;
/**
* (ebase) used as part of the rewards computation. Only applicable to accounts
* which are participating.
*/
public rewardBase?: number | bigint;
/**
* Indicates what type of signature is used by this account, must be one of:
* * sig
* * msig
* * lsig
*/
public sigType?: string;
/**
* (tbxb) The total number of bytes used by this account's app's box keys and
* values.
*/
public totalBoxBytes?: number | bigint;
/**
* (tbx) The number of existing boxes created by this account's app.
*/
public totalBoxes?: number | bigint;
/**
* Creates a new `Account` object.
* @param address - the account public key
* @param amount - (algo) total number of MicroAlgos in the account
* @param amountWithoutPendingRewards - specifies the amount of MicroAlgos in the account, without the pending rewards.
* @param minBalance - MicroAlgo balance required by the account.
* The requirement grows based on asset and application usage.
* @param pendingRewards - amount of MicroAlgos of pending rewards in this account.
* @param rewards - (ern) total rewards of MicroAlgos the account has received, including pending
* rewards.
* @param round - The round for which this information is relevant.
* @param status - (onl) delegation status of the account's MicroAlgos
* * Offline - indicates that the associated account is delegated.
* * Online - indicates that the associated account used as part of the delegation
* pool.
* * NotParticipating - indicates that the associated account is neither a
* delegator nor a delegate.
* @param totalAppsOptedIn - The count of all applications that have been opted in, equivalent to the count
* of application local data (AppLocalState objects) stored in this account.
* @param totalAssetsOptedIn - The count of all assets that have been opted in, equivalent to the count of
* AssetHolding objects held by this account.
* @param totalCreatedApps - The count of all apps (AppParams objects) created by this account.
* @param totalCreatedAssets - The count of all assets (AssetParams objects) created by this account.
* @param appsLocalState - (appl) applications local data stored in this account.
* Note the raw object uses `map[int] -> AppLocalState` for this type.
* @param appsTotalExtraPages - (teap) the sum of all extra application program pages for this account.
* @param appsTotalSchema - (tsch) stores the sum of all of the local schemas and global schemas in this
* account.
* Note: the raw account uses `StateSchema` for this type.
* @param assets - (asset) assets held by this account.
* Note the raw object uses `map[int] -> AssetHolding` for this type.
* @param authAddr - (spend) the address against which signing should be checked. If empty, the
* address of the current account is used. This field can be updated in any
* transaction by setting the RekeyTo field.
* @param createdApps - (appp) parameters of applications created by this account including app global
* data.
* Note: the raw account uses `map[int] -> AppParams` for this type.
* @param createdAssets - (apar) parameters of assets created by this account.
* Note: the raw account uses `map[int] -> Asset` for this type.
* @param participation - AccountParticipation describes the parameters used by this account in consensus
* protocol.
* @param rewardBase - (ebase) used as part of the rewards computation. Only applicable to accounts
* which are participating.
* @param sigType - Indicates what type of signature is used by this account, must be one of:
* * sig
* * msig
* * lsig
* @param totalBoxBytes - (tbxb) The total number of bytes used by this account's app's box keys and
* values.
* @param totalBoxes - (tbx) The number of existing boxes created by this account's app.
*/
constructor({
address,
amount,
amountWithoutPendingRewards,
minBalance,
pendingRewards,
rewards,
round,
status,
totalAppsOptedIn,
totalAssetsOptedIn,
totalCreatedApps,
totalCreatedAssets,
appsLocalState,
appsTotalExtraPages,
appsTotalSchema,
assets,
authAddr,
createdApps,
createdAssets,
participation,
rewardBase,
sigType,
totalBoxBytes,
totalBoxes,
}: {
address: string;
amount: number | bigint;
amountWithoutPendingRewards: number | bigint;
minBalance: number | bigint;
pendingRewards: number | bigint;
rewards: number | bigint;
round: number | bigint;
status: string;
totalAppsOptedIn: number | bigint;
totalAssetsOptedIn: number | bigint;
totalCreatedApps: number | bigint;
totalCreatedAssets: number | bigint;
appsLocalState?: ApplicationLocalState[];
appsTotalExtraPages?: number | bigint;
appsTotalSchema?: ApplicationStateSchema;
assets?: AssetHolding[];
authAddr?: string;
createdApps?: Application[];
createdAssets?: Asset[];
participation?: AccountParticipation;
rewardBase?: number | bigint;
sigType?: string;
totalBoxBytes?: number | bigint;
totalBoxes?: number | bigint;
}) {
super();
this.address = address;
this.amount = amount;
this.amountWithoutPendingRewards = amountWithoutPendingRewards;
this.minBalance = minBalance;
this.pendingRewards = pendingRewards;
this.rewards = rewards;
this.round = round;
this.status = status;
this.totalAppsOptedIn = totalAppsOptedIn;
this.totalAssetsOptedIn = totalAssetsOptedIn;
this.totalCreatedApps = totalCreatedApps;
this.totalCreatedAssets = totalCreatedAssets;
this.appsLocalState = appsLocalState;
this.appsTotalExtraPages = appsTotalExtraPages;
this.appsTotalSchema = appsTotalSchema;
this.assets = assets;
this.authAddr = authAddr;
this.createdApps = createdApps;
this.createdAssets = createdAssets;
this.participation = participation;
this.rewardBase = rewardBase;
this.sigType = sigType;
this.totalBoxBytes = totalBoxBytes;
this.totalBoxes = totalBoxes;
this.attribute_map = {
address: 'address',
amount: 'amount',
amountWithoutPendingRewards: 'amount-without-pending-rewards',
minBalance: 'min-balance',
pendingRewards: 'pending-rewards',
rewards: 'rewards',
round: 'round',
status: 'status',
totalAppsOptedIn: 'total-apps-opted-in',
totalAssetsOptedIn: 'total-assets-opted-in',
totalCreatedApps: 'total-created-apps',
totalCreatedAssets: 'total-created-assets',
appsLocalState: 'apps-local-state',
appsTotalExtraPages: 'apps-total-extra-pages',
appsTotalSchema: 'apps-total-schema',
assets: 'assets',
authAddr: 'auth-addr',
createdApps: 'created-apps',
createdAssets: 'created-assets',
participation: 'participation',
rewardBase: 'reward-base',
sigType: 'sig-type',
totalBoxBytes: 'total-box-bytes',
totalBoxes: 'total-boxes',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(data: Record<string, any>): Account {
/* eslint-disable dot-notation */
if (typeof data['address'] === 'undefined')
throw new Error(`Response is missing required field 'address': ${data}`);
if (typeof data['amount'] === 'undefined')
throw new Error(`Response is missing required field 'amount': ${data}`);
if (typeof data['amount-without-pending-rewards'] === 'undefined')
throw new Error(
`Response is missing required field 'amount-without-pending-rewards': ${data}`
);
if (typeof data['min-balance'] === 'undefined')
throw new Error(
`Response is missing required field 'min-balance': ${data}`
);
if (typeof data['pending-rewards'] === 'undefined')
throw new Error(
`Response is missing required field 'pending-rewards': ${data}`
);
if (typeof data['rewards'] === 'undefined')
throw new Error(`Response is missing required field 'rewards': ${data}`);
if (typeof data['round'] === 'undefined')
throw new Error(`Response is missing required field 'round': ${data}`);
if (typeof data['status'] === 'undefined')
throw new Error(`Response is missing required field 'status': ${data}`);
if (typeof data['total-apps-opted-in'] === 'undefined')
throw new Error(
`Response is missing required field 'total-apps-opted-in': ${data}`
);
if (typeof data['total-assets-opted-in'] === 'undefined')
throw new Error(
`Response is missing required field 'total-assets-opted-in': ${data}`
);
if (typeof data['total-created-apps'] === 'undefined')
throw new Error(
`Response is missing required field 'total-created-apps': ${data}`
);
if (typeof data['total-created-assets'] === 'undefined')
throw new Error(
`Response is missing required field 'total-created-assets': ${data}`
);
return new Account({
address: data['address'],
amount: data['amount'],
amountWithoutPendingRewards: data['amount-without-pending-rewards'],
minBalance: data['min-balance'],
pendingRewards: data['pending-rewards'],
rewards: data['rewards'],
round: data['round'],
status: data['status'],
totalAppsOptedIn: data['total-apps-opted-in'],
totalAssetsOptedIn: data['total-assets-opted-in'],
totalCreatedApps: data['total-created-apps'],
totalCreatedAssets: data['total-created-assets'],
appsLocalState:
typeof data['apps-local-state'] !== 'undefined'
? data['apps-local-state'].map(
ApplicationLocalState.from_obj_for_encoding
)
: undefined,
appsTotalExtraPages: data['apps-total-extra-pages'],
appsTotalSchema:
typeof data['apps-total-schema'] !== 'undefined'
? ApplicationStateSchema.from_obj_for_encoding(
data['apps-total-schema']
)
: undefined,
assets:
typeof data['assets'] !== 'undefined'
? data['assets'].map(AssetHolding.from_obj_for_encoding)
: undefined,
authAddr: data['auth-addr'],
createdApps:
typeof data['created-apps'] !== 'undefined'
? data['created-apps'].map(Application.from_obj_for_encoding)
: undefined,
createdAssets:
typeof data['created-assets'] !== 'undefined'
? data['created-assets'].map(Asset.from_obj_for_encoding)
: undefined,
participation:
typeof data['participation'] !== 'undefined'
? AccountParticipation.from_obj_for_encoding(data['participation'])
: undefined,
rewardBase: data['reward-base'],
sigType: data['sig-type'],
totalBoxBytes: data['total-box-bytes'],
totalBoxes: data['total-boxes'],
});
/* eslint-enable dot-notation */
}
}
/**
* AccountApplicationResponse describes the account's application local state and
* global state (AppLocalState and AppParams, if either exists) for a specific
* application ID. Global state will only be returned if the provided address is
* the application's creator.
*/
export class AccountApplicationResponse extends BaseModel {
/**
* The round for which this information is relevant.
*/
public round: number | bigint;
/**
* (appl) the application local data stored in this account.
* The raw account uses `AppLocalState` for this type.
*/
public appLocalState?: ApplicationLocalState;
/**
* (appp) parameters of the application created by this account including app
* global data.
* The raw account uses `AppParams` for this type.
*/
public createdApp?: ApplicationParams;
/**
* Creates a new `AccountApplicationResponse` object.
* @param round - The round for which this information is relevant.
* @param appLocalState - (appl) the application local data stored in this account.
* The raw account uses `AppLocalState` for this type.
* @param createdApp - (appp) parameters of the application created by this account including app
* global data.
* The raw account uses `AppParams` for this type.
*/
constructor({
round,
appLocalState,
createdApp,
}: {
round: number | bigint;
appLocalState?: ApplicationLocalState;
createdApp?: ApplicationParams;
}) {
super();
this.round = round;
this.appLocalState = appLocalState;
this.createdApp = createdApp;
this.attribute_map = {
round: 'round',
appLocalState: 'app-local-state',
createdApp: 'created-app',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): AccountApplicationResponse {
/* eslint-disable dot-notation */
if (typeof data['round'] === 'undefined')
throw new Error(`Response is missing required field 'round': ${data}`);
return new AccountApplicationResponse({
round: data['round'],
appLocalState:
typeof data['app-local-state'] !== 'undefined'
? ApplicationLocalState.from_obj_for_encoding(data['app-local-state'])
: undefined,
createdApp:
typeof data['created-app'] !== 'undefined'
? ApplicationParams.from_obj_for_encoding(data['created-app'])
: undefined,
});
/* eslint-enable dot-notation */
}
}
/**
* AccountAssetResponse describes the account's asset holding and asset parameters
* (if either exist) for a specific asset ID. Asset parameters will only be
* returned if the provided address is the asset's creator.
*/
export class AccountAssetResponse extends BaseModel {
/**
* The round for which this information is relevant.
*/
public round: number | bigint;
/**
* (asset) Details about the asset held by this account.
* The raw account uses `AssetHolding` for this type.
*/
public assetHolding?: AssetHolding;
/**
* (apar) parameters of the asset created by this account.
* The raw account uses `AssetParams` for this type.
*/
public createdAsset?: AssetParams;
/**
* Creates a new `AccountAssetResponse` object.
* @param round - The round for which this information is relevant.
* @param assetHolding - (asset) Details about the asset held by this account.
* The raw account uses `AssetHolding` for this type.
* @param createdAsset - (apar) parameters of the asset created by this account.
* The raw account uses `AssetParams` for this type.
*/
constructor({
round,
assetHolding,
createdAsset,
}: {
round: number | bigint;
assetHolding?: AssetHolding;
createdAsset?: AssetParams;
}) {
super();
this.round = round;
this.assetHolding = assetHolding;
this.createdAsset = createdAsset;
this.attribute_map = {
round: 'round',
assetHolding: 'asset-holding',
createdAsset: 'created-asset',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): AccountAssetResponse {
/* eslint-disable dot-notation */
if (typeof data['round'] === 'undefined')
throw new Error(`Response is missing required field 'round': ${data}`);
return new AccountAssetResponse({
round: data['round'],
assetHolding:
typeof data['asset-holding'] !== 'undefined'
? AssetHolding.from_obj_for_encoding(data['asset-holding'])
: undefined,
createdAsset:
typeof data['created-asset'] !== 'undefined'
? AssetParams.from_obj_for_encoding(data['created-asset'])
: undefined,
});
/* eslint-enable dot-notation */
}
}
/**
* AccountParticipation describes the parameters used by this account in consensus
* protocol.
*/
export class AccountParticipation extends BaseModel {
/**
* (sel) Selection public key (if any) currently registered for this round.
*/
public selectionParticipationKey: Uint8Array;
/**
* (voteFst) First round for which this participation is valid.
*/
public voteFirstValid: number | bigint;
/**
* (voteKD) Number of subkeys in each batch of participation keys.
*/
public voteKeyDilution: number | bigint;
/**
* (voteLst) Last round for which this participation is valid.
*/
public voteLastValid: number | bigint;
/**
* (vote) root participation public key (if any) currently registered for this
* round.
*/
public voteParticipationKey: Uint8Array;
/**
* (stprf) Root of the state proof key (if any)
*/
public stateProofKey?: Uint8Array;
/**
* Creates a new `AccountParticipation` object.
* @param selectionParticipationKey - (sel) Selection public key (if any) currently registered for this round.
* @param voteFirstValid - (voteFst) First round for which this participation is valid.
* @param voteKeyDilution - (voteKD) Number of subkeys in each batch of participation keys.
* @param voteLastValid - (voteLst) Last round for which this participation is valid.
* @param voteParticipationKey - (vote) root participation public key (if any) currently registered for this
* round.
* @param stateProofKey - (stprf) Root of the state proof key (if any)
*/
constructor({
selectionParticipationKey,
voteFirstValid,
voteKeyDilution,
voteLastValid,
voteParticipationKey,
stateProofKey,
}: {
selectionParticipationKey: string | Uint8Array;
voteFirstValid: number | bigint;
voteKeyDilution: number | bigint;
voteLastValid: number | bigint;
voteParticipationKey: string | Uint8Array;
stateProofKey?: string | Uint8Array;
}) {
super();
this.selectionParticipationKey =
typeof selectionParticipationKey === 'string'
? new Uint8Array(Buffer.from(selectionParticipationKey, 'base64'))
: selectionParticipationKey;
this.voteFirstValid = voteFirstValid;
this.voteKeyDilution = voteKeyDilution;
this.voteLastValid = voteLastValid;
this.voteParticipationKey =
typeof voteParticipationKey === 'string'
? new Uint8Array(Buffer.from(voteParticipationKey, 'base64'))
: voteParticipationKey;
this.stateProofKey =
typeof stateProofKey === 'string'
? new Uint8Array(Buffer.from(stateProofKey, 'base64'))
: stateProofKey;
this.attribute_map = {
selectionParticipationKey: 'selection-participation-key',
voteFirstValid: 'vote-first-valid',
voteKeyDilution: 'vote-key-dilution',
voteLastValid: 'vote-last-valid',
voteParticipationKey: 'vote-participation-key',
stateProofKey: 'state-proof-key',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): AccountParticipation {
/* eslint-disable dot-notation */
if (typeof data['selection-participation-key'] === 'undefined')
throw new Error(
`Response is missing required field 'selection-participation-key': ${data}`
);
if (typeof data['vote-first-valid'] === 'undefined')
throw new Error(
`Response is missing required field 'vote-first-valid': ${data}`
);
if (typeof data['vote-key-dilution'] === 'undefined')
throw new Error(
`Response is missing required field 'vote-key-dilution': ${data}`
);
if (typeof data['vote-last-valid'] === 'undefined')
throw new Error(
`Response is missing required field 'vote-last-valid': ${data}`
);
if (typeof data['vote-participation-key'] === 'undefined')
throw new Error(
`Response is missing required field 'vote-participation-key': ${data}`
);
return new AccountParticipation({
selectionParticipationKey: data['selection-participation-key'],
voteFirstValid: data['vote-first-valid'],
voteKeyDilution: data['vote-key-dilution'],
voteLastValid: data['vote-last-valid'],
voteParticipationKey: data['vote-participation-key'],
stateProofKey: data['state-proof-key'],
});
/* eslint-enable dot-notation */
}
}
/**
* Application state delta.
*/
export class AccountStateDelta extends BaseModel {
public address: string;
/**
* Application state delta.
*/
public delta: EvalDeltaKeyValue[];
/**
* Creates a new `AccountStateDelta` object.
* @param address -
* @param delta - Application state delta.
*/
constructor({
address,
delta,
}: {
address: string;
delta: EvalDeltaKeyValue[];
}) {
super();
this.address = address;
this.delta = delta;
this.attribute_map = {
address: 'address',
delta: 'delta',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(data: Record<string, any>): AccountStateDelta {
/* eslint-disable dot-notation */
if (typeof data['address'] === 'undefined')
throw new Error(`Response is missing required field 'address': ${data}`);
if (!Array.isArray(data['delta']))
throw new Error(
`Response is missing required array field 'delta': ${data}`
);
return new AccountStateDelta({
address: data['address'],
delta: data['delta'].map(EvalDeltaKeyValue.from_obj_for_encoding),
});
/* eslint-enable dot-notation */
}
}
/**
* Application index and its parameters
*/
export class Application extends BaseModel {
/**
* (appidx) application index.
*/
public id: number | bigint;
/**
* (appparams) application parameters.
*/
public params: ApplicationParams;
/**
* Creates a new `Application` object.
* @param id - (appidx) application index.
* @param params - (appparams) application parameters.
*/
constructor({
id,
params,
}: {
id: number | bigint;
params: ApplicationParams;
}) {
super();
this.id = id;
this.params = params;
this.attribute_map = {
id: 'id',
params: 'params',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(data: Record<string, any>): Application {
/* eslint-disable dot-notation */
if (typeof data['id'] === 'undefined')
throw new Error(`Response is missing required field 'id': ${data}`);
if (typeof data['params'] === 'undefined')
throw new Error(`Response is missing required field 'params': ${data}`);
return new Application({
id: data['id'],
params: ApplicationParams.from_obj_for_encoding(data['params']),
});
/* eslint-enable dot-notation */
}
}
/**
* An application's initial global/local/box states that were accessed during
* simulation.
*/
export class ApplicationInitialStates extends BaseModel {
/**
* Application index.
*/
public id: number | bigint;
/**
* An application's global/local/box state.
*/
public appBoxes?: ApplicationKVStorage;
/**
* An application's global/local/box state.
*/
public appGlobals?: ApplicationKVStorage;
/**
* An application's initial local states tied to different accounts.
*/
public appLocals?: ApplicationKVStorage[];
/**
* Creates a new `ApplicationInitialStates` object.
* @param id - Application index.
* @param appBoxes - An application's global/local/box state.
* @param appGlobals - An application's global/local/box state.
* @param appLocals - An application's initial local states tied to different accounts.
*/
constructor({
id,
appBoxes,
appGlobals,
appLocals,
}: {
id: number | bigint;
appBoxes?: ApplicationKVStorage;
appGlobals?: ApplicationKVStorage;
appLocals?: ApplicationKVStorage[];
}) {
super();
this.id = id;
this.appBoxes = appBoxes;
this.appGlobals = appGlobals;
this.appLocals = appLocals;
this.attribute_map = {
id: 'id',
appBoxes: 'app-boxes',
appGlobals: 'app-globals',
appLocals: 'app-locals',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): ApplicationInitialStates {
/* eslint-disable dot-notation */
if (typeof data['id'] === 'undefined')
throw new Error(`Response is missing required field 'id': ${data}`);
return new ApplicationInitialStates({
id: data['id'],
appBoxes:
typeof data['app-boxes'] !== 'undefined'
? ApplicationKVStorage.from_obj_for_encoding(data['app-boxes'])
: undefined,
appGlobals:
typeof data['app-globals'] !== 'undefined'
? ApplicationKVStorage.from_obj_for_encoding(data['app-globals'])
: undefined,
appLocals:
typeof data['app-locals'] !== 'undefined'
? data['app-locals'].map(ApplicationKVStorage.from_obj_for_encoding)
: undefined,
});
/* eslint-enable dot-notation */
}
}
/**
* An application's global/local/box state.
*/
export class ApplicationKVStorage extends BaseModel {
/**
* Key-Value pairs representing application states.
*/
public kvs: AvmKeyValue[];
/**
* The address of the account associated with the local state.
*/
public account?: string;
/**
* Creates a new `ApplicationKVStorage` object.
* @param kvs - Key-Value pairs representing application states.
* @param account - The address of the account associated with the local state.
*/
constructor({ kvs, account }: { kvs: AvmKeyValue[]; account?: string }) {
super();
this.kvs = kvs;
this.account = account;
this.attribute_map = {
kvs: 'kvs',
account: 'account',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): ApplicationKVStorage {
/* eslint-disable dot-notation */
if (!Array.isArray(data['kvs']))
throw new Error(
`Response is missing required array field 'kvs': ${data}`
);
return new ApplicationKVStorage({
kvs: data['kvs'].map(AvmKeyValue.from_obj_for_encoding),
account: data['account'],
});
/* eslint-enable dot-notation */
}
}
/**
* References an account's local state for an application.
*/
export class ApplicationLocalReference extends BaseModel {
/**
* Address of the account with the local state.
*/
public account: string;
/**
* Application ID of the local state application.
*/
public app: number | bigint;
/**
* Creates a new `ApplicationLocalReference` object.
* @param account - Address of the account with the local state.
* @param app - Application ID of the local state application.
*/
constructor({ account, app }: { account: string; app: number | bigint }) {
super();
this.account = account;
this.app = app;
this.attribute_map = {
account: 'account',
app: 'app',
};
}
// eslint-disable-next-line camelcase
static from_obj_for_encoding(
data: Record<string, any>
): ApplicationLocalReference {
/* eslint-disable dot-notation */
if (typeof data['account'] === 'undefined')
throw new Error(`Response is missing required field 'account': ${data}`);
if (typeof data['app'] === 'undefined')
throw new Error(`Response is missing required field 'app': ${data}`);
return new ApplicationLocalReference({
account: data['account'],
app: data['app'],
});
/* eslint-enable dot-notation */
}
}
/**
* Stores local state associated with an application.
*/
export class ApplicationLocalState extends BaseModel {
/**
* The application which this local state is for.
*/
public id: number | bigint;
/**
* (hsch) schema.
*/
public schema: ApplicationStateSchema;
/**
* (tkv) storage.
*/
public keyValue?: TealKeyValue[];
/**
* Creates a new `ApplicationLocalState` object.
* @param id - The application which this local state is for.
* @param schema - (hsch) schema.
* @param keyValue - (tkv) storage.
*/
constructor({
id,
schema,
keyValue,
}: {
id: number | bigint;
schema: ApplicationStateSchema;
keyValue?: TealKeyValue[];
}) {
super();
this.id = id;
this.schema = schema;