algosdk 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/appAccess.js +14 -6
  5. package/dist/cjs/appAccess.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/accountApplicationsInformation.js +38 -0
  7. package/dist/cjs/client/v2/algod/accountApplicationsInformation.js.map +1 -0
  8. package/dist/cjs/client/v2/algod/accountAssetsInformation.js +31 -0
  9. package/dist/cjs/client/v2/algod/accountAssetsInformation.js.map +1 -0
  10. package/dist/cjs/client/v2/algod/algod.js +23 -1
  11. package/dist/cjs/client/v2/algod/algod.js.map +1 -1
  12. package/dist/cjs/client/v2/algod/getApplicationBoxes.js +116 -5
  13. package/dist/cjs/client/v2/algod/getApplicationBoxes.js.map +1 -1
  14. package/dist/cjs/client/v2/algod/models/types.js +243 -20
  15. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  16. package/dist/cjs/dryrun.js.map +1 -1
  17. package/dist/cjs/transaction.js +1 -0
  18. package/dist/cjs/transaction.js.map +1 -1
  19. package/dist/esm/appAccess.js +14 -6
  20. package/dist/esm/appAccess.js.map +1 -1
  21. package/dist/esm/client/v2/algod/accountApplicationsInformation.js +32 -0
  22. package/dist/esm/client/v2/algod/accountApplicationsInformation.js.map +1 -0
  23. package/dist/esm/client/v2/algod/accountAssetsInformation.js +25 -0
  24. package/dist/esm/client/v2/algod/accountAssetsInformation.js.map +1 -0
  25. package/dist/esm/client/v2/algod/algod.js +23 -1
  26. package/dist/esm/client/v2/algod/algod.js.map +1 -1
  27. package/dist/esm/client/v2/algod/getApplicationBoxes.js +116 -5
  28. package/dist/esm/client/v2/algod/getApplicationBoxes.js.map +1 -1
  29. package/dist/esm/client/v2/algod/models/types.js +239 -18
  30. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  31. package/dist/esm/dryrun.js.map +1 -1
  32. package/dist/esm/transaction.js +1 -0
  33. package/dist/esm/transaction.js.map +1 -1
  34. package/dist/types/client/v2/algod/accountApplicationsInformation.d.ts +16 -0
  35. package/dist/types/client/v2/algod/accountAssetsInformation.d.ts +12 -0
  36. package/dist/types/client/v2/algod/algod.d.ts +19 -1
  37. package/dist/types/client/v2/algod/getApplicationBoxes.d.ts +100 -5
  38. package/dist/types/client/v2/algod/models/types.d.ts +146 -15
  39. package/package.json +1 -1
  40. package/src/appAccess.ts +17 -6
  41. package/src/client/v2/algod/accountApplicationsInformation.ts +46 -0
  42. package/src/client/v2/algod/accountAssetsInformation.ts +33 -0
  43. package/src/client/v2/algod/algod.ts +25 -1
  44. package/src/client/v2/algod/getApplicationBoxes.ts +123 -5
  45. package/src/client/v2/algod/models/types.ts +409 -32
  46. package/src/dryrun.ts +2 -2
  47. package/src/transaction.ts +1 -0
@@ -338,6 +338,96 @@ export class Account {
338
338
  });
339
339
  }
340
340
  }
