@algorandfoundation/algokit-utils 7.0.0-beta.3 → 7.0.0-beta.5

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 (170) hide show
  1. package/amount.d.ts +14 -4
  2. package/amount.d.ts.map +1 -1
  3. package/amount.js +6 -0
  4. package/amount.js.map +1 -1
  5. package/amount.mjs +6 -0
  6. package/amount.mjs.map +1 -1
  7. package/app-client.d.ts +15 -0
  8. package/app-client.d.ts.map +1 -1
  9. package/app-client.js +15 -0
  10. package/app-client.js.map +1 -1
  11. package/app-client.mjs +15 -0
  12. package/app-client.mjs.map +1 -1
  13. package/app-deploy.d.ts.map +1 -1
  14. package/app-deploy.js +4 -6
  15. package/app-deploy.js.map +1 -1
  16. package/app-deploy.mjs +5 -7
  17. package/app-deploy.mjs.map +1 -1
  18. package/app.d.ts +2 -2
  19. package/app.d.ts.map +1 -1
  20. package/app.js +7 -3
  21. package/app.js.map +1 -1
  22. package/app.mjs +7 -3
  23. package/app.mjs.map +1 -1
  24. package/asset.d.ts.map +1 -1
  25. package/asset.js +0 -3
  26. package/asset.js.map +1 -1
  27. package/asset.mjs +0 -3
  28. package/asset.mjs.map +1 -1
  29. package/debugging/debugging.d.ts +1 -1
  30. package/debugging/debugging.d.ts.map +1 -1
  31. package/debugging/debugging.js +4 -5
  32. package/debugging/debugging.js.map +1 -1
  33. package/debugging/debugging.mjs +4 -5
  34. package/debugging/debugging.mjs.map +1 -1
  35. package/index.d.ts +4 -4
  36. package/index.d.ts.map +1 -1
  37. package/index.js +37 -37
  38. package/index.mjs +5 -5
  39. package/package.json +1 -1
  40. package/testing/test-logger.d.ts.map +1 -1
  41. package/testing/test-logger.js +1 -3
  42. package/testing/test-logger.js.map +1 -1
  43. package/testing/test-logger.mjs +1 -3
  44. package/testing/test-logger.mjs.map +1 -1
  45. package/transaction/legacy-bridge.d.ts +3 -3
  46. package/transaction/legacy-bridge.d.ts.map +1 -1
  47. package/transaction/legacy-bridge.js +1 -1
  48. package/transaction/legacy-bridge.js.map +1 -1
  49. package/transaction/legacy-bridge.mjs +2 -2
  50. package/transaction/legacy-bridge.mjs.map +1 -1
  51. package/transaction/transaction.d.ts +34 -3
  52. package/transaction/transaction.d.ts.map +1 -1
  53. package/transaction/transaction.js +42 -11
  54. package/transaction/transaction.js.map +1 -1
  55. package/transaction/transaction.mjs +42 -11
  56. package/transaction/transaction.mjs.map +1 -1
  57. package/transfer/transfer.js +2 -2
  58. package/transfer/transfer.js.map +1 -1
  59. package/transfer/transfer.mjs +2 -2
  60. package/transfer/transfer.mjs.map +1 -1
  61. package/types/account-manager.d.ts +2 -2
  62. package/types/account-manager.d.ts.map +1 -1
  63. package/types/account-manager.js +1 -1
  64. package/types/account-manager.js.map +1 -1
  65. package/types/account-manager.mjs +1 -1
  66. package/types/account-manager.mjs.map +1 -1
  67. package/types/algorand-client-interface.d.ts +29 -0
  68. package/types/algorand-client-interface.d.ts.map +1 -0
  69. package/types/algorand-client-interface.js +3 -0
  70. package/types/algorand-client-interface.js.map +1 -0
  71. package/types/algorand-client-interface.mjs +2 -0
  72. package/types/algorand-client-interface.mjs.map +1 -0
  73. package/types/algorand-client-transaction-sender.d.ts +12 -12
  74. package/types/algorand-client-transaction-sender.d.ts.map +1 -1
  75. package/types/algorand-client-transaction-sender.js +22 -6
  76. package/types/algorand-client-transaction-sender.js.map +1 -1
  77. package/types/algorand-client-transaction-sender.mjs +22 -6
  78. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  79. package/types/algorand-client.d.ts +2 -1
  80. package/types/algorand-client.d.ts.map +1 -1
  81. package/types/algorand-client.js +1 -1
  82. package/types/algorand-client.js.map +1 -1
  83. package/types/algorand-client.mjs +1 -1
  84. package/types/algorand-client.mjs.map +1 -1
  85. package/types/amount.d.ts +10 -10
  86. package/types/amount.d.ts.map +1 -1
  87. package/types/amount.js +7 -7
  88. package/types/amount.js.map +1 -1
  89. package/types/amount.mjs +7 -7
  90. package/types/amount.mjs.map +1 -1
  91. package/types/app-arc56.d.ts +326 -0
  92. package/types/app-arc56.d.ts.map +1 -0
  93. package/types/app-arc56.js +163 -0
  94. package/types/app-arc56.js.map +1 -0
  95. package/types/app-arc56.mjs +154 -0
  96. package/types/app-arc56.mjs.map +1 -0
  97. package/types/app-client.d.ts +1479 -7
  98. package/types/app-client.d.ts.map +1 -1
  99. package/types/app-client.js +814 -8
  100. package/types/app-client.js.map +1 -1
  101. package/types/app-client.mjs +814 -9
  102. package/types/app-client.mjs.map +1 -1
  103. package/types/app-deployer.d.ts +19 -13
  104. package/types/app-deployer.d.ts.map +1 -1
  105. package/types/app-deployer.js +2 -2
  106. package/types/app-deployer.js.map +1 -1
  107. package/types/app-deployer.mjs +2 -2
  108. package/types/app-deployer.mjs.map +1 -1
  109. package/types/app-factory.d.ts +967 -0
  110. package/types/app-factory.d.ts.map +1 -0
  111. package/types/app-factory.js +322 -0
  112. package/types/app-factory.js.map +1 -0
  113. package/types/app-factory.mjs +320 -0
  114. package/types/app-factory.mjs.map +1 -0
  115. package/types/app-manager.d.ts +12 -2
  116. package/types/app-manager.d.ts.map +1 -1
  117. package/types/app-manager.js +10 -1
  118. package/types/app-manager.js.map +1 -1
  119. package/types/app-manager.mjs +10 -1
  120. package/types/app-manager.mjs.map +1 -1
  121. package/types/app-spec.d.ts +2 -0
  122. package/types/app-spec.d.ts.map +1 -1
  123. package/types/app-spec.js +115 -0
  124. package/types/app-spec.js.map +1 -1
  125. package/types/app-spec.mjs +114 -0
  126. package/types/app-spec.mjs.map +1 -1
  127. package/types/app.d.ts +6 -2
  128. package/types/app.d.ts.map +1 -1
  129. package/types/asset-manager.d.ts +2 -1
  130. package/types/asset-manager.d.ts.map +1 -1
  131. package/types/asset-manager.js +0 -1
  132. package/types/asset-manager.js.map +1 -1
  133. package/types/asset-manager.mjs +0 -1
  134. package/types/asset-manager.mjs.map +1 -1
  135. package/types/client-manager.d.ts +109 -50
  136. package/types/client-manager.d.ts.map +1 -1
  137. package/types/client-manager.js +137 -23
  138. package/types/client-manager.js.map +1 -1
  139. package/types/client-manager.mjs +138 -24
  140. package/types/client-manager.mjs.map +1 -1
  141. package/types/composer.d.ts +31 -14
  142. package/types/composer.d.ts.map +1 -1
  143. package/types/composer.js +65 -10
  144. package/types/composer.js.map +1 -1
  145. package/types/composer.mjs +66 -11
  146. package/types/composer.mjs.map +1 -1
  147. package/types/debugging.d.ts +3 -2
  148. package/types/debugging.d.ts.map +1 -1
  149. package/types/debugging.js.map +1 -1
  150. package/types/debugging.mjs.map +1 -1
  151. package/types/dispenser-client.d.ts +1 -1
  152. package/types/dispenser-client.d.ts.map +1 -1
  153. package/types/dispenser-client.js +1 -1
  154. package/types/dispenser-client.js.map +1 -1
  155. package/types/dispenser-client.mjs +1 -1
  156. package/types/dispenser-client.mjs.map +1 -1
  157. package/types/network-client.d.ts +13 -0
  158. package/types/network-client.d.ts.map +1 -1
  159. package/types/network-client.js.map +1 -1
  160. package/types/network-client.mjs.map +1 -1
  161. package/types/testing.d.ts +3 -3
  162. package/types/testing.d.ts.map +1 -1
  163. package/types/transaction.d.ts +14 -1
  164. package/types/transaction.d.ts.map +1 -1
  165. package/util.d.ts +2 -1
  166. package/util.d.ts.map +1 -1
  167. package/util.js +11 -1
  168. package/util.js.map +1 -1
  169. package/util.mjs +11 -2
  170. package/util.mjs.map +1 -1
