algosdk 2.3.0 → 2.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 (44) 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/client/v2/algod/algod.js +51 -0
  5. package/dist/cjs/client/v2/algod/algod.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/getLedgerStateDelta.js +20 -0
  7. package/dist/cjs/client/v2/algod/getLedgerStateDelta.js.map +1 -0
  8. package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +20 -0
  9. package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -0
  10. package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +25 -0
  11. package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -0
  12. package/dist/cjs/client/v2/algod/models/types.js +73 -3
  13. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  14. package/dist/cjs/client/v2/serviceClient.js +3 -0
  15. package/dist/cjs/client/v2/serviceClient.js.map +1 -1
  16. package/dist/cjs/composer.js +1 -1
  17. package/dist/cjs/composer.js.map +1 -1
  18. package/dist/esm/client/v2/algod/algod.js +51 -0
  19. package/dist/esm/client/v2/algod/algod.js.map +1 -1
  20. package/dist/esm/client/v2/algod/getLedgerStateDelta.js +14 -0
  21. package/dist/esm/client/v2/algod/getLedgerStateDelta.js.map +1 -0
  22. package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +14 -0
  23. package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -0
  24. package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +19 -0
  25. package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -0
  26. package/dist/esm/client/v2/algod/models/types.js +69 -2
  27. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  28. package/dist/esm/client/v2/serviceClient.js +3 -0
  29. package/dist/esm/client/v2/serviceClient.js.map +1 -1
  30. package/dist/esm/composer.js +1 -1
  31. package/dist/esm/composer.js.map +1 -1
  32. package/dist/types/client/v2/algod/algod.d.ts +45 -0
  33. package/dist/types/client/v2/algod/getLedgerStateDelta.d.ts +8 -0
  34. package/dist/types/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts +8 -0
  35. package/dist/types/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts +10 -0
  36. package/dist/types/client/v2/algod/models/types.d.ts +49 -2
  37. package/package.json +1 -3
  38. package/src/client/v2/algod/algod.ts +62 -0
  39. package/src/client/v2/algod/getLedgerStateDelta.ts +16 -0
  40. package/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts +16 -0
  41. package/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts +29 -0
  42. package/src/client/v2/algod/models/types.ts +106 -0
  43. package/src/client/v2/serviceClient.ts +3 -0
  44. package/src/composer.ts +1 -1
@@ -40,6 +40,9 @@ import { EncodedSignedTransaction } from '../../../types';
40
40
  import * as encoding from '../../../encoding/encoding';
41
41
  import Ready from './ready';
42
42
  import UnsetSyncRound from './unsetSyncRound';
43
+ import GetLedgerStateDeltaForTransactionGroup from './getLedgerStateDeltaForTransactionGroup';
44
+ import GetLedgerStateDelta from './getLedgerStateDelta';
45
+ import GetTransactionGroupLedgerStateDeltasForRound from './getTransactionGroupLedgerStateDeltasForRound';
43
46
 
44
47
  /**
45
48
  * Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with.
@@ -751,4 +754,63 @@ export default class AlgodClient extends ServiceClient {
751
754
  ready() {
752
755
  return new Ready(this.c, this.intDecoding);
753
756
  }
757
+
758
+ /**
759
+ * GetLedgerStateDeltaForTransactionGroup returns the ledger delta for the txn group identified by id
760
+ *
761
+ * #### Example
762
+ * ```typescript
763
+ * const id = "ABC123";
764
+ * await client.getLedgerStateDeltaForTransactionGroup(id).do();
765
+ * ```
766
+ *
767
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltastxngroupid)
768
+ * @param id txn ID or group ID to be searched for
769
+ * @category GET
770
+ */
771
+ getLedgerStateDeltaForTransactionGroup(id: string) {
772
+ return new GetLedgerStateDeltaForTransactionGroup(
773
+ this.c,
774
+ this.intDecoding,
775
+ id
776
+ );
777
+ }
778
+
779
+ /**
780
+ * GetLedgerStateDelta returns the ledger delta for the entire round
781
+ *
782
+ * #### Example
783
+ * ```typescript
784
+ * const round = 12345;
785
+ * await client.getLedgerStateDelta(round).do();
786
+ * ```
787
+ *
788
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasround)
789
+ * @param round the round number to be searched for
790
+ * @category GET
791
+ */
792
+ getLedgerStateDelta(round: bigint) {
793
+ return new GetLedgerStateDelta(this.c, this.intDecoding, round);
794
+ }
795
+
796
+ /**
797
+ * GetTransactionGroupLedgerStateDeltasForRound returns all ledger deltas for txn groups in the provided round
798
+ *
799
+ * #### Example
800
+ * ```typescript
801
+ * const round = 12345;
802
+ * await client.getTransactionGroupLedgerStateDeltasForRound(round).do();
803
+ * ```
804
+ *
805
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasroundtxngroup)
806
+ * @param round the round number to be searched for
807
+ * @category GET
808
+ */
809
+ getTransactionGroupLedgerStateDeltasForRound(round: bigint) {
810
+ return new GetTransactionGroupLedgerStateDeltasForRound(
811
+ this.c,
812
+ this.intDecoding,
813
+ round
814
+ );
815
+ }
754
816
  }