341
+ /**
342
+ * AccountApplicationResource describes the account's application resource (local
343
+ * state and params if the account is the creator) for a specific application ID.
344
+ */
345
+ export class AccountApplicationResource {
346
+ static get encodingSchema() {
347
+ if (!this.encodingSchemaValue) {
348
+ this.encodingSchemaValue = new NamedMapSchema([]);
349
+ this.encodingSchemaValue.pushEntries({ key: 'id', valueSchema: new Uint64Schema(), omitEmpty: true }, {
350
+ key: 'app-local-state',
351
+ valueSchema: new OptionalSchema(ApplicationLocalState.encodingSchema),
352
+ omitEmpty: true,
353
+ }, {
354
+ key: 'created-at-round',
355
+ valueSchema: new OptionalSchema(new Uint64Schema()),
356
+ omitEmpty: true,
357
+ }, {
358
+ key: 'deleted',
359
+ valueSchema: new OptionalSchema(new BooleanSchema()),
360
+ omitEmpty: true,
361
+ }, {
362
+ key: 'params',
363
+ valueSchema: new OptionalSchema(ApplicationParams.encodingSchema),
364
+ omitEmpty: true,
365
+ });
366
+ }
367
+ return this.encodingSchemaValue;
368
+ }
369
+ /**
370
+ * Creates a new `AccountApplicationResource` object.
371
+ * @param id - The application ID.
372
+ * @param appLocalState - (appl) the application local data stored in this account.
373
+ * The raw account uses `AppLocalState` for this type.
374
+ * @param createdAtRound - Round when the account opted into or created the application.
375
+ * @param deleted - Whether the application has been deleted.
376
+ * @param params - (appp) parameters of the application created by this account including app
377
+ * global data.
378
+ * The raw account uses `AppParams` for this type.
379
+ * Only present if the account is the creator and `include=params` is specified.
380
+ */
381
+ constructor({ id, appLocalState, createdAtRound, deleted, params, }) {
382
+ this.id = ensureSafeInteger(id);
383
+ this.appLocalState = appLocalState;
384
+ this.createdAtRound =
385
+ typeof createdAtRound === 'undefined'
386
+ ? undefined
387
+ : ensureSafeInteger(createdAtRound);
388
+ this.deleted = deleted;
389
+ this.params = params;
390
+ }
391
+ // eslint-disable-next-line class-methods-use-this
392
+ getEncodingSchema() {
393
+ return AccountApplicationResource.encodingSchema;
394
+ }
395
+ toEncodingData() {
396
+ return new Map([
397
+ ['id', this.id],
398
+ [
399
+ 'app-local-state',
400
+ typeof this.appLocalState !== 'undefined'
401
+ ? this.appLocalState.toEncodingData()
402
+ : undefined,
403
+ ],
404
+ ['created-at-round', this.createdAtRound],
405
+ ['deleted', this.deleted],
406
+ [
407
+ 'params',
408
+ typeof this.params !== 'undefined'
409
+ ? this.params.toEncodingData()
410
+ : undefined,
411
+ ],
412
+ ]);
413
+ }
414
+ static fromEncodingData(data) {
415
+ if (!(data instanceof Map)) {
416
+ throw new Error(`Invalid decoded AccountApplicationResource: ${data}`);
417
+ }
418
+ return new AccountApplicationResource({
419
+ id: data.get('id'),
420
+ appLocalState: typeof data.get('app-local-state') !== 'undefined'
421
+ ? ApplicationLocalState.fromEncodingData(data.get('app-local-state'))
422
+ : undefined,
423
+ createdAtRound: data.get('created-at-round'),
424
+ deleted: data.get('deleted'),
425
+ params: typeof data.get('params') !== 'undefined'
426
+ ? ApplicationParams.fromEncodingData(data.get('params'))
427
+ : undefined,
428
+ });
429
+ }
430
+ }
341
431
  /**
342
432
  * AccountApplicationResponse describes the account's application local state and
343
433
  * global state (AppLocalState and AppParams, if either exists) for a specific
@@ -410,6 +500,70 @@ export class AccountApplicationResponse {
410
500
  });
411
501
  }
412
502
  }
503
+ /**
504
+ * AccountApplicationsInformationResponse contains a list of application resources
505
+ * for an account.
506
+ */
507
+ export class AccountApplicationsInformationResponse {
508
+ static get encodingSchema() {
509
+ if (!this.encodingSchemaValue) {
510
+ this.encodingSchemaValue = new NamedMapSchema([]);
511
+ this.encodingSchemaValue.pushEntries({ key: 'round', valueSchema: new Uint64Schema(), omitEmpty: true }, {
512
+ key: 'application-resources',
513
+ valueSchema: new OptionalSchema(new ArraySchema(AccountApplicationResource.encodingSchema)),
514
+ omitEmpty: true,
515
+ }, {
516
+ key: 'next-token',
517
+ valueSchema: new OptionalSchema(new StringSchema()),
518
+ omitEmpty: true,
519
+ });
520
+ }
521
+ return this.encodingSchemaValue;
522
+ }
523
+ /**
524
+ * Creates a new `AccountApplicationsInformationResponse` object.
525
+ * @param round - The round for which this information is relevant.
526
+ * @param applicationResources -
527
+ * @param nextToken - Used for pagination, when making another request provide this token with the
528
+ * next parameter. The next token is the next application ID to use as the
529
+ * pagination cursor.
530
+ */
531
+ constructor({ round, applicationResources, nextToken, }) {
532
+ this.round = ensureSafeInteger(round);
533
+ this.applicationResources = applicationResources;
534
+ this.nextToken = nextToken;
535
+ }
536
+ // eslint-disable-next-line class-methods-use-this
537
+ getEncodingSchema() {
538
+ return AccountApplicationsInformationResponse.encodingSchema;
539
+ }
540
+ toEncodingData() {
541
+ return new Map([
542
+ ['round', this.round],
543
+ [
544
+ 'application-resources',
545
+ typeof this.applicationResources !== 'undefined'
546
+ ? this.applicationResources.map((v) => v.toEncodingData())
547
+ : undefined,
548
+ ],
549
+ ['next-token', this.nextToken],
550
+ ]);
551
+ }
552
+ static fromEncodingData(data) {
553
+ if (!(data instanceof Map)) {
554
+ throw new Error(`Invalid decoded AccountApplicationsInformationResponse: ${data}`);
555
+ }
556
+ return new AccountApplicationsInformationResponse({
557
+ round: data.get('round'),
558
+ applicationResources: typeof data.get('application-resources') !== 'undefined'
559
+ ? data
560
+ .get('application-resources')
561
+ .map((v) => AccountApplicationResource.fromEncodingData(v))
562
+ : undefined,
563
+ nextToken: data.get('next-token'),
564
+ });
565
+ }
566
+ }
413
567
  /**
414
568
  * AccountAssetHolding describes the account's asset holding and asset parameters
415
569
  * (if either exist) for a specific asset ID.
@@ -797,7 +951,7 @@ export class Application {
797
951
  this.encodingSchemaValue = new NamedMapSchema([]);
798
952
  this.encodingSchemaValue.pushEntries({ key: 'id', valueSchema: new Uint64Schema(), omitEmpty: true }, {
799
953
  key: 'params',
800
- valueSchema: ApplicationParams.encodingSchema,
954
+ valueSchema: new OptionalSchema(ApplicationParams.encodingSchema),
801
955
  omitEmpty: true,
802
956
  });
803
957
  }
@@ -819,7 +973,12 @@ export class Application {
819
973
  toEncodingData() {
820
974
  return new Map([
821
975
  ['id', this.id],
822
- ['params', this.params.toEncodingData()],
976
+ [
977
+ 'params',
978
+ typeof this.params !== 'undefined'
979
+ ? this.params.toEncodingData()
980
+ : undefined,
981
+ ],
823
982
  ]);
824
983
  }
825
984
  static fromEncodingData(data) {
@@ -828,7 +987,9 @@ export class Application {
828
987
  }
829
988
  return new Application({
830
989
  id: data.get('id'),
831
- params: ApplicationParams.fromEncodingData(data.get('params') ?? new Map()),
990
+ params: typeof data.get('params') !== 'undefined'
991
+ ? ApplicationParams.fromEncodingData(data.get('params'))
992
+ : undefined,
832
993
  });
833
994
  }
834
995
  }
@@ -1103,6 +1264,10 @@ export class ApplicationParams {
1103
1264
  key: 'local-state-schema',
1104
1265
  valueSchema: new OptionalSchema(ApplicationStateSchema.encodingSchema),
1105
1266
  omitEmpty: true,
1267
+ }, {
1268
+ key: 'size-sponsor',
1269
+ valueSchema: new OptionalSchema(new StringSchema()),
1270
+ omitEmpty: true,
1106
1271
  }, {
1107
1272
  key: 'version',
1108
1273
  valueSchema: new OptionalSchema(new Uint64Schema()),
@@ -1121,9 +1286,10 @@ export class ApplicationParams {
1121
1286
  * @param globalState - (gs) global state
1122
1287
  * @param globalStateSchema - (gsch) global schema
1123
1288
  * @param localStateSchema - (lsch) local schema
1289
+ * @param sizeSponsor - (ss) the account responsible for extra pages and global state MBR
1124
1290
  * @param version - (v) the number of updates to the application programs
1125
1291
  */
