@algorandfoundation/algokit-utils 8.2.0-beta.2 → 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 +128 -8
  34. package/types/app-client.js.map +1 -1
  35. package/types/app-client.mjs +128 -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 ?? {};
@@ -681,7 +753,11 @@ class AppClient {
681
753
  }
682
754
  getMethodCallParamsMethods() {
683
755
  return {
684
- /** 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
+ */
685
761
  fundAppAccount: (params) => {
686
762
  return {
687
763
  ...params,
@@ -690,26 +766,44 @@ class AppClient {
690
766
  receiver: this.appAddress,
691
767
  };
692
768
  },
693
- /** 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
+ */
694
774
  update: async (params) => {
695
775
  return (await this.getABIParams({
696
776
  ...params,
697
777
  ...(await this.compile(params)),
698
778
  }, OnApplicationComplete.UpdateApplicationOC));
699
779
  },
700
- /** 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
+ */
701
785
  optIn: async (params) => {
702
786
  return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
703
787
  },
704
- /** 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
+ */
705
793
  delete: async (params) => {
706
794
  return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
707
795
  },
708
- /** 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
+ */
709
800
  closeOut: async (params) => {
710
801
  return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
711
802
  },
712
- /** 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
+ */
713
807
  call: async (params) => {
714
808
  return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
715
809
  },
@@ -717,12 +811,17 @@ class AppClient {
717
811
  }
718
812
  getMethodCallSendMethods() {
719
813
  return {
720
- /** 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
+ */
721
818
  fundAppAccount: (params) => {
722
819
  return this._algorand.send.payment(this.params.fundAppAccount(params));
723
820
  },
724
821
  /**
725
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
726
825
  */
727
826
  update: async (params) => {
728
827
  const compiled = await this.compile(params);
@@ -733,24 +832,32 @@ class AppClient {
733
832
  },
734
833
  /**
735
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
736
837
  */
737
838
  optIn: (params) => {
738
839
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
739
840
  },
740
841
  /**
741
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
742
845
  */
743
846
  delete: (params) => {
744
847
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
745
848
  },
746
849
  /**
747
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
748
853
  */
749
854
  closeOut: (params) => {
750
855
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
751
856
  },
752
857
  /**
753
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
754
861
  */
755
862
  call: async (params) => {
756
863
  // Read-only call - do it via simulate
@@ -801,36 +908,49 @@ class AppClient {
801
908
  }
802
909
  getMethodCallCreateTransactionMethods() {
803
910
  return {
804
- /** 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
+ */
805
915
  fundAppAccount: (params) => {
806
916
  return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
807
917
  },
808
918
  /**
809
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
810
922
  */
811
923
  update: async (params) => {
812
924
  return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
813
925
  },
814
926
  /**
815
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
816
930
  */
817
931
  optIn: async (params) => {
818
932
  return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
819
933
  },
820
934
  /**
821
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
822
938
  */
823
939
  delete: async (params) => {
824
940
  return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
825
941
  },
826
942
  /**
827
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
828
946
  */
829
947
  closeOut: async (params) => {
830
948
  return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
831
949
  },
832
950
  /**
833
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
834
954
  */
835
955
  call: async (params) => {
836
956
  return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));