@@ -0,0 +1,16 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import HTTPClient from '../../client';
3
+ import IntDecoding from '../../../types/intDecoding';
4
+
5
+ export default class GetLedgerStateDelta extends JSONRequest {
6
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) {
7
+ super(c, intDecoding);
8
+ this.round = round;
9
+ this.query = { format: 'json' };
10
+ }
11
+
12
+ // eslint-disable-next-line class-methods-use-this
13
+ path() {
14
+ return `/v2/deltas/${this.round}`;
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import HTTPClient from '../../client';
3
+ import IntDecoding from '../../../types/intDecoding';
4
+
5
+ export default class GetLedgerStateDeltaForTransactionGroup extends JSONRequest {
6
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private id: string) {
7
+ super(c, intDecoding);
8
+ this.id = id;
9
+ this.query = { format: 'json' };
10
+ }
11
+
12
+ // eslint-disable-next-line class-methods-use-this
13
+ path() {
14
+ return `/v2/deltas/txn/group/${this.id}`;
15
+ }
16
+ }
@@ -0,0 +1,29 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import { TransactionGroupLedgerStateDeltasForRoundResponse } from './models/types';
3
+ import HTTPClient from '../../client';
4
+ import IntDecoding from '../../../types/intDecoding';
5
+
6
+ export default class GetTransactionGroupLedgerStateDeltasForRound extends JSONRequest<
7
+ TransactionGroupLedgerStateDeltasForRoundResponse,
8
+ Record<string, any>
9
+ > {
10
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) {
11
+ super(c, intDecoding);
12
+ this.round = round;
13
+ this.query = { format: 'json' };
14
+ }
15
+
16
+ // eslint-disable-next-line class-methods-use-this
17
+ path() {
18
+ return `/v2/deltas/${this.round}/txn/group`;
19
+ }
20
+
21
+ // eslint-disable-next-line class-methods-use-this
22
+ prepare(
23
+ body: Record<string, any>
24
+ ): TransactionGroupLedgerStateDeltasForRoundResponse {
25
+ return TransactionGroupLedgerStateDeltasForRoundResponse.from_obj_for_encoding(
26
+ body
27
+ );
28
+ }
29
+ }
@@ -2558,6 +2558,52 @@ export class KvDelta extends BaseModel {
2558
2558
  }
2559
2559
  }
2560
2560
 
2561
+ /**
2562
+ * Contains a ledger delta for a single transaction group
2563
+ */
2564
+ export class LedgerStateDeltaForTransactionGroup extends BaseModel {
2565
+ /**
2566
+ * Ledger StateDelta object
2567
+ */
2568
+ public delta: Record<string, any>;
2569
+
2570
+ public ids: string[];
2571
+
2572
+ /**
2573
+ * Creates a new `LedgerStateDeltaForTransactionGroup` object.
2574
+ * @param delta - Ledger StateDelta object
2575
+ * @param ids -
2576
+ */
2577
+ constructor({ delta, ids }: { delta: Record<string, any>; ids: string[] }) {
2578
+ super();
2579
+ this.delta = delta;
2580
+ this.ids = ids;
2581
+
2582
+ this.attribute_map = {
2583
+ delta: 'delta',
2584
+ ids: 'ids',
2585
+ };
2586
+ }
2587
+
2588
+ // eslint-disable-next-line camelcase
2589
+ static from_obj_for_encoding(
2590
+ data: Record<string, any>
2591
+ ): LedgerStateDeltaForTransactionGroup {
2592
+ /* eslint-disable dot-notation */
2593
+ if (typeof data['delta'] === 'undefined')
2594
+ throw new Error(`Response is missing required field 'delta': ${data}`);
2595
+ if (!Array.isArray(data['ids']))
2596
+ throw new Error(
2597
+ `Response is missing required array field 'ids': ${data}`
2598
+ );
2599
+ return new LedgerStateDeltaForTransactionGroup({
2600
+ delta: data['delta'],
2601
+ ids: data['ids'],
2602
+ });
2603
+ /* eslint-enable dot-notation */
2604
+ }
2605
+ }
2606
+
2561
2607
  /**
2562
2608
  * Proof of membership and position of a light block header.
2563
2609
  */
