algosdk 3.3.1 → 3.4.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 (33) hide show
  1. package/README.md +5 -5
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/client/v2/algod/getTransactionProof.js +1 -1
  5. package/dist/cjs/client/v2/algod/getTransactionProof.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/models/types.js +8 -8
  7. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  8. package/dist/cjs/client/v2/indexer/models/types.js +75 -3
  9. package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
  10. package/dist/cjs/client/v2/indexer/searchForTransactions.js +19 -0
  11. package/dist/cjs/client/v2/indexer/searchForTransactions.js.map +1 -1
  12. package/dist/cjs/encoding/schema/bytearray.js +3 -0
  13. package/dist/cjs/encoding/schema/bytearray.js.map +1 -1
  14. package/dist/esm/client/v2/algod/getTransactionProof.js +2 -2
  15. package/dist/esm/client/v2/algod/getTransactionProof.js.map +1 -1
  16. package/dist/esm/client/v2/algod/models/types.js +6 -6
  17. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  18. package/dist/esm/client/v2/indexer/models/types.js +72 -1
  19. package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
  20. package/dist/esm/client/v2/indexer/searchForTransactions.js +19 -0
  21. package/dist/esm/client/v2/indexer/searchForTransactions.js.map +1 -1
  22. package/dist/esm/encoding/schema/bytearray.js +3 -0
  23. package/dist/esm/encoding/schema/bytearray.js.map +1 -1
  24. package/dist/types/client/v2/algod/getTransactionProof.d.ts +3 -3
  25. package/dist/types/client/v2/algod/models/types.d.ts +4 -4
  26. package/dist/types/client/v2/indexer/models/types.d.ts +46 -1
  27. package/dist/types/client/v2/indexer/searchForTransactions.d.ts +16 -0
  28. package/package.json +2 -2
  29. package/src/client/v2/algod/getTransactionProof.ts +4 -4
  30. package/src/client/v2/algod/models/types.ts +7 -7
  31. package/src/client/v2/indexer/models/types.ts +119 -0
  32. package/src/client/v2/indexer/searchForTransactions.ts +20 -0
  33. package/src/encoding/schema/bytearray.ts +3 -0
@@ -2381,6 +2381,47 @@ export class BoxDescriptor {
2381
2381
  });
2382
2382
  }
2383
2383
  }
2384
+ /**
2385
+ * BoxReference names a box by its name and the application ID it belongs to.
2386
+ */
2387
+ export class BoxReference {
2388
+ static get encodingSchema() {
2389
+ if (!this.encodingSchemaValue) {
2390
+ this.encodingSchemaValue = new NamedMapSchema([]);
2391
+ this.encodingSchemaValue.pushEntries({ key: 'app', valueSchema: new Uint64Schema(), omitEmpty: true }, { key: 'name', valueSchema: new ByteArraySchema(), omitEmpty: true });
2392
+ }
2393
+ return this.encodingSchemaValue;
2394
+ }
2395
+ /**
2396
+ * Creates a new `BoxReference` object.
2397
+ * @param app - Application ID to which the box belongs, or zero if referring to the called
2398
+ * application.
2399
+ * @param name - Base64 encoded box name
2400
+ */
2401
+ constructor({ app, name, }) {
2402
+ this.app = ensureSafeInteger(app);
2403
+ this.name = typeof name === 'string' ? base64ToBytes(name) : name;
2404
+ }
2405
+ // eslint-disable-next-line class-methods-use-this
2406
+ getEncodingSchema() {
2407
+ return BoxReference.encodingSchema;
2408
+ }
2409
+ toEncodingData() {
2410
+ return new Map([
2411
+ ['app', this.app],
2412
+ ['name', this.name],
2413
+ ]);
2414
+ }
2415
+ static fromEncodingData(data) {
2416
+ if (!(data instanceof Map)) {
2417
+ throw new Error(`Invalid decoded BoxReference: ${data}`);
2418
+ }
2419
+ return new BoxReference({
2420
+ app: data.get('app'),
2421
+ name: data.get('name'),
2422
+ });
2423
+ }
2424
+ }
2384
2425
  /**
2385
2426
  * Box names of an application
2386
2427
  */
@@ -4179,6 +4220,10 @@ export class TransactionApplication {
4179
4220
  key: 'approval-program',
4180
4221
  valueSchema: new OptionalSchema(new ByteArraySchema()),
4181
4222
  omitEmpty: true,
4223
+ }, {
4224
+ key: 'box-references',
4225
+ valueSchema: new OptionalSchema(new ArraySchema(BoxReference.encodingSchema)),
4226
+ omitEmpty: true,
4182
4227
  }, {
4183
4228
  key: 'clear-state-program',
4184
4229
  valueSchema: new OptionalSchema(new ByteArraySchema()),
@@ -4207,6 +4252,10 @@ export class TransactionApplication {
4207
4252
  key: 'on-completion',
4208
4253
  valueSchema: new OptionalSchema(new StringSchema()),
4209
4254
  omitEmpty: true,
4255
+ }, {
4256
+ key: 'reject-version',
4257
+ valueSchema: new OptionalSchema(new Uint64Schema()),
4258
+ omitEmpty: true,
4210
4259
  });