1126
- constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, version, }) {
1292
+ constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, sizeSponsor, version, }) {
1127
1293
  this.approvalProgram =
1128
1294
  typeof approvalProgram === 'string'
1129
1295
  ? base64ToBytes(approvalProgram)
@@ -1141,6 +1307,10 @@ export class ApplicationParams {
1141
1307
  this.globalState = globalState;
1142
1308
  this.globalStateSchema = globalStateSchema;
1143
1309
  this.localStateSchema = localStateSchema;
1310
+ this.sizeSponsor =
1311
+ typeof sizeSponsor === 'string'
1312
+ ? Address.fromString(sizeSponsor)
1313
+ : sizeSponsor;
1144
1314
  this.version =
1145
1315
  typeof version === 'undefined' ? undefined : ensureSafeInteger(version);
1146
1316
  }
@@ -1172,6 +1342,12 @@ export class ApplicationParams {
1172
1342
  ? this.localStateSchema.toEncodingData()
1173
1343
  : undefined,
1174
1344
  ],
1345
+ [
1346
+ 'size-sponsor',
1347
+ typeof this.sizeSponsor !== 'undefined'
1348
+ ? this.sizeSponsor.toString()
1349
+ : undefined,
1350
+ ],
1175
1351
  ['version', this.version],
1176
1352
  ]);
