@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.
- 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 +131 -8
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +131 -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 ?? {};
|
|
@@ -539,6 +611,9 @@ class AppClient {
|
|
|
539
611
|
const m = types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
|
|
540
612
|
return await Promise.all(args?.map(async (a, i) => {
|
|
541
613
|
const arg = m.args[i];
|
|
614
|
+
if (!arg) {
|
|
615
|
+
throw new Error(`Unexpected arg at position ${i}. ${m.name} only expects ${m.args.length} args`);
|
|
616
|
+
}
|
|
542
617
|
if (a !== undefined) {
|
|
543
618
|
// If a struct then convert to tuple for the underlying call
|
|
544
619
|
return arg.struct && typeof a === 'object' && !Array.isArray(a)
|
|
@@ -680,7 +755,11 @@ class AppClient {
|
|
|
680
755
|
}
|
|
681
756
|
getMethodCallParamsMethods() {
|
|
682
757
|
return {
|
|
683
|
-
/**
|
|
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
|
+
*/
|
|
684
763
|
fundAppAccount: (params) => {
|
|
685
764
|
return {
|
|
686
765
|
...params,
|
|
@@ -689,26 +768,44 @@ class AppClient {
|
|
|
689
768
|
receiver: this.appAddress,
|
|
690
769
|
};
|
|
691
770
|
},
|
|
692
|
-
/**
|
|
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
|
+
*/
|
|
693
776
|
update: async (params) => {
|
|
694
777
|
return (await this.getABIParams({
|
|
695
778
|
...params,
|
|
696
779
|
...(await this.compile(params)),
|
|
697
780
|
}, OnApplicationComplete.UpdateApplicationOC));
|
|
698
781
|
},
|
|
699
|
-
/**
|
|
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
|
+
*/
|
|
700
787
|
optIn: async (params) => {
|
|
701
788
|
return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
|
|
702
789
|
},
|
|
703
|
-
/**
|
|
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
|
+
*/
|
|
704
795
|
delete: async (params) => {
|
|
705
796
|
return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
|
|
706
797
|
},
|
|
707
|
-
/** 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
|
+
*/
|
|
708
802
|
closeOut: async (params) => {
|
|
709
803
|
return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
|
|
710
804
|
},
|
|
711
|
-
/** 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
|
+
*/
|
|
712
809
|
call: async (params) => {
|
|
713
810
|
return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
|
|
714
811
|
},
|
|
@@ -716,12 +813,17 @@ class AppClient {
|
|
|
716
813
|
}
|
|
717
814
|
getMethodCallSendMethods() {
|
|
718
815
|
return {
|
|
719
|
-
/** 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
|
+
*/
|
|
720
820
|
fundAppAccount: (params) => {
|
|
721
821
|
return this._algorand.send.payment(this.params.fundAppAccount(params));
|
|
722
822
|
},
|
|
723
823
|
/**
|
|
724
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
|
|
725
827
|
*/
|
|
726
828
|
update: async (params) => {
|
|
727
829
|
const compiled = await this.compile(params);
|
|
@@ -732,24 +834,32 @@ class AppClient {
|
|
|
732
834
|
},
|
|
733
835
|
/**
|
|
734
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
|
|
735
839
|
*/
|
|
736
840
|
optIn: (params) => {
|
|
737
841
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
738
842
|
},
|
|
739
843
|
/**
|
|
740
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
|
|
741
847
|
*/
|
|
742
848
|
delete: (params) => {
|
|
743
849
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
744
850
|
},
|
|
745
851
|
/**
|
|
746
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
|
|
747
855
|
*/
|
|
748
856
|
closeOut: (params) => {
|
|
749
857
|
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
750
858
|
},
|
|
751
859
|
/**
|
|
752
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
|
|
753
863
|
*/
|
|
754
864
|
call: async (params) => {
|
|
755
865
|
// Read-only call - do it via simulate
|
|
@@ -800,36 +910,49 @@ class AppClient {
|
|
|
800
910
|
}
|
|
801
911
|
getMethodCallCreateTransactionMethods() {
|
|
802
912
|
return {
|
|
803
|
-
/** 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
|
+
*/
|
|
804
917
|
fundAppAccount: (params) => {
|
|
805
918
|
return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
|
|
806
919
|
},
|
|
807
920
|
/**
|
|
808
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
|
|
809
924
|
*/
|
|
810
925
|
update: async (params) => {
|
|
811
926
|
return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
|
|
812
927
|
},
|
|
813
928
|
/**
|
|
814
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
|
|
815
932
|
*/
|
|
816
933
|
optIn: async (params) => {
|
|
817
934
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
|
|
818
935
|
},
|
|
819
936
|
/**
|
|
820
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
|
|
821
940
|
*/
|
|
822
941
|
delete: async (params) => {
|
|
823
942
|
return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
|
|
824
943
|
},
|
|
825
944
|
/**
|
|
826
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
|
|
827
948
|
*/
|
|
828
949
|
closeOut: async (params) => {
|
|
829
950
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
|
|
830
951
|
},
|
|
831
952
|
/**
|
|
832
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
|
|
833
956
|
*/
|
|
834
957
|
call: async (params) => {
|
|
835
958
|
return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
|