4211
4260
  }
4212
4261
  return this.encodingSchemaValue;
@@ -4222,6 +4271,8 @@ export class TransactionApplication {
4222
4271
  * on-completion is set to "clear". It can read and write global state for the
4223
4272
  * application, as well as account-specific local state. Approval programs may
4224
4273
  * reject the transaction.
4274
+ * @param boxReferences - (apbx) the boxes that can be accessed by this transaction (and others in the
4275
+ * same group).
4225
4276
  * @param clearStateProgram - (apsu) Logic executed for application transactions with on-completion set to
4226
4277
  * "clear". It can read and write global state for the application, as well as
4227
4278
  * account-specific local state. Clear state programs cannot reject the
@@ -4249,8 +4300,10 @@ export class TransactionApplication {
4249
4300
  * * update
4250
4301
  * * update
4251
4302
  * * delete
4303
+ * @param rejectVersion - (aprv) the lowest application version for which this transaction should
4304
+ * immediately fail. 0 indicates that no version check should be performed.
4252
4305
  */
4253
- constructor({ applicationId, accounts, applicationArgs, approvalProgram, clearStateProgram, extraProgramPages, foreignApps, foreignAssets, globalStateSchema, localStateSchema, onCompletion, }) {
4306
+ constructor({ applicationId, accounts, applicationArgs, approvalProgram, boxReferences, clearStateProgram, extraProgramPages, foreignApps, foreignAssets, globalStateSchema, localStateSchema, onCompletion, rejectVersion, }) {
4254
4307
  this.applicationId = ensureBigInt(applicationId);
4255
4308
  this.accounts =
4256
4309
  typeof accounts !== 'undefined'
@@ -4261,6 +4314,7 @@ export class TransactionApplication {
4261
4314
  typeof approvalProgram === 'string'
4262
4315
  ? base64ToBytes(approvalProgram)
4263
4316
  : approvalProgram;
4317
+ this.boxReferences = boxReferences;
4264
4318
  this.clearStateProgram =
4265
4319
  typeof clearStateProgram === 'string'
4266
4320
  ? base64ToBytes(clearStateProgram)
@@ -4280,6 +4334,10 @@ export class TransactionApplication {
4280
4334
  this.globalStateSchema = globalStateSchema;
4281
4335
  this.localStateSchema = localStateSchema;
4282
4336
  this.onCompletion = onCompletion;
4337
+ this.rejectVersion =
4338
+ typeof rejectVersion === 'undefined'
4339
+ ? undefined
4340
+ : ensureSafeInteger(rejectVersion);
4283
4341
  }
4284
4342
  // eslint-disable-next-line class-methods-use-this
4285
4343
  getEncodingSchema() {
@@ -4296,6 +4354,12 @@ export class TransactionApplication {
4296
4354
  ],
4297
4355
  ['application-args', this.applicationArgs],
4298
4356
  ['approval-program', this.approvalProgram],
4357
+ [
4358
+ 'box-references',
4359
+ typeof this.boxReferences !== 'undefined'
4360
+ ? this.boxReferences.map((v) => v.toEncodingData())
4361
+ : undefined,
4362
+ ],
4299
4363
  ['clear-state-program', this.clearStateProgram],
4300
4364
  ['extra-program-pages', this.extraProgramPages],
4301
4365
  ['foreign-apps', this.foreignApps],
@@ -4313,6 +4377,7 @@ export class TransactionApplication {
4313
4377
  : undefined,
4314
4378
  ],
4315
4379
  ['on-completion', this.onCompletion],
4380
+ ['reject-version', this.rejectVersion],
4316
4381
  ]);
4317
4382
  }
4318
4383
  static fromEncodingData(data) {
@@ -4324,6 +4389,11 @@ export class TransactionApplication {
4324
4389
  accounts: data.get('accounts'),
4325
4390
  applicationArgs: data.get('application-args'),
4326
4391
  approvalProgram: data.get('approval-program'),
4392
+ boxReferences: typeof data.get('box-references') !== 'undefined'
4393
+ ? data
4394
+ .get('box-references')
4395
+ .map((v) => BoxReference.fromEncodingData(v))
4396
+ : undefined,
4327
4397
  clearStateProgram: data.get('clear-state-program'),
4328
4398
  extraProgramPages: data.get('extra-program-pages'),
4329
4399
  foreignApps: data.get('foreign-apps'),
@@ -4335,6 +4405,7 @@ export class TransactionApplication {
4335
4405
  ? StateSchema.fromEncodingData(data.get('local-state-schema'))
4336
4406
  : undefined,
4337
4407
  onCompletion: data.get('on-completion'),
4408
+ rejectVersion: data.get('reject-version'),
4338
4409
  });
4339
4410
  }
4340
4411
  }