@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.
- package/package.json +3 -2
- package/types/account-manager.d.ts +33 -18
- package/types/account-manager.js +33 -18
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +33 -18
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +5 -0
- package/types/account.js +5 -0
- package/types/account.js.map +1 -1
- package/types/account.mjs +5 -0
- package/types/account.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +103 -70
- package/types/algorand-client-transaction-creator.js +103 -70
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +103 -70
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +107 -20
- package/types/algorand-client-transaction-sender.js +107 -21
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +107 -21
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +108 -24
- package/types/algorand-client.js +107 -23
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +107 -23
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +10 -0
- package/types/amount.js +10 -0
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +10 -0
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +128 -8
- package/types/app-client.js +128 -8
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +128 -8
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +33 -1
- package/types/app-deployer.js +33 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +33 -1
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +74 -4
- package/types/app-factory.js +74 -4
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +74 -4
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +64 -0
- package/types/app-manager.js +64 -0
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +64 -0
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +9 -0
- package/types/app-spec.js +9 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +9 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/asset-manager.d.ts +5 -5
- package/types/asset-manager.js +5 -5
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +5 -5
- package/types/asset-manager.mjs.map +1 -1
- package/types/client-manager.d.ts +79 -18
- package/types/client-manager.js +79 -18
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +79 -18
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +599 -1
- package/types/composer.js +575 -1
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +575 -1
- package/types/composer.mjs.map +1 -1
package/types/app-client.js
CHANGED
|
@@ -96,6 +96,18 @@ function getConstantBlockOffset(program) {
|
|
|
96
96
|
/** ARC-56/ARC-32 application client that allows you to manage calls and
|
|
97
97
|
* state for a specific deployed instance of an app (with a known app ID). */
|
|
98
98
|
class AppClient {
|
|
99
|
+
/**
|
|
100
|
+
* Create a new app client.
|
|
101
|
+
* @param params The parameters to create the app client
|
|
102
|
+
* @returns The `AppClient` instance
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const appClient = new AppClient({
|
|
106
|
+
* appId: 12345678n,
|
|
107
|
+
* appSpec: appSpec,
|
|
108
|
+
* algorand: AlgorandClient.mainNet(),
|
|
109
|
+
* })
|
|
110
|
+
*/
|
|
99
111
|
constructor(params) {
|
|
100
112
|
this._appId = params.appId;
|
|
101
113
|
this._appAddress = algosdk.getApplicationAddress(this._appId);
|
|
@@ -130,6 +142,10 @@ class AppClient {
|
|
|
130
142
|
*
|
|
131
143
|
* @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.
|
|
132
144
|
* @returns A new app client with the altered params
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const appClient2 = appClient.clone({ defaultSender: 'NEW_SENDER_ADDRESS' })
|
|
148
|
+
* ```
|
|
133
149
|
*/
|
|
134
150
|
clone(params) {
|
|
135
151
|
return new AppClient({
|
|
@@ -148,6 +164,15 @@ class AppClient {
|
|
|
148
164
|
* Returns a new `AppClient` client, resolving the app by creator address and name
|
|
149
165
|
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
150
166
|
* @param params The parameters to create the app client
|
|
167
|
+
* @returns The `AppClient` instance
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const appClient = await AppClient.fromCreatorAndName({
|
|
171
|
+
* creatorAddress: 'CREATOR_ADDRESS',
|
|
172
|
+
* name: 'APP_NAME',
|
|
173
|
+
* appSpec: appSpec,
|
|
174
|
+
* algorand: AlgorandClient.mainNet(),
|
|
175
|
+
* })
|
|
151
176
|
*/
|
|
152
177
|
static async fromCreatorAndName(params) {
|
|
153
178
|
const appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
@@ -168,6 +193,13 @@ class AppClient {
|
|
|
168
193
|
*
|
|
169
194
|
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
170
195
|
* @param params The parameters to create the app client
|
|
196
|
+
* @returns The `AppClient` instance
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const appClient = await AppClient.fromNetwork({
|
|
200
|
+
* appSpec: appSpec,
|
|
201
|
+
* algorand: AlgorandClient.mainNet(),
|
|
202
|
+
* })
|
|
171
203
|
*/
|
|
172
204
|
static async fromNetwork(params) {
|
|
173
205
|
const network = await params.algorand.client.network();
|
|
@@ -192,6 +224,10 @@ class AppClient {
|
|
|
192
224
|
* normalises it into a parsed ARC-56 contract object.
|
|
193
225
|
* @param spec The spec to normalise
|
|
194
226
|
* @returns The normalised ARC-56 contract object
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const arc56AppSpec = AppClient.normaliseAppSpec(appSpec)
|
|
230
|
+
* ```
|
|
195
231
|
*/
|
|
196
232
|
static normaliseAppSpec(spec) {
|
|
197
233
|
const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
|
|
@@ -268,6 +304,10 @@ class AppClient {
|
|
|
268
304
|
* An alias for `appClient.send.fundAppAccount(params)`.
|
|
269
305
|
* @param params The parameters for the funding transaction
|
|
270
306
|
* @returns The result of the funding
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* await appClient.fundAppAccount({ amount: algo(1) })
|
|
310
|
+
* ```
|
|
271
311
|
*/
|
|
272
312
|
async fundAppAccount(params) {
|
|
273
313
|
return this.send.fundAppAccount(params);
|
|
@@ -275,6 +315,10 @@ class AppClient {
|
|
|
275
315
|
/**
|
|
276
316
|
* Returns raw global state for the current app.
|
|
277
317
|
* @returns The global state
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const globalState = await appClient.getGlobalState()
|
|
321
|
+
* ```
|
|
278
322
|
*/
|
|
279
323
|
async getGlobalState() {
|
|
280
324
|
return await this._algorand.app.getGlobalState(this.appId);
|
|
@@ -283,6 +327,10 @@ class AppClient {
|
|
|
283
327
|
* Returns raw local state for the given account address.
|
|
284
328
|
* @param address The address of the account to get the local state for
|
|
285
329
|
* @returns The local state
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const localState = await appClient.getLocalState('ACCOUNT_ADDRESS')
|
|
333
|
+
* ```
|
|
286
334
|
*/
|
|
287
335
|
async getLocalState(address) {
|
|
288
336
|
return await this._algorand.app.getLocalState(this.appId, address);
|
|
@@ -290,6 +338,10 @@ class AppClient {
|
|
|
290
338
|
/**
|
|
291
339
|
* Returns the names of all current boxes for the current app.
|
|
292
340
|
* @returns The names of the boxes
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const boxNames = await appClient.getBoxNames()
|
|
344
|
+
* ```
|
|
293
345
|
*/
|
|
294
346
|
async getBoxNames() {
|
|
295
347
|
return await this._algorand.app.getBoxNames(this.appId);
|
|
@@ -298,6 +350,10 @@ class AppClient {
|
|
|
298
350
|
* Returns the value of the given box for the current app.
|
|
299
351
|
* @param name The identifier of the box to return
|
|
300
352
|
* @returns The current box value as a byte array
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const boxValue = await appClient.getBoxValue('boxName')
|
|
356
|
+
* ```
|
|
301
357
|
*/
|
|
302
358
|
async getBoxValue(name) {
|
|
303
359
|
return await this._algorand.app.getBoxValue(this.appId, name);
|
|
@@ -307,6 +363,10 @@ class AppClient {
|
|
|
307
363
|
* @param name The identifier of the box to return
|
|
308
364
|
* @param type
|
|
309
365
|
* @returns The current box value as a byte array
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const boxValue = await appClient.getBoxValueFromABIType('boxName', new ABIUintType(32))
|
|
369
|
+
* ```
|
|
310
370
|
*/
|
|
311
371
|
async getBoxValueFromABIType(name, type) {
|
|
312
372
|
return await this._algorand.app.getBoxValueFromABIType({
|
|
@@ -320,6 +380,10 @@ class AppClient {
|
|
|
320
380
|
* Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
|
|
321
381
|
* @param filter Optional filter to filter which boxes' values are returned
|
|
322
382
|
* @returns The (name, value) pair of the boxes with values as raw byte arrays
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* const boxValues = await appClient.getBoxValues()
|
|
386
|
+
* ```
|
|
323
387
|
*/
|
|
324
388
|
async getBoxValues(filter) {
|
|
325
389
|
const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
|
|
@@ -332,6 +396,10 @@ class AppClient {
|
|
|
332
396
|
* @param type The ABI type to decode the values with
|
|
333
397
|
* @param filter Optional filter to filter which boxes' values are returned
|
|
334
398
|
* @returns The (name, value) pair of the boxes with values as the ABI Value
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const boxValues = await appClient.getBoxValuesFromABIType(new ABIUintType(32))
|
|
402
|
+
* ```
|
|
335
403
|
*/
|
|
336
404
|
async getBoxValuesFromABIType(type, filter) {
|
|
337
405
|
const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
|
|
@@ -416,6 +484,8 @@ class AppClient {
|
|
|
416
484
|
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
417
485
|
*
|
|
418
486
|
* Will store any generated source maps for later use in debugging.
|
|
487
|
+
* @param compilation Any compilation parameters to use
|
|
488
|
+
* @returns The compiled code and any compilation results (including source maps)
|
|
419
489
|
*/
|
|
420
490
|
async compile(compilation) {
|
|
421
491
|
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
@@ -491,7 +561,9 @@ class AppClient {
|
|
|
491
561
|
*
|
|
492
562
|
* Will store any generated source maps for later use in debugging.
|
|
493
563
|
* @param appSpec The app spec for the app
|
|
564
|
+
* @param appManager The app manager to use for compilation
|
|
494
565
|
* @param compilation Any compilation parameters to use
|
|
566
|
+
* @returns The compiled code and any compilation results (including source maps)
|
|
495
567
|
*/
|
|
496
568
|
static async compile(appSpec, appManager, compilation) {
|
|
497
569
|
const { deployTimeParams, updatable, deletable } = compilation ?? {};
|
|
@@ -683,7 +755,11 @@ class AppClient {
|
|
|
683
755
|
}
|
|
684
756
|
getMethodCallParamsMethods() {
|
|
685
757
|
return {
|
|
686
|
-
/**
|
|
758
|
+
/**
|
|
759
|
+
* Return params for a payment transaction to fund the app account
|
|
760
|
+
* @param params The parameters for the fund app accont payment transaction
|
|
761
|
+
* @returns The parameters which can be used to create a fund app account payment transaction
|
|
762
|
+
*/
|
|
687
763
|
fundAppAccount: (params) => {
|
|
688
764
|
return {
|
|
689
765
|
...params,
|
|
@@ -692,26 +768,44 @@ class AppClient {
|
|
|
692
768
|
receiver: this.appAddress,
|
|
693
769
|
};
|
|
694
770
|
},
|
|
695
|
-
/**
|
|
771
|
+
/**
|
|
772
|
+
* Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
773
|
+
* @param params The parameters for the update ABI method call
|
|
774
|
+
* @returns The parameters which can be used to create an update ABI method call
|
|
775
|
+
*/
|
|
696
776
|
update: async (params) => {
|
|
697
777
|
return (await this.getABIParams({
|
|
698
778
|
...params,
|
|
699
779
|
...(await this.compile(params)),
|
|
700
780
|
}, OnApplicationComplete.UpdateApplicationOC));
|
|
701
781
|
},
|
|
702
|
-
/**
|
|
782
|
+
/**
|
|
783
|
+
* Return params for an opt-in ABI call
|
|
784
|
+
* @param params The parameters for the opt-in ABI method call
|
|
785
|
+
* @returns The parameters which can be used to create an opt-in ABI method call
|
|
786
|
+
*/
|
|
703
787
|
optIn: async (params) => {
|
|
704
788
|
return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
|
|
705
789
|
},
|
|
706
|
-
/**
|
|
790
|
+
/**
|
|
791
|
+
* Return params for an delete ABI call
|
|
792
|
+
* @param params The parameters for the delete ABI method call
|
|
793
|
+
* @returns The parameters which can be used to create a delete ABI method call
|
|
794
|
+
*/
|
|
707
795
|
delete: async (params) => {
|
|
708
796
|
return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
|
|
709
797
|
},
|
|
710
|
-
/** Return params for an close out ABI call
|
|
798
|
+
/** Return params for an close out ABI call
|
|
799
|
+
* @param params The parameters for the close out ABI method call
|
|
800
|
+
* @returns The parameters which can be used to create a close out ABI method call
|
|
801
|
+
*/
|
|
711
802
|
closeOut: async (params) => {
|
|
712
803
|
return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
|
|
713
804
|
},
|
|
714
|
-
/** Return params for an ABI call
|
|
805
|
+
/** Return params for an ABI call
|
|
806
|
+
* @param params The parameters for the ABI method call
|
|
807
|
+
* @returns The parameters which can be used to create an ABI method call
|
|
808
|
+
*/
|
|
715
809
|
call: async (params) => {
|
|
716
810
|
return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
|
|
717
811
|
},
|
|
@@ -719,12 +813,17 @@ class AppClient {
|
|
|
719
813
|
}
|
|
720
814
|
getMethodCallSendMethods() {
|
|
721
815
|
return {
|
|
722
|
-
/** Sign and send transactions for a payment transaction to fund the app account
|
|
816
|
+
/** Sign and send transactions for a payment transaction to fund the app account
|
|
817
|
+
* @param params The parameters for the fund app account payment transaction
|
|
818
|
+
* @returns The result of send the fund app account payment transaction
|
|
819
|
+
*/
|
|
723
820
|
fundAppAccount: (params) => {
|
|
724
821
|
return this._algorand.send.payment(this.params.fundAppAccount(params));
|
|
725
822
|
},
|
|
726
823
|
/**
|
|
727
824
|
* Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
825
|
+
* @param params The parameters for the update ABI method call
|
|
826
|
+
* @returns The result of sending the update ABI method call
|
|
728
827
|
*/
|
|
729
828
|
update: async (params) => {
|
|
730
829
|
const compiled = await this.compile(params);
|
|
@@ -735,24 +834,32 @@ class AppClient {
|
|
|
735
834
|
},
|
|
736
835
|
/**
|
|
737
836
|
* Sign and send transactions for an opt-in ABI call
|
|
837
|
+
* @param params The parameters for the opt-in ABI method call
|
|
838
|
+
* @returns The result of sending the opt-in ABI method call
|
|
738
839
|
*/
|
|
739
840
|
optIn: (params) => {
|
|
740
841
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
741
842
|
},
|
|
742
843
|
/**
|
|
743
844
|
* Sign and send transactions for a delete ABI call
|
|
845
|
+
* @param params The parameters for the delete ABI method call
|
|
846
|
+
* @returns The result of sending the delete ABI method call
|
|
744
847
|
*/
|
|
745
848
|
delete: (params) => {
|
|
746
849
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
747
850
|
},
|
|
748
851
|
/**
|
|
749
852
|
* Sign and send transactions for a close out ABI call
|
|
853
|
+
* @param params The parameters for the close out ABI method call
|
|
854
|
+
* @returns The result of sending the close out ABI method call
|
|
750
855
|
*/
|
|
751
856
|
closeOut: (params) => {
|
|
752
857
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
753
858
|
},
|
|
754
859
|
/**
|
|
755
860
|
* Sign and send transactions for a call (defaults to no-op)
|
|
861
|
+
* @param params The parameters for the ABI method call
|
|
862
|
+
* @returns The result of sending the ABI method call
|
|
756
863
|
*/
|
|
757
864
|
call: async (params) => {
|
|
758
865
|
// Read-only call - do it via simulate
|
|
@@ -803,36 +910,49 @@ class AppClient {
|
|
|
803
910
|
}
|
|
804
911
|
getMethodCallCreateTransactionMethods() {
|
|
805
912
|
return {
|
|
806
|
-
/** Return transaction for a payment transaction to fund the app account
|
|
913
|
+
/** Return transaction for a payment transaction to fund the app account
|
|
914
|
+
* @param params The parameters for the fund app account payment transaction
|
|
915
|
+
* @returns A transaction which can be used to fund the app account
|
|
916
|
+
*/
|
|
807
917
|
fundAppAccount: (params) => {
|
|
808
918
|
return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
|
|
809
919
|
},
|
|
810
920
|
/**
|
|
811
921
|
* Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
922
|
+
* @param params The parameters for the update ABI method call
|
|
923
|
+
* @returns The transactions which can be used to create an update ABI method call
|
|
812
924
|
*/
|
|
813
925
|
update: async (params) => {
|
|
814
926
|
return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
|
|
815
927
|
},
|
|
816
928
|
/**
|
|
817
929
|
* Return transactions for an opt-in ABI call
|
|
930
|
+
* @param params The parameters for the opt-in ABI method call
|
|
931
|
+
* @returns The transactions which can be used to create an opt-in ABI method call
|
|
818
932
|
*/
|
|
819
933
|
optIn: async (params) => {
|
|
820
934
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
|
|
821
935
|
},
|
|
822
936
|
/**
|
|
823
937
|
* Return transactions for a delete ABI call
|
|
938
|
+
* @param params The parameters for the delete ABI method call
|
|
939
|
+
* @returns The transactions which can be used to create a delete ABI method call
|
|
824
940
|
*/
|
|
825
941
|
delete: async (params) => {
|
|
826
942
|
return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
|
|
827
943
|
},
|
|
828
944
|
/**
|
|
829
945
|
* Return transactions for a close out ABI call
|
|
946
|
+
* @param params The parameters for the close out ABI method call
|
|
947
|
+
* @returns The transactions which can be used to create a close out ABI method call
|
|
830
948
|
*/
|
|
831
949
|
closeOut: async (params) => {
|
|
832
950
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
|
|
833
951
|
},
|
|
834
952
|
/**
|
|
835
953
|
* Return transactions for an ABI call (defaults to no-op)
|
|
954
|
+
* @param params The parameters for the ABI method call
|
|
955
|
+
* @returns The transactions which can be used to create an ABI method call
|
|
836
956
|
*/
|
|
837
957
|
call: async (params) => {
|
|
838
958
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
|