1177
1353
  }
@@ -1195,6 +1371,7 @@ export class ApplicationParams {
1195
1371
  localStateSchema: typeof data.get('local-state-schema') !== 'undefined'
1196
1372
  ? ApplicationStateSchema.fromEncodingData(data.get('local-state-schema'))
1197
1373
  : undefined,
1374
+ sizeSponsor: data.get('size-sponsor'),
1198
1375
  version: data.get('version'),
1199
1376
  });
1200
1377
  }
@@ -1331,7 +1508,7 @@ export class Asset {
1331
1508
  this.encodingSchemaValue = new NamedMapSchema([]);
1332
1509
  this.encodingSchemaValue.pushEntries({ key: 'index', valueSchema: new Uint64Schema(), omitEmpty: true }, {
1333
1510
  key: 'params',
1334
- valueSchema: AssetParams.encodingSchema,
1511
+ valueSchema: new OptionalSchema(AssetParams.encodingSchema),
1335
1512
  omitEmpty: true,
1336
1513
  });
1337
1514
  }
@@ -1356,7 +1533,12 @@ export class Asset {
1356
1533
  toEncodingData() {
1357
1534
  return new Map([
1358
1535
  ['index', this.index],
1359
- ['params', this.params.toEncodingData()],
1536
+ [
1537
+ 'params',
1538
+ typeof this.params !== 'undefined'
1539
+ ? this.params.toEncodingData()
1540
+ : undefined,
1541
+ ],
1360
1542
  ]);
1361
1543
  }
1362
1544
  static fromEncodingData(data) {
@@ -1365,7 +1547,9 @@ export class Asset {
1365
1547
  }
1366
1548
  return new Asset({
1367
1549
  index: data.get('index'),
1368
- params: AssetParams.fromEncodingData(data.get('params') ?? new Map()),
1550
+ params: typeof data.get('params') !== 'undefined'
1551
+ ? AssetParams.fromEncodingData(data.get('params'))
1552
+ : undefined,
1369
1553
  });
1370
1554
  }
1371
1555
  }
