@algorandfoundation/algokit-utils 8.2.0-beta.1 → 8.2.0-beta.3

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 (71) hide show
  1. package/package.json +3 -2
  2. package/types/account-manager.d.ts +33 -18
  3. package/types/account-manager.js +33 -18
  4. package/types/account-manager.js.map +1 -1
  5. package/types/account-manager.mjs +33 -18
  6. package/types/account-manager.mjs.map +1 -1
  7. package/types/account.d.ts +5 -0
  8. package/types/account.js +5 -0
  9. package/types/account.js.map +1 -1
  10. package/types/account.mjs +5 -0
  11. package/types/account.mjs.map +1 -1
  12. package/types/algorand-client-transaction-creator.d.ts +103 -70
  13. package/types/algorand-client-transaction-creator.js +103 -70
  14. package/types/algorand-client-transaction-creator.js.map +1 -1
  15. package/types/algorand-client-transaction-creator.mjs +103 -70
  16. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  17. package/types/algorand-client-transaction-sender.d.ts +107 -20
  18. package/types/algorand-client-transaction-sender.js +107 -21
  19. package/types/algorand-client-transaction-sender.js.map +1 -1
  20. package/types/algorand-client-transaction-sender.mjs +107 -21
  21. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  22. package/types/algorand-client.d.ts +108 -24
  23. package/types/algorand-client.js +107 -23
  24. package/types/algorand-client.js.map +1 -1
  25. package/types/algorand-client.mjs +107 -23
  26. package/types/algorand-client.mjs.map +1 -1
  27. package/types/amount.d.ts +10 -0
  28. package/types/amount.js +10 -0
  29. package/types/amount.js.map +1 -1
  30. package/types/amount.mjs +10 -0
  31. package/types/amount.mjs.map +1 -1
  32. package/types/app-client.d.ts +128 -8
  33. package/types/app-client.js +131 -8
  34. package/types/app-client.js.map +1 -1
  35. package/types/app-client.mjs +131 -8
  36. package/types/app-client.mjs.map +1 -1
  37. package/types/app-deployer.d.ts +33 -1
  38. package/types/app-deployer.js +33 -1
  39. package/types/app-deployer.js.map +1 -1
  40. package/types/app-deployer.mjs +33 -1
  41. package/types/app-deployer.mjs.map +1 -1
  42. package/types/app-factory.d.ts +74 -4
  43. package/types/app-factory.js +74 -4
  44. package/types/app-factory.js.map +1 -1
  45. package/types/app-factory.mjs +74 -4
  46. package/types/app-factory.mjs.map +1 -1
  47. package/types/app-manager.d.ts +64 -0
  48. package/types/app-manager.js +64 -0
  49. package/types/app-manager.js.map +1 -1
  50. package/types/app-manager.mjs +64 -0
  51. package/types/app-manager.mjs.map +1 -1
  52. package/types/app-spec.d.ts +9 -0
  53. package/types/app-spec.js +9 -0
  54. package/types/app-spec.js.map +1 -1
  55. package/types/app-spec.mjs +9 -0
  56. package/types/app-spec.mjs.map +1 -1
  57. package/types/asset-manager.d.ts +5 -5
  58. package/types/asset-manager.js +5 -5
  59. package/types/asset-manager.js.map +1 -1
  60. package/types/asset-manager.mjs +5 -5
  61. package/types/asset-manager.mjs.map +1 -1
  62. package/types/client-manager.d.ts +79 -18
  63. package/types/client-manager.js +79 -18
  64. package/types/client-manager.js.map +1 -1
  65. package/types/client-manager.mjs +79 -18
  66. package/types/client-manager.mjs.map +1 -1
  67. package/types/composer.d.ts +599 -1
  68. package/types/composer.js +575 -1
  69. package/types/composer.js.map +1 -1
  70. package/types/composer.mjs +575 -1
  71. package/types/composer.mjs.map +1 -1