@@ -6,7 +6,11 @@ import { Config } from '../config.mjs';
6
6
  import { persistSourceMaps } from '../debugging/debugging.mjs';
7
7
  import { legacySendTransactionBridge } from '../transaction/legacy-bridge.mjs';
8
8
  import { getSenderAddress, encodeTransactionNote } from '../transaction/transaction.mjs';
9
+ import { binaryStartsWith } from '../util.mjs';
9
10
  import { UPDATABLE_TEMPLATE_NAME, DELETABLE_TEMPLATE_NAME } from './app.mjs';
11
+ import { getArc56Method, getArc56ReturnValue, getABITupleFromABIStruct, getABIDecodedValue, getABIEncodedValue } from './app-arc56.mjs';
12
+ import { AppManager } from './app-manager.mjs';
13
+ import { arc32ToArc56 } from './app-spec.mjs';
10
14
  import { PersistSourceMapInput } from './debugging.mjs';
11
15
  import { LogicError } from './logic-error.mjs';
12
16
 
@@ -14,6 +18,7 @@ var ABIMethod = algosdk.ABIMethod;
14
18
  var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
15
19
  var getApplicationAddress = algosdk.getApplicationAddress;
16
20
  var Indexer = algosdk.Indexer;
21
+ var OnApplicationComplete = algosdk.OnApplicationComplete;
17
22
  var SourceMap = algosdk.SourceMap;