@@ -1934,9 +2118,9 @@ export class BoxDescriptor {
1934
2118
  static get encodingSchema() {
1935
2119
  if (!this.encodingSchemaValue) {
1936
2120
  this.encodingSchemaValue = new NamedMapSchema([]);
1937
- this.encodingSchemaValue.pushEntries({
1938
- key: 'name',
1939
- valueSchema: new ByteArraySchema(),
2121
+ this.encodingSchemaValue.pushEntries({ key: 'name', valueSchema: new ByteArraySchema(), omitEmpty: true }, {
2122
+ key: 'value',
2123
+ valueSchema: new OptionalSchema(new ByteArraySchema()),
1940
2124
  omitEmpty: true,
1941
2125
  });
1942
2126
  }
@@ -1945,16 +2129,22 @@ export class BoxDescriptor {
1945
2129
  /**
1946
2130
  * Creates a new `BoxDescriptor` object.
1947
2131
  * @param name - Base64 encoded box name
2132
+ * @param value - Base64 encoded box value. Present only when the `values` query parameter is set
2133
+ * to true.
1948
2134
  */
1949
- constructor({ name }) {
2135
+ constructor({ name, value, }) {
1950
2136
  this.name = typeof name === 'string' ? base64ToBytes(name) : name;
2137
+ this.value = typeof value === 'string' ? base64ToBytes(value) : value;
1951
2138
  }
1952
2139
  // eslint-disable-next-line class-methods-use-this
1953
2140
  getEncodingSchema() {
1954
2141
  return BoxDescriptor.encodingSchema;
1955
2142
  }
1956
2143
  toEncodingData() {
1957
- return new Map([['name', this.name]]);
2144
+ return new Map([
2145
+ ['name', this.name],
2146
+ ['value', this.value],
2147
+ ]);
1958
2148
  }
1959
2149
  static fromEncodingData(data) {
1960
2150
  if (!(data instanceof Map)) {
@@ -1962,6 +2152,7 @@ export class BoxDescriptor {
1962
2152
  }
1963
2153
  return new BoxDescriptor({
1964
2154
  name: data.get('name'),
2155
+ value: data.get('value'),
1965
2156
  });
1966
2157
  }
1967
2158
  }
@@ -2006,7 +2197,7 @@ export class BoxReference {
2006
2197
  }
2007
2198
  }
2008
2199
  /**
2009
- * Box names of an application
2200
+ * Boxes of an application
2010
2201
  */
2011
2202
  export class BoxesResponse {
2012
2203
  static get encodingSchema() {
@@ -2016,6 +2207,14 @@ export class BoxesResponse {
2016
2207
  key: 'boxes',
2017
2208
  valueSchema: new ArraySchema(BoxDescriptor.encodingSchema),
2018
2209
  omitEmpty: true,
2210
+ }, {
2211
+ key: 'next-token',
2212
+ valueSchema: new OptionalSchema(new StringSchema()),
2213
+ omitEmpty: true,
2214
+ }, {
2215
+ key: 'round',
2216
+ valueSchema: new OptionalSchema(new Uint64Schema()),
2217
+ omitEmpty: true,
2019
2218
  });
2020
2219
  }
2021
2220
  return this.encodingSchemaValue;
@@ -2023,9 +2222,16 @@ export class BoxesResponse {
2023
2222
  /**
2024
2223
  * Creates a new `BoxesResponse` object.
2025
2224
  * @param boxes -
2225
+ * @param nextToken - Used for pagination, when making another request provide this token with the
2226
+ * next parameter. The next token is the box name to use as the pagination cursor,
2227
+ * encoded in the goal app call arg form.
2228
+ * @param round - The round for which this information is relevant.
2026
2229
  */
2027
- constructor({ boxes }) {
2230
+ constructor({ boxes, nextToken, round, }) {
2028
2231
  this.boxes = boxes;
2232
+ this.nextToken = nextToken;
2233
+ this.round =
2234
+ typeof round === 'undefined' ? undefined : ensureSafeInteger(round);
2029
2235
  }
2030
2236
  // eslint-disable-next-line class-methods-use-this
2031
2237
  getEncodingSchema() {
@@ -2034,6 +2240,8 @@ export class BoxesResponse {
2034
2240
  toEncodingData() {
2035
2241
  return new Map([
2036
2242
  ['boxes', this.boxes.map((v) => v.toEncodingData())],
2243
+ ['next-token', this.nextToken],
2244
+ ['round', this.round],
2037
2245
  ]);
2038
2246
  }
2039
2247
  static fromEncodingData(data) {
@@ -2042,6 +2250,8 @@ export class BoxesResponse {
2042
2250
  }
2043
2251
  return new BoxesResponse({
2044
2252
  boxes: (data.get('boxes') ?? []).map((v) => BoxDescriptor.fromEncodingData(v)),
2253
+ nextToken: data.get('next-token'),
2254
+ round: data.get('round'),
2045
2255
  });
2046
2256
  }
2047
2257
  }
@@ -4909,6 +5119,10 @@ export class SupplyResponse {
4909
5119
  key: 'online-money',
4910
5120
  valueSchema: new Uint64Schema(),
4911
5121
  omitEmpty: true,
5122
+ }, {
5123
+ key: 'online-stake',
5124
+ valueSchema: new Uint64Schema(),
5125
+ omitEmpty: true,
4912
5126
  }, { key: 'total-money', valueSchema: new Uint64Schema(), omitEmpty: true });
4913
5127
  }
4914
5128
  return this.encodingSchemaValue;
@@ -4916,12 +5130,17 @@ export class SupplyResponse {
4916
5130
  /**
4917
5131
  * Creates a new `SupplyResponse` object.
4918
5132
  * @param currentRound - Round
4919
- * @param onlineMoney - OnlineMoney
5133
+ * @param onlineMoney - Total stake held by accounts with status Online at current_round, including
5134
+ * those whose participation keys have expired but have not yet been marked
5135
+ * offline.
5136
+ * @param onlineStake - Online stake used by agreement to vote for current_round, excluding accounts
5137
+ * whose participation keys have expired.
4920
5138
  * @param totalMoney - TotalMoney
4921
5139
  */
4922
- constructor({ currentRound, onlineMoney, totalMoney, }) {
5140
+ constructor({ currentRound, onlineMoney, onlineStake, totalMoney, }) {
4923
5141
  this.currentRound = ensureBigInt(currentRound);
4924
5142
  this.onlineMoney = ensureBigInt(onlineMoney);
5143
+ this.onlineStake = ensureBigInt(onlineStake);
4925
5144
  this.totalMoney = ensureBigInt(totalMoney);
4926
5145
  }
4927
5146
  // eslint-disable-next-line class-methods-use-this
@@ -4932,6 +5151,7 @@ export class SupplyResponse {
4932
5151
  return new Map([
4933
5152
  ['current_round', this.currentRound],
4934
5153
  ['online-money', this.onlineMoney],
5154
+ ['online-stake', this.onlineStake],
4935
5155
  ['total-money', this.totalMoney],
4936
5156
  ]);
4937
5157
  }
@@ -4942,6 +5162,7 @@ export class SupplyResponse {
4942
5162
  return new SupplyResponse({
4943
5163
  currentRound: data.get('current_round'),
4944
5164
  onlineMoney: data.get('online-money'),
5165
+ onlineStake: data.get('online-stake'),
4945
5166
  totalMoney: data.get('total-money'),
4946
5167
  });
4947
5168
  }
@@ -5102,8 +5323,8 @@ export class TransactionParametersResponse {
5102
5323
  * @param genesisHash - GenesisHash is the hash of the genesis block.
5103
5324
  * @param genesisId - GenesisID is an ID listed in the genesis block.
5104
5325
  * @param lastRound - LastRound indicates the last round seen
5105
- * @param minFee - The minimum transaction fee (not per byte) required for the
5106
- * txn to validate for the current network protocol.
5326
+ * @param minFee - The minimum transaction fee (not per byte) required for the txn to validate for
5327
+ * the current network protocol.
5107
5328
  */
5108
5329
  constructor({ consensusVersion, fee, genesisHash, genesisId, lastRound, minFee, }) {
5109
5330
  this.consensusVersion = consensusVersion;