@@ -94,6 +94,18 @@ function getConstantBlockOffset(program) {
94
94
  /** ARC-56/ARC-32 application client that allows you to manage calls and
95
95
  * state for a specific deployed instance of an app (with a known app ID). */
96
96
  class AppClient {
97
+ /**
98
+ * Create a new app client.
99
+ * @param params The parameters to create the app client
100
+ * @returns The `AppClient` instance
101
+ * @example
102
+ * ```typescript
103
+ * const appClient = new AppClient({
104
+ * appId: 12345678n,
105
+ * appSpec: appSpec,
106
+ * algorand: AlgorandClient.mainNet(),
107
+ * })
108
+ */
97
109
  constructor(params) {
98
110
  this._appId = params.appId;
99
111
  this._appAddress = algosdk.getApplicationAddress(this._appId);
@@ -128,6 +140,10 @@ class AppClient {
128
140
  *
129
141
  * @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.
130
142
  * @returns A new app client with the altered params
143
+ * @example
144
+ * ```typescript
145
+ * const appClient2 = appClient.clone({ defaultSender: 'NEW_SENDER_ADDRESS' })
146
+ * ```
131
147
  */
132
148
  clone(params) {
133
149
  return new AppClient({
@@ -146,6 +162,15 @@ class AppClient {
146
162
  * Returns a new `AppClient` client, resolving the app by creator address and name
147
163
  * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
148
164
  * @param params The parameters to create the app client
165
+ * @returns The `AppClient` instance
166
+ * @example
167
+ * ```typescript
168
+ * const appClient = await AppClient.fromCreatorAndName({
169
+ * creatorAddress: 'CREATOR_ADDRESS',
170
+ * name: 'APP_NAME',
171
+ * appSpec: appSpec,
172
+ * algorand: AlgorandClient.mainNet(),
173
+ * })
149
174
  */
150
175
  static async fromCreatorAndName(params) {
151
176
  const appSpec = AppClient.normaliseAppSpec(params.appSpec);
@@ -166,6 +191,13 @@ class AppClient {
166
191
  *
167
192
  * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
168
193
  * @param params The parameters to create the app client
194
+ * @returns The `AppClient` instance
195
+ * @example
196
+ * ```typescript
197
+ * const appClient = await AppClient.fromNetwork({
198
+ * appSpec: appSpec,
199
+ * algorand: AlgorandClient.mainNet(),
200
+ * })
169
201
  */
170
202
  static async fromNetwork(params) {
171
203
  const network = await params.algorand.client.network();
@@ -190,6 +222,10 @@ class AppClient {
190
222
  * normalises it into a parsed ARC-56 contract object.
191
223
  * @param spec The spec to normalise
192
224
  * @returns The normalised ARC-56 contract object
225
+ * @example
226
+ * ```typescript
227
+ * const arc56AppSpec = AppClient.normaliseAppSpec(appSpec)
228
+ * ```
193
229
  */
194
230
  static normaliseAppSpec(spec) {
195
231
  const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
@@ -266,6 +302,10 @@ class AppClient {
266
302
  * An alias for `appClient.send.fundAppAccount(params)`.
267
303
  * @param params The parameters for the funding transaction
268
304
  * @returns The result of the funding
305
+ * @example
306
+ * ```typescript
307
+ * await appClient.fundAppAccount({ amount: algo(1) })
308
+ * ```
269
309
  */
270
310
  async fundAppAccount(params) {
271
311
  return this.send.fundAppAccount(params);
@@ -273,6 +313,10 @@ class AppClient {
273
313
  /**
274
314
  * Returns raw global state for the current app.
275
315
  * @returns The global state
316
+ * @example
317
+ * ```typescript
318
+ * const globalState = await appClient.getGlobalState()
319
+ * ```
276
320
  */
277
321
  async getGlobalState() {
278
322
  return await this._algorand.app.getGlobalState(this.appId);
@@ -281,6 +325,10 @@ class AppClient {
281
325
  * Returns raw local state for the given account address.
282
326
  * @param address The address of the account to get the local state for
283
327
  * @returns The local state
328
+ * @example
329
+ * ```typescript
330
+ * const localState = await appClient.getLocalState('ACCOUNT_ADDRESS')
331
+ * ```
284
332
  */
285
333
  async getLocalState(address) {
286
334
  return await this._algorand.app.getLocalState(this.appId, address);
@@ -288,6 +336,10 @@ class AppClient {
288
336
  /**
289
337
  * Returns the names of all current boxes for the current app.
290
338
  * @returns The names of the boxes
339
+ * @example
340
+ * ```typescript
341
+ * const boxNames = await appClient.getBoxNames()
342
+ * ```
291
343
  */
292
344
  async getBoxNames() {
293
345
  return await this._algorand.app.getBoxNames(this.appId);
@@ -296,6 +348,10 @@ class AppClient {
296
348
  * Returns the value of the given box for the current app.
297
349
  * @param name The identifier of the box to return
298
350
  * @returns The current box value as a byte array
351
+ * @example
352
+ * ```typescript
353
+ * const boxValue = await appClient.getBoxValue('boxName')
354
+ * ```
299
355
  */
300
356
  async getBoxValue(name) {
301
357
  return await this._algorand.app.getBoxValue(this.appId, name);
@@ -305,6 +361,10 @@ class AppClient {
305
361
  * @param name The identifier of the box to return
306
362
  * @param type
307
363
  * @returns The current box value as a byte array
364
+ * @example
365
+ * ```typescript
366
+ * const boxValue = await appClient.getBoxValueFromABIType('boxName', new ABIUintType(32))
367
+ * ```
308
368
  */
309
369
  async getBoxValueFromABIType(name, type) {
310
370
  return await this._algorand.app.getBoxValueFromABIType({
@@ -318,6 +378,10 @@ class AppClient {
318
378
  * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
319
379
  * @param filter Optional filter to filter which boxes' values are returned
320
380
  * @returns The (name, value) pair of the boxes with values as raw byte arrays
381
+ * @example
382
+ * ```typescript
383
+ * const boxValues = await appClient.getBoxValues()
384
+ * ```
321
385
  */
322
386
  async getBoxValues(filter) {
323
387
  const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
@@ -330,6 +394,10 @@ class AppClient {
330
394
  * @param type The ABI type to decode the values with
331
395
  * @param filter Optional filter to filter which boxes' values are returned
332
396
  * @returns The (name, value) pair of the boxes with values as the ABI Value
397
+ * @example
398
+ * ```typescript
399
+ * const boxValues = await appClient.getBoxValuesFromABIType(new ABIUintType(32))
400
+ * ```
333
401
  */
334
402
  async getBoxValuesFromABIType(type, filter) {
335
403
  const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
@@ -414,6 +482,8 @@ class AppClient {
414
482
  * If no TEAL templates provided it will use any byte code provided in the app spec.
415
483
  *
416
484
  * Will store any generated source maps for later use in debugging.
485
+ * @param compilation Any compilation parameters to use
486
+ * @returns The compiled code and any compilation results (including source maps)
417
487
  */
418
488
  async compile(compilation) {
419
489
  const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
@@ -489,7 +559,9 @@ class AppClient {
489
559
  *
490
560
  * Will store any generated source maps for later use in debugging.
491
561
  * @param appSpec The app spec for the app
562
+ * @param appManager The app manager to use for compilation
492
563
  * @param compilation Any compilation parameters to use
564
+ * @returns The compiled code and any compilation results (including source maps)
493
565
  */
494
566
  static async compile(appSpec, appManager, compilation) {
495
567
  const { deployTimeParams, updatable, deletable } = compilation ?? {};
@@ -537,6 +609,9 @@ class AppClient {
537
609
  const m = getArc56Method(methodNameOrSignature, this._appSpec);
538
610
  return await Promise.all(args?.map(async (a, i) => {
539
611
  const arg = m.args[i];
612
+ if (!arg) {
613
+ throw new Error(`Unexpected arg at position ${i}. ${m.name} only expects ${m.args.length} args`);
614
+ }
540
615
  if (a !== undefined) {
541
616
  // If a struct then convert to tuple for the underlying call
542
617
  return arg.struct && typeof a === 'object' && !Array.isArray(a)
@@ -678,7 +753,11 @@ class AppClient {
678
753
  }
679
754
  getMethodCallParamsMethods() {
680
755
  return {
681
- /** Return params for a payment transaction to fund the app account */
756
+ /**
757
+ * Return params for a payment transaction to fund the app account
758
+ * @param params The parameters for the fund app accont payment transaction
759
+ * @returns The parameters which can be used to create a fund app account payment transaction
760
+ */
682
761
  fundAppAccount: (params) => {
683
762
  return {
684
763
  ...params,
@@ -687,26 +766,44 @@ class AppClient {
687
766
  receiver: this.appAddress,
688
767
  };
689
768
  },
690
- /** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
769
+ /**
770
+ * Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
771
+ * @param params The parameters for the update ABI method call
772
+ * @returns The parameters which can be used to create an update ABI method call
773
+ */
691
774
  update: async (params) => {
692
775
  return (await this.getABIParams({
693
776
  ...params,
694
777
  ...(await this.compile(params)),
695
778
  }, OnApplicationComplete.UpdateApplicationOC));
696
779
  },
697
- /** Return params for an opt-in ABI call */
780
+ /**
781
+ * Return params for an opt-in ABI call
782
+ * @param params The parameters for the opt-in ABI method call
783
+ * @returns The parameters which can be used to create an opt-in ABI method call
784
+ */
698
785
  optIn: async (params) => {
699
786
  return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
700
787
  },
701
- /** Return params for an delete ABI call */
788
+ /**
789
+ * Return params for an delete ABI call
790
+ * @param params The parameters for the delete ABI method call
791
+ * @returns The parameters which can be used to create a delete ABI method call
792
+ */
702
793
  delete: async (params) => {
703
794
  return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
704
795
  },
705
- /** Return params for an close out ABI call */
796
+ /** Return params for an close out ABI call
797
+ * @param params The parameters for the close out ABI method call
798
+ * @returns The parameters which can be used to create a close out ABI method call
799
+ */
706
800
  closeOut: async (params) => {
707
801
  return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
708
802
  },
709
- /** Return params for an ABI call */
803
+ /** Return params for an ABI call
804
+ * @param params The parameters for the ABI method call
805
+ * @returns The parameters which can be used to create an ABI method call
806
+ */
710
807
  call: async (params) => {
711
808
  return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
712
809
  },
@@ -714,12 +811,17 @@ class AppClient {
714
811
  }
715
812
  getMethodCallSendMethods() {
716
813
  return {
717
- /** Sign and send transactions for a payment transaction to fund the app account */
814
+ /** Sign and send transactions for a payment transaction to fund the app account
815
+ * @param params The parameters for the fund app account payment transaction
816
+ * @returns The result of send the fund app account payment transaction
817
+ */
718
818
  fundAppAccount: (params) => {
719
819
  return this._algorand.send.payment(this.params.fundAppAccount(params));
720
820
  },
721
821
  /**
722
822
  * Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
823
+ * @param params The parameters for the update ABI method call
824
+ * @returns The result of sending the update ABI method call
723
825
  */
724
826
  update: async (params) => {
725
827
  const compiled = await this.compile(params);
@@ -730,24 +832,32 @@ class AppClient {
730
832
  },
731
833
  /**
732
834
  * Sign and send transactions for an opt-in ABI call
835
+ * @param params The parameters for the opt-in ABI method call
836
+ * @returns The result of sending the opt-in ABI method call
733
837
  */
734
838
  optIn: (params) => {
735
839
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
736
840
  },
737
841
  /**
738
842
  * Sign and send transactions for a delete ABI call
843
+ * @param params The parameters for the delete ABI method call
844
+ * @returns The result of sending the delete ABI method call
739
845
  */
740
846
  delete: (params) => {
741
847
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
742
848
  },
743
849
  /**
744
850
  * Sign and send transactions for a close out ABI call
851
+ * @param params The parameters for the close out ABI method call
852
+ * @returns The result of sending the close out ABI method call
745
853
  */
746
854
  closeOut: (params) => {
747
855
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
748
856
  },
749
857
  /**
750
858
  * Sign and send transactions for a call (defaults to no-op)
859
+ * @param params The parameters for the ABI method call
860
+ * @returns The result of sending the ABI method call
751
861
  */
752
862
  call: async (params) => {
753
863
  // Read-only call - do it via simulate
@@ -798,36 +908,49 @@ class AppClient {
798
908
  }
799
909
  getMethodCallCreateTransactionMethods() {
800
910
  return {
801
- /** Return transaction for a payment transaction to fund the app account */
911
+ /** Return transaction for a payment transaction to fund the app account
912
+ * @param params The parameters for the fund app account payment transaction
913
+ * @returns A transaction which can be used to fund the app account
914
+ */
802
915
  fundAppAccount: (params) => {
803
916
  return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
804
917
  },
805
918
  /**
806
919
  * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
920
+ * @param params The parameters for the update ABI method call
921
+ * @returns The transactions which can be used to create an update ABI method call
807
922
  */
808
923
  update: async (params) => {
809
924
  return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
810
925
  },
811
926
  /**
812
927
  * Return transactions for an opt-in ABI call
928
+ * @param params The parameters for the opt-in ABI method call
929
+ * @returns The transactions which can be used to create an opt-in ABI method call
813
930
  */
814
931
  optIn: async (params) => {
815
932
  return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
816
933
  },
817
934
  /**
818
935
  * Return transactions for a delete ABI call
936
+ * @param params The parameters for the delete ABI method call
937
+ * @returns The transactions which can be used to create a delete ABI method call
819
938
  */
820
939
  delete: async (params) => {
821
940
  return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
822
941
  },
823
942
  /**
824
943
  * Return transactions for a close out ABI call
944
+ * @param params The parameters for the close out ABI method call
945
+ * @returns The transactions which can be used to create a close out ABI method call
825
946
  */
826
947
  closeOut: async (params) => {
827
948
  return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
828
949
  },
829
950
  /**
830
951
  * Return transactions for an ABI call (defaults to no-op)
952
+ * @param params The parameters for the ABI method call
953
+ * @returns The transactions which can be used to create an ABI method call
831
954
  */
832
955
  call: async (params) => {
833
956
  return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));