18
23
  /**
19
24
  * Determines deploy time control (UPDATABLE, DELETABLE) value by inspecting application specification
@@ -37,13 +42,787 @@ function getDeployTimeControl(approval, appSpec, templateVariableName, callConfi
37
42
  return !!abiCallConfig && abiCallConfig !== 'NEVER';
38
43
  });
39
44
  }
40
- /** Application client - a class that wraps an ARC-0032 app spec and provides high productivity methods to deploy and call the app */
45
+ /** ARC-56/ARC-32 application client that allows you to manage calls and
46
+ * state for a specific deployed instance of an app (with a known app ID). */
47
+ class AppClient {
48
+ constructor(params) {
49
+ this._appId = params.appId;
50
+ this._appAddress = algosdk.getApplicationAddress(this._appId);
51
+ this._appSpec = AppClient.normaliseAppSpec(params.appSpec);
52
+ this._appName = params.appName ?? this._appSpec.name;
53
+ this._algorand = params.algorand;
54
+ this._defaultSender = params.defaultSender;
55
+ this._approvalSourceMap = params.approvalSourceMap;
56
+ this._clearSourceMap = params.clearSourceMap;
57
+ this._localStateMethods = (address) => this.getStateMethods(() => this.getLocalState(address), () => this._appSpec.state.keys.local, () => this._appSpec.state.maps.local);
58
+ this._globalStateMethods = this.getStateMethods(() => this.getGlobalState(), () => this._appSpec.state.keys.global, () => this._appSpec.state.maps.global);
59
+ this._boxStateMethods = this.getBoxMethods();
60
+ this._paramsMethods = {
61
+ ...this.getMethodCallParamsMethods(),
62
+ bare: this.getBareParamsMethods(),
63
+ };
64
+ this._transactionsMethods = { ...this.getMethodCallTransactionsMethods(), bare: this.getBareTransactionsMethods() };
65
+ this._sendMethods = { ...this.getMethodCallSendMethods(), bare: this.getBareSendMethods() };
66
+ }
67
+ /** Start a new `AlgoKitComposer` transaction group */
68
+ newGroup() {
69
+ return this._algorand.newGroup();
70
+ }
71
+ /**
72
+ * Returns a new `AppClient` client, resolving the app by creator address and name
73
+ * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
74
+ * @param params The parameters to create the app client
75
+ */
76
+ static async fromCreatorAndName(params) {
77
+ const appSpec = AppClient.normaliseAppSpec(params.appSpec);
78
+ const appLookup = params.appLookupCache ?? (await params.algorand.appDeployer.getCreatorAppsByName(params.creatorAddress, params.ignoreCache));
79
+ const appMetadata = appLookup.apps[params.appName ?? appSpec.name];
80
+ if (!appMetadata) {
81
+ throw new Error(`App not found for creator ${params.creatorAddress} and name ${params.appName ?? appSpec.name}`);
82
+ }
83
+ return new AppClient({
84
+ ...params,
85
+ algorand: params.algorand,
86
+ appId: appMetadata.appId,
87
+ });
88
+ }
89
+ /**
90
+ * Returns an `AppClient` instance for the current network based on
91
+ * pre-determined network-specific app IDs specified in the ARC-56 app spec.
92
+ *
93
+ * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
94
+ * @param params The parameters to create the app client
95
+ */
96
+ static async fromNetwork(params) {
97
+ const network = await params.algorand.client.network();
98
+ const appSpec = AppClient.normaliseAppSpec(params.appSpec);
99
+ const networkNames = [network.genesisHash];
100
+ if (network.isLocalNet)
101
+ networkNames.push('localnet');
102
+ if (network.isTestNet)
103
+ networkNames.push('testnet');
104
+ if (network.isMainNet)
105
+ networkNames.push('mainnet');
106
+ const availableAppSpecNetworks = Object.keys(appSpec.networks ?? {});
107
+ const networkIndex = availableAppSpecNetworks.findIndex((n) => networkNames.includes(n));
108
+ if (networkIndex === -1) {
109
+ throw new Error(`No app ID found for network ${JSON.stringify(networkNames)} in the app spec`);
110
+ }
111
+ const appId = BigInt(appSpec.networks[networkIndex].appID);
112
+ return new AppClient({ ...params, appId, appSpec });
113
+ }
114
+ /**
115
+ * Takes a string or parsed JSON object that could be ARC-32 or ARC-56 format and
116
+ * normalises it into a parsed ARC-56 contract object.
117
+ * @param spec The spec to normalise
118
+ * @returns The normalised ARC-56 contract object
119
+ */
120
+ static normaliseAppSpec(spec) {
121
+ const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
122
+ const appSpec = 'hints' in parsedSpec ? arc32ToArc56(parsedSpec) : parsedSpec;
123
+ return appSpec;
124
+ }
125
+ /** The ID of the app instance this client is linked to. */
126
+ get appId() {
127
+ return this._appId;
128
+ }
129
+ /** The app address of the app instance this client is linked to. */
130
+ get appAddress() {
131
+ return this._appAddress;
132
+ }
133
+ /** The name of the app (from the ARC-32 / ARC-56 app spec). */
134
+ get appName() {
135
+ return this._appName;
136
+ }
137
+ /** The ARC-56 app spec being used */
138
+ get appSpec() {
139
+ return this._appSpec;
140
+ }
141
+ /** Get parameters to define transactions to the current app */
142
+ get params() {
143
+ return this._paramsMethods;
144
+ }
145
+ /** Get transactions for the current app */
146
+ get transactions() {
147
+ return this._transactionsMethods;
148
+ }
149
+ /** Send calls to the current app */
150
+ get send() {
151
+ return this._sendMethods;
152
+ }
153
+ get state() {
154
+ return {
155
+ /**
156
+ * Methods to access local state for the current app
157
+ * @param address The address of the account to get the local state for
158
+ */
159
+ local: this._localStateMethods,
160
+ /**
161
+ * Methods to access global state for the current app
162
+ */
163
+ global: this._globalStateMethods,
164
+ /**
165
+ * Methods to access box storage for the current app
166
+ */
167
+ box: this._boxStateMethods,
168
+ };
169
+ }
170
+ /**
171
+ * Funds Algo into the app account for this app.
172
+ * @param params The parameters for the funding transaction
173
+ * @returns The result of the funding
174
+ */
175
+ async fundAppAccount(params) {
176
+ return this.send.fundAppAccount(params);
177
+ }
178
+ /**
179
+ * Returns raw global state for the current app.
180
+ * @returns The global state
181
+ */
182
+ async getGlobalState() {
183
+ return await this._algorand.app.getGlobalState(this.appId);
184
+ }
185
+ /**
186
+ * Returns raw local state for the given account address.
187
+ * @param address The address of the account to get the local state for
188
+ * @returns The local state
189
+ */
190
+ async getLocalState(address) {
191
+ return await this._algorand.app.getLocalState(this.appId, address);
192
+ }
193
+ /**
194
+ * Returns the names of all current boxes for the current app.
195
+ * @returns The names of the boxes
196
+ */
197
+ async getBoxNames() {
198
+ return await this._algorand.app.getBoxNames(this.appId);
199
+ }
200
+ /**
201
+ * Returns the value of the given box for the current app.
202
+ * @param name The identifier of the box to return
203
+ * @returns The current box value as a byte array
204
+ */
205
+ async getBoxValue(name) {
206
+ return await this._algorand.app.getBoxValue(this.appId, name);
207
+ }
208
+ /**
209
+ * Returns the value of the given box for the current app.
210
+ * @param name The identifier of the box to return
211
+ * @param type
212
+ * @returns The current box value as a byte array
213
+ */
214
+ async getBoxValueFromABIType(name, type) {
215
+ return await this._algorand.app.getBoxValueFromABIType({
216
+ appId: this.appId,
217
+ boxName: name,
218
+ type,
219
+ });
220
+ }
221
+ /**
222
+ * Returns the values of all current boxes for the current app.
223
+ * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
224
+ * @param filter Optional filter to filter which boxes' values are returned
225
+ * @returns The (name, value) pair of the boxes with values as raw byte arrays
226
+ */
227
+ async getBoxValues(filter) {
228
+ const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
229
+ const values = await this._algorand.app.getBoxValues(this.appId, names.map((name) => name.nameRaw));
230
+ return names.map((name, i) => ({ name, value: values[i] }));
231
+ }
232
+ /**
233
+ * Returns the values of all current boxes for the current app decoded using an ABI Type.
234
+ * Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
235
+ * @param type The ABI type to decode the values with
236
+ * @param filter Optional filter to filter which boxes' values are returned
237
+ * @returns The (name, value) pair of the boxes with values as the ABI Value
238
+ */
239
+ async getBoxValuesFromABIType(type, filter) {
240
+ const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
241
+ const values = await this._algorand.app.getBoxValuesFromABIType({
242
+ appId: this.appId,
243
+ boxNames: names.map((name) => name.nameRaw),
244
+ type,
245
+ });
246
+ return names.map((name, i) => ({ name, value: values[i] }));
247
+ }
248
+ /**
249
+ * Takes an error that may include a logic error from a call to the current app and re-exposes the
250
+ * error to include source code information via the source map and ARC-56 spec.
251
+ * @param e The error to parse
252
+ * @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)
253
+ * @returns The new error, or if there was no logic error or source map then the wrapped error with source details
254
+ */
255
+ exposeLogicError(e, isClearStateProgram) {
256
+ return AppClient.exposeLogicError(e, this._appSpec, {
257
+ isClearStateProgram,
258
+ approvalSourceMap: this._approvalSourceMap,
259
+ clearSourceMap: this._clearSourceMap,
260
+ });
261
+ }
262
+ /**
263
+ * Export the current source maps for the app.
264
+ * @returns The source maps
265
+ */
266
+ exportSourceMaps() {
267
+ if (!this._approvalSourceMap || !this._clearSourceMap) {
268
+ throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");
269
+ }
270
+ return {
271
+ approvalSourceMap: this._approvalSourceMap,
272
+ clearSourceMap: this._clearSourceMap,
273
+ };
274
+ }
275
+ /**
276
+ * Import source maps for the app.
277
+ * @param sourceMaps The source maps to import
278
+ */
279
+ importSourceMaps(sourceMaps) {
280
+ this._approvalSourceMap = new SourceMap(sourceMaps.approvalSourceMap);
281
+ this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
282
+ }
283
+ /**
284
+ * Returns the ABI Method for the given method name string for the app represented by this application client instance
285
+ * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
286
+ * e.g. `my_method` or `my_method(unit64,string)bytes`
287
+ * @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
288
+ */
289
+ getABIMethod(methodNameOrSignature) {
290
+ return getArc56Method(methodNameOrSignature, this._appSpec);
291
+ }
292
+ /**
293
+ * Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
294
+ * on the ARC-56 method.
295
+ *
296
+ * If the return type is a struct then the struct will be returned.
297
+ *
298
+ * @param result The SendAppTransactionResult to be mapped
299
+ * @param method The method that was called
300
+ * @returns The smart contract response with an updated return value
301
+ */
302
+ async parseMethodCallReturn(result, method) {
303
+ const resultValue = await result;
304
+ return { ...resultValue, return: getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
305
+ }
306
+ /**
307
+ * Takes an error that may include a logic error from a call to the current app and re-exposes the
308
+ * error to include source code information via the source map and ARC-56 spec.
309
+ * @param e The error to parse
310
+ * @param appSpec The app spec for the app
311
+ * @param details Additional information to inform the error
312
+ * @returns The new error, or if there was no logic error or source map then the wrapped error with source details
313
+ */
314
+ static exposeLogicError(e, appSpec, details) {
315
+ const { isClearStateProgram, approvalSourceMap, clearSourceMap } = details;
316
+ if ((!isClearStateProgram && approvalSourceMap == undefined) || (isClearStateProgram && clearSourceMap == undefined))
317
+ return e;
318
+ const errorDetails = LogicError.parseLogicError(e);
319
+ const errorMessage = (isClearStateProgram ? appSpec.sourceInfo?.clear : appSpec.sourceInfo?.approval)?.find((s) => s?.pc?.includes(errorDetails?.pc ?? -1))?.errorMessage;
320
+ if (errorDetails !== undefined && appSpec.source)
321
+ e = new LogicError(errorDetails, Buffer.from(isClearStateProgram ? appSpec.source.clear : appSpec.source.approval, 'base64')
322
+ .toString()
323
+ .split('\n'),
324
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
325
+ isClearStateProgram ? clearSourceMap : approvalSourceMap);
326
+ if (errorMessage) {
327
+ const appId = JSON.stringify(e).match(/(?<=app=)\d+/)?.[0] || '';
328
+ const txId = JSON.stringify(e).match(/(?<=transaction )\S+(?=:)/)?.[0];
329
+ const error = new Error(`Runtime error when executing ${appSpec.name} (appId: ${appId}) in transaction ${txId}: ${errorMessage}`);
330
+ error.cause = e;
331
+ return error;
332
+ }
333
+ return e;
334
+ }
335
+ /**
336
+ * Compiles the approval and clear state programs (if TEAL templates provided),
337
+ * performing any provided deploy-time parameter replacement and returns
338
+ * the compiled code and any compilation results (including source maps).
339
+ *
340
+ * If no TEAL templates provided it will use any byte code provided in the app spec.
341
+ *
342
+ * Will store any generated source maps for later use in debugging.
343
+ * @param appSpec The app spec for the app
344
+ * @param compilation Any compilation parameters to use
345
+ */
346
+ static async compile(appSpec, appManager, compilation) {
347
+ const { deployTimeParams, updatable, deletable } = compilation ?? {};
348
+ if (!appSpec.source) {
349
+ if (!appSpec.byteCode?.approval || !appSpec.byteCode?.clear) {
350
+ throw new Error(`Attempt to compile app ${appSpec.name} without source or byteCode`);
351
+ }
352
+ return {
353
+ approvalProgram: Buffer.from(appSpec.byteCode.approval, 'base64'),
354
+ clearStateProgram: Buffer.from(appSpec.byteCode.clear, 'base64'),
355
+ };
356
+ }
357
+ const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
358
+ const compiledApproval = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {
359
+ updatable,
360
+ deletable,
361
+ });
362
+ const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
363
+ const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
364
+ if (Config.debug && Config.projectRoot) {
365
+ persistSourceMaps({
366
+ sources: [
367
+ PersistSourceMapInput.fromCompiledTeal(compiledApproval, appSpec.name, 'approval.teal'),
368
+ PersistSourceMapInput.fromCompiledTeal(compiledClear, appSpec.name, 'clear.teal'),
369
+ ],
370
+ projectRoot: Config.projectRoot,
371
+ appManager,
372
+ withSources: true,
373
+ });
374
+ }
375
+ return {
376
+ approvalProgram: compiledApproval.compiledBase64ToBytes,
377
+ compiledApproval,
378
+ clearStateProgram: compiledClear.compiledBase64ToBytes,
379
+ compiledClear,
380
+ };
381
+ }
382
+ /**
383
+ * Returns ABI method arguments ready for a method call params object with default values populated
384
+ * and structs replaced with tuples.
385
+ *
386
+ * It does this by replacing any `undefined` values with the equivalent default value from the given ARC-56 app spec.
387
+ * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
388
+ * e.g. `my_method` or `my_method(unit64,string)bytes`
389
+ * @param args The arguments to the method with `undefined` for any that should be populated with a default value
390
+ * @param appSpec The app spec for the app
391
+ */
392
+ static getABIArgsWithDefaultValues(methodNameOrSignature, args, appSpec) {
393
+ const m = getArc56Method(methodNameOrSignature, appSpec);
394
+ return args?.map((a, i) => {
395
+ const arg = m.args[i];
396
+ if (a !== undefined) {
397
+ // If a struct then convert to tuple for the underlying call
398
+ return arg.struct && typeof a === 'object' && !Array.isArray(a)
399
+ ? getABITupleFromABIStruct(a, appSpec.structs[arg.struct])
400
+ : a;
401
+ }
402
+ // todo: expand this to match previous ApplicationClient implementation when ARC-56 spec is updated to support other default value options
403
+ const defaultValue = arg.defaultValue;
404
+ if (defaultValue)
405
+ return getABIDecodedValue(Buffer.from(defaultValue, 'base64'), m.method.args[i].type, {});
406
+ throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
407
+ });
408
+ }
409
+ getBareParamsMethods() {
410
+ return {
411
+ /** Return params for an update call, including deploy-time TEAL template replacements and compilation if provided */
412
+ update: async (params) => {
413
+ return this.getBareParams({
414
+ ...params,
415
+ ...(await this.compile(params)),
416
+ }, OnApplicationComplete.UpdateApplicationOC);
417
+ },
418
+ /** Return params for an opt-in call */
419
+ optIn: (params) => {
420
+ return this.getBareParams(params, OnApplicationComplete.OptInOC);
421
+ },
422
+ /** Return params for a delete call */
423
+ delete: (params) => {
424
+ return this.getBareParams(params, OnApplicationComplete.DeleteApplicationOC);
425
+ },
426
+ /** Return params for a clear state call */
427
+ clearState: (params) => {
428
+ return this.getBareParams(params, OnApplicationComplete.ClearStateOC);
429
+ },
430
+ /** Return params for a close out call */
431
+ closeOut: (params) => {
432
+ return this.getBareParams(params, OnApplicationComplete.CloseOutOC);
433
+ },
434
+ /** Return params for a call (defaults to no-op) */
435
+ call: (params) => {
436
+ return this.getBareParams(params, params?.onComplete ?? OnApplicationComplete.NoOpOC);
437
+ },
438
+ };
439
+ }
440
+ getBareTransactionsMethods() {
441
+ return {
442
+ /** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
443
+ update: async (params) => {
444
+ return this._algorand.transactions.appUpdate(await this.params.bare.update(params));
445
+ },
446
+ /** Returns a transaction for an opt-in call */
447
+ optIn: (params) => {
448
+ return this._algorand.transactions.appCall(this.params.bare.optIn(params));
449
+ },
450
+ /** Returns a transaction for a delete call */
451
+ delete: (params) => {
452
+ return this._algorand.transactions.appDelete(this.params.bare.delete(params));
453
+ },
454
+ /** Returns a transaction for a clear state call */
455
+ clearState: (params) => {
456
+ return this._algorand.transactions.appCall(this.params.bare.clearState(params));
457
+ },
458
+ /** Returns a transaction for a close out call */
459
+ closeOut: (params) => {
460
+ return this._algorand.transactions.appCall(this.params.bare.closeOut(params));
461
+ },
462
+ /** Returns a transaction for a call (defaults to no-op) */
463
+ call: (params) => {
464
+ return this._algorand.transactions.appCall(this.params.bare.call(params));
465
+ },
466
+ };
467
+ }
468
+ getBareSendMethods() {
469
+ return {
470
+ /** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */
471
+ update: async (params) => {
472
+ return await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)));
473
+ },
474
+ /** Signs and sends an opt-in call */
475
+ optIn: (params) => {
476
+ return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.optIn(params)));
477
+ },
478
+ /** Signs and sends a delete call */
479
+ delete: (params) => {
480
+ return this.handleCallErrors(() => this._algorand.send.appDelete(this.params.bare.delete(params)));
481
+ },
482
+ /** Signs and sends a clear state call */
483
+ clearState: (params) => {
484
+ return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.clearState(params)));
485
+ },
486
+ /** Signs and sends a close out call */
487
+ closeOut: (params) => {
488
+ return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.closeOut(params)));
489
+ },
490
+ /** Signs and sends a call (defaults to no-op) */
491
+ call: (params) => {
492
+ return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.call(params)));
493
+ },
494
+ };
495
+ }
496
+ getMethodCallParamsMethods() {
497
+ return {
498
+ /** Return params for a payment transaction to fund the app account */
499
+ fundAppAccount: (params) => {
500
+ return {
501
+ ...params,
502
+ sender: this.getSender(params.sender),
503
+ receiver: this.appAddress,
504
+ };
505
+ },
506
+ /** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
507
+ update: async (params) => {
508
+ return this.getABIParams({
509
+ ...params,
510
+ ...(await this.compile(params)),
511
+ }, OnApplicationComplete.UpdateApplicationOC);
512
+ },
513
+ /** Return params for an opt-in ABI call */
514
+ optIn: (params) => {
515
+ return this.getABIParams(params, OnApplicationComplete.OptInOC);
516
+ },
517
+ /** Return params for an delete ABI call */
518
+ delete: (params) => {
519
+ return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
520
+ },
521
+ /** Return params for an close out ABI call */
522
+ closeOut: (params) => {
523
+ return this.getABIParams(params, OnApplicationComplete.CloseOutOC);
524
+ },
525
+ /** Return params for an ABI call */
526
+ call: (params) => {
527
+ return this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC);
528
+ },
529
+ };
530
+ }
531
+ getMethodCallSendMethods() {
532
+ return {
533
+ /** Sign and send transactions for a payment transaction to fund the app account */
534
+ fundAppAccount: (params) => {
535
+ return this._algorand.send.payment(this.params.fundAppAccount(params));
536
+ },
537
+ /**
538
+ * Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
539
+ */
540
+ update: async (params) => {
541
+ const compiled = await this.compile(params);
542
+ return {
543
+ ...(await this.handleCallErrors(async () => this.parseMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), getArc56Method(params.method, this._appSpec)))),
544
+ ...compiled,
545
+ };
546
+ },
547
+ /**
548
+ * Sign and send transactions for an opt-in ABI call
549
+ */
550
+ optIn: (params) => {
551
+ return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
552
+ },
553
+ /**
554
+ * Sign and send transactions for a delete ABI call
555
+ */
556
+ delete: (params) => {
557
+ return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appDeleteMethodCall(this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
558
+ },
559
+ /**
560
+ * Sign and send transactions for a close out ABI call
561
+ */
562
+ closeOut: (params) => {
563
+ return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
564
+ },
565
+ /**
566
+ * Sign and send transactions for a call (defaults to no-op)
567
+ */
568
+ call: async (params) => {
569
+ // Read-only call - do it via simulate
570
+ if (params.onComplete === OnApplicationComplete.NoOpOC ||
571
+ (!params.onComplete && getArc56Method(params.method, this._appSpec).method.readonly)) {
572
+ const result = await this._algorand.newGroup().addAppCallMethodCall(this.params.call(params)).simulate();
573
+ return this.parseMethodCallReturn({
574
+ ...result,
575
+ transaction: result.transactions.at(-1),
576
+ confirmation: result.confirmations.at(-1),
577
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
578
+ return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
579
+ }, getArc56Method(params.method, this._appSpec));
580
+ }
581
+ return this.handleCallErrors(() => this.parseMethodCallReturn(this._algorand.send.appCallMethodCall(this.params.call(params)), getArc56Method(params.method, this._appSpec)));
582
+ },
583
+ };
584
+ }
585
+ getMethodCallTransactionsMethods() {
586
+ return {
587
+ /** Return transaction for a payment transaction to fund the app account */
588
+ fundAppAccount: (params) => {
589
+ return this._algorand.transactions.payment(this.params.fundAppAccount(params));
590
+ },
591
+ /**
592
+ * Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
593
+ */
594
+ update: async (params) => {
595
+ return this._algorand.transactions.appUpdateMethodCall(await this.params.update(params));
596
+ },
597
+ /**
598
+ * Return transactions for an opt-in ABI call
599
+ */
600
+ optIn: (params) => {
601
+ return this._algorand.transactions.appCallMethodCall(this.params.optIn(params));
602
+ },
603
+ /**
604
+ * Return transactions for a delete ABI call
605
+ */
606
+ delete: (params) => {
607
+ return this._algorand.transactions.appDeleteMethodCall(this.params.delete(params));
608
+ },
609
+ /**
610
+ * Return transactions for a close out ABI call
611
+ */
612
+ closeOut: (params) => {
613
+ return this._algorand.transactions.appCallMethodCall(this.params.closeOut(params));
614
+ },
615
+ /**
616
+ * Return transactions for an ABI call (defaults to no-op)
617
+ */
618
+ call: (params) => {
619
+ return this._algorand.transactions.appCallMethodCall(this.params.call(params));
620
+ },
621
+ };
622
+ }
623
+ /**
624
+ * Compiles the approval and clear state programs (if TEAL templates provided),
625
+ * performing any provided deploy-time parameter replacement and stores
626
+ * the source maps.
627
+ *
628
+ * If no TEAL templates provided it will use any byte code provided in the app spec.
629
+ *
630
+ * Will store any generated source maps for later use in debugging.
631
+ */
632
+ async compile(compilation) {
633
+ const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
634
+ if (result.compiledApproval) {
635
+ this._approvalSourceMap = result.compiledApproval.sourceMap;
636
+ }
637
+ if (result.compiledClear) {
638
+ this._clearSourceMap = result.compiledClear.sourceMap;
639
+ }
640
+ return result;
641
+ }
642
+ /** Returns the sender for a call, using the `defaultSender`
643
+ * if none provided and throws an error if neither provided */
644
+ getSender(sender) {
645
+ if (!sender && !this._defaultSender) {
646
+ throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`);
647
+ }
648
+ return sender ?? this._defaultSender;
649
+ }
650
+ getBareParams(params, onComplete) {
651
+ return {
652
+ ...params,
653
+ appId: this._appId,
654
+ sender: this.getSender(params?.sender),
655
+ onComplete,
656
+ };
657
+ }
658
+ getABIParams(params, onComplete) {
659
+ const method = getArc56Method(params.method, this._appSpec);
660
+ const args = AppClient.getABIArgsWithDefaultValues(params.method, params.args, this._appSpec);
661
+ return {
662
+ ...params,
663
+ appId: this._appId,
664
+ sender: this.getSender(params.sender),
665
+ method,
666
+ onComplete,
667
+ args,
668
+ };
669
+ }
670
+ /** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */
671
+ async handleCallErrors(call) {
672
+ try {
673
+ return await call();
674
+ }
675
+ catch (e) {
676
+ throw this.exposeLogicError(e);
677
+ }
678
+ }
679
+ getBoxMethods() {
680
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
681
+ const that = this;
682
+ const stateMethods = {
683
+ /**
684
+ * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.
685
+ */
686
+ getAll: async () => {
687
+ return Object.fromEntries(await Promise.all(Object.keys(that._appSpec.state.keys.box).map(async (key) => [key, await stateMethods.getValue(key)])));
688
+ },
689
+ /**
690
+ * Returns a single state value for the current app with the value a decoded ABI value.
691
+ * @param name The name of the state value to retrieve the value for
692
+ * @returns
693
+ */
694
+ getValue: async (name) => {
695
+ const metadata = that._appSpec.state.keys.box[name];
696
+ const value = await that.getBoxValue(Buffer.from(metadata.key, 'base64'));
697
+ return getABIDecodedValue(value, metadata.valueType, that._appSpec.structs);
698
+ },
699
+ /**
700
+ *
701
+ * @param mapName The name of the map to read from
702
+ * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value
703
+ * that will be converted to bytes by encoding it using the specified ABI key type
704
+ * in the ARC-56 spec
705
+ */
706
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
707
+ getMapValue: async (mapName, key) => {
708
+ const metadata = that._appSpec.state.maps.box[mapName];
709
+ const prefix = Buffer.from(metadata.prefix ?? '', 'base64');
710
+ const encodedKey = Buffer.concat([prefix, getABIEncodedValue(key, metadata.keyType, that._appSpec.structs)]);
711
+ const base64Key = Buffer.from(encodedKey).toString('base64');
712
+ const value = await that.getBoxValue(Buffer.from(base64Key, 'base64'));
713
+ return getABIDecodedValue(value, metadata.valueType, that._appSpec.structs);
714
+ },
715
+ /**
716
+ *
717
+ * @param mapName The name of the map to read from
718
+ * @param key The key within the map as either a Buffer with the bytes or a value
719
+ * that will be converted to bytes by encoding it using the specified ABI key type
720
+ * in the ARC-56 spec
721
+ * @param appState
722
+ */
723
+ getMap: async (mapName) => {
724
+ const metadata = that._appSpec.state.maps.box[mapName];
725
+ const prefix = Buffer.from(metadata.prefix ?? '', 'base64');
726
+ const boxNames = await that.getBoxNames();
727
+ return new Map(await Promise.all(boxNames
728
+ .filter((b) => binaryStartsWith(b.nameRaw, prefix))
729
+ .map(async (b) => {
730
+ const encodedKey = Buffer.concat([prefix, b.nameRaw]);
731
+ const base64Key = Buffer.from(encodedKey).toString('base64');
732
+ return [
733
+ getABIDecodedValue(b.nameRaw.slice(prefix.length), metadata.keyType, that._appSpec.structs),
734
+ getABIDecodedValue(await that.getBoxValue(Buffer.from(base64Key, 'base64')), metadata.valueType, that._appSpec.structs),
735
+ ];
736
+ })));
737
+ },
738
+ };
739
+ return stateMethods;
740
+ }
741
+ getStateMethods(stateGetter, keyGetter, mapGetter) {
742
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
743
+ const that = this;
744
+ const stateMethods = {
745
+ /**
746
+ * Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.
747
+ */
748
+ getAll: async () => {
749
+ const appState = await stateGetter();
750
+ return Object.fromEntries(await Promise.all(Object.keys(keyGetter()).map(async (key) => [key, await stateMethods.getValue(key, appState)])));
751
+ },
752
+ /**
753
+ * Returns a single state value for the current app with the value a decoded ABI value.
754
+ * @param name The name of the state value to retrieve the value for
755
+ * @param appState Optional cached value of the current state
756
+ * @returns
757
+ */
758
+ getValue: async (name, appState) => {
759
+ const state = Object.values(appState ?? (await stateGetter()));
760
+ const metadata = keyGetter()[name];
761
+ const value = state.find((s) => s.keyBase64 === metadata.key);
762
+ if (value && 'valueRaw' in value) {
763
+ return getABIDecodedValue(value.valueRaw, metadata.valueType, that._appSpec.structs);
764
+ }
765
+ return value?.value;
766
+ },
767
+ /**
768
+ * Returns a single value from the given map for the current app with the value a decoded ABI value.
769
+ * @param mapName The name of the map to read from
770
+ * @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value
771
+ * that will be converted to bytes by encoding it using the specified ABI key type
772
+ * in the ARC-56 spec
773
+ * @param appState Optional cached value of the current state
774
+ */
775
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
776
+ getMapValue: async (mapName, key, appState) => {
777
+ const state = Object.values(appState ?? (await stateGetter()));
778
+ const metadata = mapGetter()[mapName];
779
+ const prefix = Buffer.from(metadata.prefix ?? '', 'base64');
780
+ const encodedKey = Buffer.concat([prefix, getABIEncodedValue(key, metadata.keyType, that._appSpec.structs)]);
781
+ const base64Key = Buffer.from(encodedKey).toString('base64');
782
+ const value = state.find((s) => s.keyBase64 === base64Key);
783
+ if (value && 'valueRaw' in value) {
784
+ return getABIDecodedValue(value.valueRaw, metadata.valueType, that._appSpec.structs);
785
+ }
786
+ return value?.value;
787
+ },
788
+ /**
789
+ * Returns all map values for the given map.
790
+ * @param mapName The name of the map to read from
791
+ * @param appState Optional cached value of the current state
792
+ * @returns A map of all key-value pairs in the map as a `Record<string, ABIValue>`
793
+ */
794
+ getMap: async (mapName) => {
795
+ const state = Object.values(await stateGetter());
796
+ const metadata = mapGetter()[mapName];
797
+ const prefix = Buffer.from(metadata.prefix ?? '', 'base64');
798
+ return new Map(state
799
+ .filter((s) => binaryStartsWith(s.keyRaw, prefix))
800
+ .map((s) => {
801
+ const key = s.keyRaw.slice(prefix.length);
802
+ return [
803
+ getABIDecodedValue(key, metadata.keyType, this._appSpec.structs),
804
+ getABIDecodedValue('valueRaw' in s ? s.valueRaw : s.value, metadata.valueType, this._appSpec.structs),
805
+ ];
806
+ }));
807
+ },
808
+ };
809
+ return stateMethods;
810
+ }
811
+ }
812
+ /**
813
+ * @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
814
+ * `algorand.client.getAppClientByCreatorAndName`.
815
+ * If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
816
+ * which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
817
+ *
818
+ * Application client - a class that wraps an ARC-0032 app spec and provides high productivity methods to deploy and call the app */
41
819
  class ApplicationClient {
42
- // todo: process ABI args as needed to make them nicer to deal with like beaker-ts
43
- // todo: support readonly, noop method calls
44
- // todo: find create, update, delete, etc. methods from app spec and call them by default
45
- // todo: intelligent version management when deploying
46
820
  /**
821
+ * @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
822
+ * `algorand.client.getAppClientByCreatorAndName`.
823
+ * If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
824
+ * which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
825
+ *
47
826
  * Create a new ApplicationClient instance
48
827
  * @param appDetails The details of the app
49
828
  * @param algod An algod instance
@@ -78,9 +857,11 @@ class ApplicationClient {
78
857
  this.params = params;
79
858
  }
80
859
  /**
81
- * Compiles the approval and clear programs and sets up the source map.
860
+ * @deprecated Use `AppClient.compile()` instead.
861
+ *
862
+ * Compiles the approval and clear state programs and sets up the source map.
82
863
  * @param compilation The deploy-time parameters for the compilation
83
- * @returns The compiled approval and clear programs
864
+ * @returns The compiled approval and clear state programs
84
865
  */
85
866
  async compile(compilation) {
86
867
  const { deployTimeParams, updatable, deletable } = compilation ?? {};
@@ -102,7 +883,7 @@ class ApplicationClient {
102
883
  PersistSourceMapInput.fromCompiledTeal(clearCompiled, this._appName, 'clear.teal'),
103
884
  ],
104
885
  projectRoot: Config.projectRoot,
105
- client: this.algod,
886
+ appManager: new AppManager(this.algod),
106
887
  withSources: true,
107
888
  });
108
889
  }
@@ -130,6 +911,8 @@ class ApplicationClient {
130
911
  this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
131
912
  }
132
913
  /**
914
+ * @deprecated Use `deploy` from an `AppFactory` instance instead.
915
+ *
133
916
  * Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
134
917
  *
135
918
  * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
@@ -215,6 +998,8 @@ class ApplicationClient {
215
998
  }
216
999
  }
217
1000
  /**
1001
+ * @deprecated Use `create` from an `AppFactory` instance instead.
1002
+ *
218
1003
  * Creates a smart contract app, returns the details of the created app.
219
1004
  * @param create The parameters to create the app with
220
1005
  * @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
@@ -259,6 +1044,8 @@ class ApplicationClient {
259
1044
  }
260
1045
  }
261
1046
  /**
1047
+ * @deprecated Use `appClient.send.update` or `appClient.transactions.update` from an `AppClient` instance instead.
1048
+ *
262
1049
  * Updates the smart contract app.
263
1050
  * @param update The parameters to update the app with
264
1051
  * @returns The transaction send result and the compilation result
@@ -291,6 +1078,8 @@ class ApplicationClient {
291
1078
  }
292
1079
  }
293
1080
  /**
1081
+ * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1082
+ *
294
1083
  * Issues a no_op (normal) call to the app.
295
1084
  * @param call The call details.
296
1085
  * @returns The result of the call
@@ -324,6 +1113,8 @@ class ApplicationClient {
324
1113
  return await this.callOfType(call, 'no_op');
325
1114
  }
326
1115
  /**
1116
+ * @deprecated Use `appClient.send.optIn` or `appClient.transactions.optIn` from an `AppClient` instance instead.
1117
+ *
327
1118
  * Issues a opt_in call to the app.
328
1119
  * @param call The call details.
329
1120
  * @returns The result of the call
@@ -332,6 +1123,8 @@ class ApplicationClient {
332
1123
  return await this.callOfType(call, 'opt_in');
333
1124
  }
334
1125
  /**
1126
+ * @deprecated Use `appClient.send.closeOut` or `appClient.transactions.closeOut` from an `AppClient` instance instead.
1127
+ *
335
1128
  * Issues a close_out call to the app.
336
1129
  * @param call The call details.
337
1130
  * @returns The result of the call
@@ -340,6 +1133,8 @@ class ApplicationClient {
340
1133
  return await this.callOfType(call, 'close_out');
341
1134
  }
342
1135
  /**
1136
+ * @deprecated Use `appClient.send.clearState` or `appClient.transactions.clearState` from an `AppClient` instance instead.
1137
+ *
343
1138
  * Issues a clear_state call to the app.
344
1139
  * @param call The call details.
345
1140
  * @returns The result of the call
@@ -348,6 +1143,8 @@ class ApplicationClient {
348
1143
  return await this.callOfType(call, 'clear_state');
349
1144
  }
350
1145
  /**
1146
+ * @deprecated Use `appClient.send.delete` or `appClient.transactions.delete` from an `AppClient` instance instead.
1147
+ *
351
1148
  * Issues a delete_application call to the app.
352
1149
  * @param call The call details.
353
1150
  * @returns The result of the call
@@ -356,6 +1153,8 @@ class ApplicationClient {
356
1153
  return await this.callOfType(call, 'delete_application');
357
1154
  }
358
1155
  /**
1156
+ * @deprecated Use `appClient.send.call` or `appClient.transactions.call` from an `AppClient` instance instead.
1157
+ *
359
1158
  * Issues a call to the app with the given call type.
360
1159
  * @param call The call details.
361
1160
  * @param callType The call type
@@ -498,6 +1297,8 @@ class ApplicationClient {
498
1297
  })));
499
1298
  }
500
1299
  /**
1300
+ * @deprecated Use `appClient.params.*` from an `AppClient` instance instead.
1301
+ *
501
1302
  * Returns the arguments for an app call for the given ABI method or raw method specification.
502
1303
  * @param args The call args specific to this application client
503
1304
  * @param sender The sender of this call. Will be used to fetch any default argument values if applicable
@@ -555,6 +1356,8 @@ class ApplicationClient {
555
1356
  }
556
1357
  }
557
1358
  /**
1359
+ * @deprecated Use `appClient.getABIMethod` instead.
1360
+ *
558
1361
  * Returns the ABI Method parameters for the given method name string for the app represented by this application client instance
559
1362
  * @param method Either the name of the method or the ABI method spec definition string
560
1363
  * @returns The ABI method params for the given method
@@ -581,6 +1384,8 @@ class ApplicationClient {
581
1384
  return methodParams ? new ABIMethod(methodParams) : undefined;
582
1385
  }
583
1386
  /**
1387
+ * @deprecated Use `appClient.appId` and `appClient.appAddress` from an `AppClient` instance instead.
1388
+ *
584
1389
  * Gets the reference information for the current application instance.
585
1390
  * `appId` will be 0 if it can't find an app.
586
1391
  * @returns The app reference, or if deployed using the `deploy` method, the app metadata too
@@ -631,5 +1436,5 @@ class ApplicationClient {
631
1436
  }
632
1437
  }
633
1438
 
634
- export { ApplicationClient };
1439
+ export { AppClient, ApplicationClient };
635
1440
  //# sourceMappingURL=app-client.mjs.map