@@ -3318,31 +3364,41 @@ export class SimulateRequest extends BaseModel {
3318
3364
  */
3319
3365
  public allowMoreLogging?: boolean;
3320
3366
 
3367
+ /**
3368
+ * Applies extra opcode budget during simulation for each transaction group.
3369
+ */
3370
+ public extraOpcodeBudget?: number | bigint;
3371
+
3321
3372
  /**
3322
3373
  * Creates a new `SimulateRequest` object.
3323
3374
  * @param txnGroups - The transaction groups to simulate.
3324
3375
  * @param allowEmptySignatures - Allow transactions without signatures to be simulated as if they had correct
3325
3376
  * signatures.
3326
3377
  * @param allowMoreLogging - Lifts limits on log opcode usage during simulation.
3378
+ * @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group.
3327
3379
  */
3328
3380
  constructor({
3329
3381
  txnGroups,
3330
3382
  allowEmptySignatures,
3331
3383
  allowMoreLogging,
3384
+ extraOpcodeBudget,
3332
3385
  }: {
3333
3386
  txnGroups: SimulateRequestTransactionGroup[];
3334
3387
  allowEmptySignatures?: boolean;
3335
3388
  allowMoreLogging?: boolean;
3389
+ extraOpcodeBudget?: number | bigint;
3336
3390
  }) {
3337
3391
  super();
3338
3392
  this.txnGroups = txnGroups;
3339
3393
  this.allowEmptySignatures = allowEmptySignatures;
3340
3394
  this.allowMoreLogging = allowMoreLogging;
3395
+ this.extraOpcodeBudget = extraOpcodeBudget;
3341
3396
 
3342
3397
  this.attribute_map = {
3343
3398
  txnGroups: 'txn-groups',
3344
3399
  allowEmptySignatures: 'allow-empty-signatures',
3345
3400
  allowMoreLogging: 'allow-more-logging',
3401
+ extraOpcodeBudget: 'extra-opcode-budget',
3346
3402
  };
3347
3403
  }
3348
3404
 
@@ -3359,6 +3415,7 @@ export class SimulateRequest extends BaseModel {
3359
3415
  ),
3360
3416
  allowEmptySignatures: data['allow-empty-signatures'],
3361
3417
  allowMoreLogging: data['allow-more-logging'],
3418
+ extraOpcodeBudget: data['extra-opcode-budget'],
3362
3419
  });
3363
3420
  /* eslint-enable dot-notation */
3364
3421
  }
@@ -3672,6 +3729,11 @@ export class SimulationEvalOverrides extends BaseModel {
3672
3729
  */
3673
3730
  public allowEmptySignatures?: boolean;
3674
3731
 
3732
+ /**
3733
+ * The extra opcode budget added to each transaction group during simulation
3734
+ */
3735
+ public extraOpcodeBudget?: number | bigint;
3736
+
3675
3737
  /**
3676
3738
  * The maximum log calls one can make during simulation
3677
3739
  */
@@ -3686,25 +3748,30 @@ export class SimulationEvalOverrides extends BaseModel {
3686
3748
  * Creates a new `SimulationEvalOverrides` object.
3687
3749
  * @param allowEmptySignatures - If true, transactions without signatures are allowed and simulated as if they
3688
3750
  * were properly signed.
3751
+ * @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation
3689
3752
  * @param maxLogCalls - The maximum log calls one can make during simulation
3690
3753
  * @param maxLogSize - The maximum byte number to log during simulation
3691
3754
  */
3692
3755
  constructor({
3693
3756
  allowEmptySignatures,
3757
+ extraOpcodeBudget,
3694
3758
  maxLogCalls,
3695
3759
  maxLogSize,
3696
3760
  }: {
3697
3761
  allowEmptySignatures?: boolean;
3762
+ extraOpcodeBudget?: number | bigint;
3698
3763
  maxLogCalls?: number | bigint;
3699
3764
  maxLogSize?: number | bigint;
3700
3765
  }) {
3701
3766
  super();
3702
3767
  this.allowEmptySignatures = allowEmptySignatures;
3768
+ this.extraOpcodeBudget = extraOpcodeBudget;
3703
3769
  this.maxLogCalls = maxLogCalls;
3704
3770
  this.maxLogSize = maxLogSize;
3705
3771
 
3706
3772
  this.attribute_map = {
3707
3773
  allowEmptySignatures: 'allow-empty-signatures',
3774
+ extraOpcodeBudget: 'extra-opcode-budget',
3708
3775
  maxLogCalls: 'max-log-calls',
3709
3776
  maxLogSize: 'max-log-size',
3710
3777
  };
@@ -3717,6 +3784,7 @@ export class SimulationEvalOverrides extends BaseModel {
3717
3784
  /* eslint-disable dot-notation */
3718
3785
  return new SimulationEvalOverrides({
3719
3786
  allowEmptySignatures: data['allow-empty-signatures'],
3787
+ extraOpcodeBudget: data['extra-opcode-budget'],
3720
3788
  maxLogCalls: data['max-log-calls'],
3721
3789
  maxLogSize: data['max-log-size'],
3722
3790
  });
@@ -4066,6 +4134,44 @@ export class TealValue extends BaseModel {
4066
4134
  }
4067
4135
  }
4068
4136
 
4137
+ /**
4138
+ * Response containing all ledger state deltas for transaction groups, with their
4139
+ * associated Ids, in a single round.
4140
+ */
4141
+ export class TransactionGroupLedgerStateDeltasForRoundResponse extends BaseModel {
4142
+ public deltas: LedgerStateDeltaForTransactionGroup[];
4143
+
4144
+ /**
4145
+ * Creates a new `TransactionGroupLedgerStateDeltasForRoundResponse` object.
4146
+ * @param deltas -
4147
+ */
4148
+ constructor({ deltas }: { deltas: LedgerStateDeltaForTransactionGroup[] }) {
4149
+ super();
4150
+ this.deltas = deltas;
4151
+
4152
+ this.attribute_map = {
4153
+ deltas: 'deltas',
4154
+ };
4155
+ }
4156
+
4157
+ // eslint-disable-next-line camelcase
4158
+ static from_obj_for_encoding(
4159
+ data: Record<string, any>
4160
+ ): TransactionGroupLedgerStateDeltasForRoundResponse {
4161
+ /* eslint-disable dot-notation */
4162
+ if (!Array.isArray(data['Deltas']))
4163
+ throw new Error(
4164
+ `Response is missing required array field 'Deltas': ${data}`
4165
+ );
4166
+ return new TransactionGroupLedgerStateDeltasForRoundResponse({
4167
+ deltas: data['Deltas'].map(
4168
+ LedgerStateDeltaForTransactionGroup.from_obj_for_encoding
4169
+ ),
4170
+ });
4171
+ /* eslint-enable dot-notation */
4172
+ }
4173
+ }
4174
+
4069
4175
  /**
4070
4176
  * TransactionParams contains the parameters that help a client construct a new
4071
4177
  * transaction.
@@ -19,6 +19,9 @@ function convertTokenStringToTokenHeader(
19
19
  headerIdentifier: TokenHeaderIdentifier
20
20
  ): TokenHeader {
21
21
  const tokenHeader = {};
22
+ if (token === '') {
23
+ return tokenHeader;
24
+ }
22
25
  tokenHeader[headerIdentifier] = token;
23
26
  return tokenHeader as TokenHeader;
24
27
  }
package/src/composer.ts CHANGED
@@ -351,7 +351,7 @@ export class AtomicTransactionComposer {
351
351
  !abiCheckTransactionType(argType, argValue.txn)
352
352
  ) {
353
353
  throw new Error(
354
- `Expected ${argType} transaction for argument at index ${i}`
354
+ `Expected ${argType} TransactionWithSigner for argument at index ${i}`
355
355
  );
356
356
  }
357
357
  if (argValue.txn.group && argValue.txn.group.some((v) => v !== 0)) {