@algorandfoundation/algokit-utils 7.0.0-beta.6 → 7.0.0-beta.8
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/app.d.ts +6 -6
- package/app.js +6 -6
- package/app.js.map +1 -1
- package/app.mjs +6 -6
- package/app.mjs.map +1 -1
- package/asset.d.ts +3 -3
- package/asset.js +3 -3
- package/asset.js.map +1 -1
- package/asset.mjs +3 -3
- package/asset.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/fixtures/algorand-fixture.js +1 -1
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/transaction/legacy-bridge.d.ts +3 -3
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/transaction.d.ts +1 -3
- package/transaction/transaction.js +17 -11
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +17 -11
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +1 -1
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -1
- package/transfer/transfer.js +1 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +1 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +13 -4
- package/types/account-manager.js +17 -3
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +17 -3
- package/types/account-manager.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +1 -1
- package/types/algorand-client-transaction-creator.d.ts +30 -30
- package/types/algorand-client-transaction-creator.js +30 -30
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +30 -30
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +18 -18
- package/types/algorand-client-transaction-sender.js +1 -1
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +1 -1
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +8 -8
- package/types/algorand-client.js +8 -8
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +8 -8
- package/types/algorand-client.mjs.map +1 -1
- package/types/app-arc56.d.ts +60 -37
- package/types/app-arc56.js +37 -16
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +37 -16
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +123 -132
- package/types/app-client.js +165 -94
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +165 -94
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +2 -2
- package/types/app-deployer.js +24 -24
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +24 -24
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +116 -246
- package/types/app-factory.js +120 -39
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +121 -40
- package/types/app-factory.mjs.map +1 -1
- package/types/app-spec.js +15 -9
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +15 -9
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +3 -3
- package/types/asset-manager.js +2 -2
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +2 -2
- package/types/asset-manager.mjs.map +1 -1
- package/types/client-manager.d.ts +30 -8
- package/types/client-manager.js +6 -0
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +6 -0
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +29 -4
- package/types/composer.js +24 -7
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +24 -7
- package/types/composer.mjs.map +1 -1
- package/types/kmd-account-manager.js +1 -1
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +1 -1
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/transaction.d.ts +4 -6
package/types/app-client.mjs
CHANGED
|
@@ -57,10 +57,19 @@ class AppClient {
|
|
|
57
57
|
this._boxStateMethods = this.getBoxMethods();
|
|
58
58
|
this._paramsMethods = {
|
|
59
59
|
...this.getMethodCallParamsMethods(),
|
|
60
|
+
/** Get parameters to define bare (raw) transactions to the current app */
|
|
60
61
|
bare: this.getBareParamsMethods(),
|
|
61
62
|
};
|
|
62
|
-
this.
|
|
63
|
-
|
|
63
|
+
this._createTransactionsMethods = {
|
|
64
|
+
...this.getMethodCallCreateTransactionMethods(),
|
|
65
|
+
/** Get transactions for bare (raw) calls to the current app */
|
|
66
|
+
bare: this.getBareCreateTransactionMethods(),
|
|
67
|
+
};
|
|
68
|
+
this._sendMethods = {
|
|
69
|
+
...this.getMethodCallSendMethods(),
|
|
70
|
+
/** Send bare (raw) transactions to the current app */
|
|
71
|
+
bare: this.getBareSendMethods(),
|
|
72
|
+
};
|
|
64
73
|
}
|
|
65
74
|
/** Start a new `AlgoKitComposer` transaction group */
|
|
66
75
|
newGroup() {
|
|
@@ -136,18 +145,33 @@ class AppClient {
|
|
|
136
145
|
get appSpec() {
|
|
137
146
|
return this._appSpec;
|
|
138
147
|
}
|
|
139
|
-
/** Get parameters to
|
|
148
|
+
/** Get parameters to create transactions for the current app.
|
|
149
|
+
*
|
|
150
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
151
|
+
* @example Create a transaction in the future using Algorand Client
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
154
|
+
* // ...
|
|
155
|
+
* await algorand.send.AppMethodCall(myMethodCall)
|
|
156
|
+
* ```
|
|
157
|
+
* @example Define a nested transaction as an ABI argument
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
160
|
+
* await appClient.send.call({method: 'my_method2', args: [myMethodCall]})
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
140
163
|
get params() {
|
|
141
164
|
return this._paramsMethods;
|
|
142
165
|
}
|
|
143
|
-
/**
|
|
144
|
-
get
|
|
145
|
-
return this.
|
|
166
|
+
/** Create transactions for the current app */
|
|
167
|
+
get createTransaction() {
|
|
168
|
+
return this._createTransactionsMethods;
|
|
146
169
|
}
|
|
147
|
-
/** Send
|
|
170
|
+
/** Send transactions to the current app */
|
|
148
171
|
get send() {
|
|
149
172
|
return this._sendMethods;
|
|
150
173
|
}
|
|
174
|
+
/** Get state (local, global, box) from the current app */
|
|
151
175
|
get state() {
|
|
152
176
|
return {
|
|
153
177
|
/**
|
|
@@ -167,6 +191,8 @@ class AppClient {
|
|
|
167
191
|
}
|
|
168
192
|
/**
|
|
169
193
|
* Funds Algo into the app account for this app.
|
|
194
|
+
*
|
|
195
|
+
* An alias for `appClient.send.fundAppAccount(params)`.
|
|
170
196
|
* @param params The parameters for the funding transaction
|
|
171
197
|
* @returns The result of the funding
|
|
172
198
|
*/
|
|
@@ -279,7 +305,7 @@ class AppClient {
|
|
|
279
305
|
this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
|
|
280
306
|
}
|
|
281
307
|
/**
|
|
282
|
-
* Returns the ABI Method for the given method
|
|
308
|
+
* Returns the ABI Method spec for the given method string for the app represented by this application client instance
|
|
283
309
|
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
284
310
|
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
285
311
|
* @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
|
|
@@ -289,18 +315,37 @@ class AppClient {
|
|
|
289
315
|
}
|
|
290
316
|
/**
|
|
291
317
|
* Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
|
|
292
|
-
* on the ARC-56 method.
|
|
318
|
+
* on the ARC-56 method, replacing the `return` property with the decoded type.
|
|
293
319
|
*
|
|
294
|
-
* If the return type is
|
|
320
|
+
* If the return type is an ARC-56 struct then the struct will be returned.
|
|
295
321
|
*
|
|
296
322
|
* @param result The SendAppTransactionResult to be mapped
|
|
297
323
|
* @param method The method that was called
|
|
298
324
|
* @returns The smart contract response with an updated return value
|
|
299
325
|
*/
|
|
300
|
-
async
|
|
326
|
+
async processMethodCallReturn(result, method) {
|
|
301
327
|
const resultValue = await result;
|
|
302
328
|
return { ...resultValue, return: getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
|
|
303
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
332
|
+
* performing any provided deploy-time parameter replacement and stores
|
|
333
|
+
* the source maps.
|
|
334
|
+
*
|
|
335
|
+
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
336
|
+
*
|
|
337
|
+
* Will store any generated source maps for later use in debugging.
|
|
338
|
+
*/
|
|
339
|
+
async compile(compilation) {
|
|
340
|
+
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
341
|
+
if (result.approvalProgramCompilationResult) {
|
|
342
|
+
this._approvalSourceMap = result.approvalProgramCompilationResult.sourceMap;
|
|
343
|
+
}
|
|
344
|
+
if (result.clearStateProgramCompilationResult) {
|
|
345
|
+
this._clearSourceMap = result.clearStateProgramCompilationResult.sourceMap;
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
304
349
|
/**
|
|
305
350
|
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
306
351
|
* error to include source code information via the source map and ARC-56 spec.
|
|
@@ -353,25 +398,25 @@ class AppClient {
|
|
|
353
398
|
};
|
|
354
399
|
}
|
|
355
400
|
const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
356
|
-
const
|
|
401
|
+
const approvalProgramCompilationResult = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {
|
|
357
402
|
updatable,
|
|
358
403
|
deletable,
|
|
359
404
|
});
|
|
360
405
|
const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
|
|
361
|
-
const
|
|
406
|
+
const clearStateProgramCompilationResult = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
|
|
362
407
|
if (Config.debug) {
|
|
363
408
|
await Config.events.emitAsync(EventType.AppCompiled, {
|
|
364
409
|
sources: [
|
|
365
|
-
{ compiledTeal:
|
|
366
|
-
{ compiledTeal:
|
|
410
|
+
{ compiledTeal: approvalProgramCompilationResult, appName: appSpec.name, fileName: 'approval' },
|
|
411
|
+
{ compiledTeal: clearStateProgramCompilationResult, appName: appSpec.name, fileName: 'clear' },
|
|
367
412
|
],
|
|
368
413
|
});
|
|
369
414
|
}
|
|
370
415
|
return {
|
|
371
|
-
approvalProgram:
|
|
372
|
-
|
|
373
|
-
clearStateProgram:
|
|
374
|
-
|
|
416
|
+
approvalProgram: approvalProgramCompilationResult.compiledBase64ToBytes,
|
|
417
|
+
approvalProgramCompilationResult,
|
|
418
|
+
clearStateProgram: clearStateProgramCompilationResult.compiledBase64ToBytes,
|
|
419
|
+
clearStateProgramCompilationResult,
|
|
375
420
|
};
|
|
376
421
|
}
|
|
377
422
|
/**
|
|
@@ -382,24 +427,53 @@ class AppClient {
|
|
|
382
427
|
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
383
428
|
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
384
429
|
* @param args The arguments to the method with `undefined` for any that should be populated with a default value
|
|
385
|
-
* @param appSpec The app spec for the app
|
|
386
430
|
*/
|
|
387
|
-
|
|
388
|
-
const m = getArc56Method(methodNameOrSignature,
|
|
389
|
-
return args?.map((a, i) => {
|
|
431
|
+
async getABIArgsWithDefaultValues(methodNameOrSignature, args, sender) {
|
|
432
|
+
const m = getArc56Method(methodNameOrSignature, this._appSpec);
|
|
433
|
+
return await Promise.all(args?.map(async (a, i) => {
|
|
390
434
|
const arg = m.args[i];
|
|
391
435
|
if (a !== undefined) {
|
|
392
436
|
// If a struct then convert to tuple for the underlying call
|
|
393
437
|
return arg.struct && typeof a === 'object' && !Array.isArray(a)
|
|
394
|
-
? getABITupleFromABIStruct(a,
|
|
438
|
+
? getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
|
|
395
439
|
: a;
|
|
396
440
|
}
|
|
397
|
-
// todo: expand this to match previous ApplicationClient implementation when ARC-56 spec is updated to support other default value options
|
|
398
441
|
const defaultValue = arg.defaultValue;
|
|
399
|
-
if (defaultValue)
|
|
400
|
-
|
|
442
|
+
if (defaultValue) {
|
|
443
|
+
switch (defaultValue.source) {
|
|
444
|
+
case 'literal':
|
|
445
|
+
if (typeof defaultValue.data === 'number')
|
|
446
|
+
return defaultValue.data;
|
|
447
|
+
return getABIDecodedValue(Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
448
|
+
// todo: When ARC-56 supports ABI calls as default args
|
|
449
|
+
// case 'abi': {
|
|
450
|
+
// const method = this.getABIMethod(defaultValue.data as string)
|
|
451
|
+
// const result = await this.send.call({
|
|
452
|
+
// method: defaultValue.data as string,
|
|
453
|
+
// methodArgs: method.args.map(() => undefined),
|
|
454
|
+
// sender,
|
|
455
|
+
// })
|
|
456
|
+
// return result.return!
|
|
457
|
+
// }
|
|
458
|
+
case 'local':
|
|
459
|
+
case 'global': {
|
|
460
|
+
const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
|
|
461
|
+
const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data);
|
|
462
|
+
if (!value) {
|
|
463
|
+
throw new Error(`Preparing default value for argument ${arg.name ?? `arg${i + 1}`} resulted in the failure: The key '${defaultValue.data}' could not be found in ${defaultValue.source} storage`);
|
|
464
|
+
}
|
|
465
|
+
return 'valueRaw' in value
|
|
466
|
+
? getABIDecodedValue(value.valueRaw, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs)
|
|
467
|
+
: value.value;
|
|
468
|
+
}
|
|
469
|
+
case 'box': {
|
|
470
|
+
const value = await this.getBoxValue(Buffer.from(defaultValue.data, 'base64'));
|
|
471
|
+
return getABIDecodedValue(value, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
401
475
|
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
402
|
-
});
|
|
476
|
+
}) ?? []);
|
|
403
477
|
}
|
|
404
478
|
getBareParamsMethods() {
|
|
405
479
|
return {
|
|
@@ -432,31 +506,31 @@ class AppClient {
|
|
|
432
506
|
},
|
|
433
507
|
};
|
|
434
508
|
}
|
|
435
|
-
|
|
509
|
+
getBareCreateTransactionMethods() {
|
|
436
510
|
return {
|
|
437
511
|
/** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
438
512
|
update: async (params) => {
|
|
439
|
-
return this._algorand.
|
|
513
|
+
return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params));
|
|
440
514
|
},
|
|
441
515
|
/** Returns a transaction for an opt-in call */
|
|
442
516
|
optIn: (params) => {
|
|
443
|
-
return this._algorand.
|
|
517
|
+
return this._algorand.createTransaction.appCall(this.params.bare.optIn(params));
|
|
444
518
|
},
|
|
445
519
|
/** Returns a transaction for a delete call */
|
|
446
520
|
delete: (params) => {
|
|
447
|
-
return this._algorand.
|
|
521
|
+
return this._algorand.createTransaction.appDelete(this.params.bare.delete(params));
|
|
448
522
|
},
|
|
449
523
|
/** Returns a transaction for a clear state call */
|
|
450
524
|
clearState: (params) => {
|
|
451
|
-
return this._algorand.
|
|
525
|
+
return this._algorand.createTransaction.appCall(this.params.bare.clearState(params));
|
|
452
526
|
},
|
|
453
527
|
/** Returns a transaction for a close out call */
|
|
454
528
|
closeOut: (params) => {
|
|
455
|
-
return this._algorand.
|
|
529
|
+
return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params));
|
|
456
530
|
},
|
|
457
531
|
/** Returns a transaction for a call (defaults to no-op) */
|
|
458
532
|
call: (params) => {
|
|
459
|
-
return this._algorand.
|
|
533
|
+
return this._algorand.createTransaction.appCall(this.params.bare.call(params));
|
|
460
534
|
},
|
|
461
535
|
};
|
|
462
536
|
}
|
|
@@ -464,7 +538,14 @@ class AppClient {
|
|
|
464
538
|
return {
|
|
465
539
|
/** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
466
540
|
update: async (params) => {
|
|
467
|
-
|
|
541
|
+
const compiled = await this.compile(params);
|
|
542
|
+
return {
|
|
543
|
+
...(await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)))),
|
|
544
|
+
...{
|
|
545
|
+
compiledApproval: compiled.approvalProgramCompilationResult,
|
|
546
|
+
compiledClear: compiled.clearStateProgramCompilationResult,
|
|
547
|
+
},
|
|
548
|
+
};
|
|
468
549
|
},
|
|
469
550
|
/** Signs and sends an opt-in call */
|
|
470
551
|
optIn: (params) => {
|
|
@@ -500,26 +581,26 @@ class AppClient {
|
|
|
500
581
|
},
|
|
501
582
|
/** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
|
|
502
583
|
update: async (params) => {
|
|
503
|
-
return this.getABIParams({
|
|
584
|
+
return (await this.getABIParams({
|
|
504
585
|
...params,
|
|
505
586
|
...(await this.compile(params)),
|
|
506
|
-
}, OnApplicationComplete.UpdateApplicationOC);
|
|
587
|
+
}, OnApplicationComplete.UpdateApplicationOC));
|
|
507
588
|
},
|
|
508
589
|
/** Return params for an opt-in ABI call */
|
|
509
|
-
optIn: (params) => {
|
|
510
|
-
return this.getABIParams(params, OnApplicationComplete.OptInOC);
|
|
590
|
+
optIn: async (params) => {
|
|
591
|
+
return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
|
|
511
592
|
},
|
|
512
593
|
/** Return params for an delete ABI call */
|
|
513
|
-
delete: (params) => {
|
|
514
|
-
return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
|
|
594
|
+
delete: async (params) => {
|
|
595
|
+
return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
|
|
515
596
|
},
|
|
516
597
|
/** Return params for an close out ABI call */
|
|
517
|
-
closeOut: (params) => {
|
|
518
|
-
return this.getABIParams(params, OnApplicationComplete.CloseOutOC);
|
|
598
|
+
closeOut: async (params) => {
|
|
599
|
+
return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
|
|
519
600
|
},
|
|
520
601
|
/** Return params for an ABI call */
|
|
521
|
-
call: (params) => {
|
|
522
|
-
return this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC);
|
|
602
|
+
call: async (params) => {
|
|
603
|
+
return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
|
|
523
604
|
},
|
|
524
605
|
};
|
|
525
606
|
}
|
|
@@ -535,27 +616,30 @@ class AppClient {
|
|
|
535
616
|
update: async (params) => {
|
|
536
617
|
const compiled = await this.compile(params);
|
|
537
618
|
return {
|
|
538
|
-
...(await this.handleCallErrors(async () => this.
|
|
539
|
-
...
|
|
619
|
+
...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), getArc56Method(params.method, this._appSpec)))),
|
|
620
|
+
...{
|
|
621
|
+
compiledApproval: compiled.approvalProgramCompilationResult,
|
|
622
|
+
compiledClear: compiled.clearStateProgramCompilationResult,
|
|
623
|
+
},
|
|
540
624
|
};
|
|
541
625
|
},
|
|
542
626
|
/**
|
|
543
627
|
* Sign and send transactions for an opt-in ABI call
|
|
544
628
|
*/
|
|
545
629
|
optIn: (params) => {
|
|
546
|
-
return this.handleCallErrors(() => this.
|
|
630
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), getArc56Method(params.method, this._appSpec)));
|
|
547
631
|
},
|
|
548
632
|
/**
|
|
549
633
|
* Sign and send transactions for a delete ABI call
|
|
550
634
|
*/
|
|
551
635
|
delete: (params) => {
|
|
552
|
-
return this.handleCallErrors(() => this.
|
|
636
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), getArc56Method(params.method, this._appSpec)));
|
|
553
637
|
},
|
|
554
638
|
/**
|
|
555
639
|
* Sign and send transactions for a close out ABI call
|
|
556
640
|
*/
|
|
557
641
|
closeOut: (params) => {
|
|
558
|
-
return this.handleCallErrors(() => this.
|
|
642
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), getArc56Method(params.method, this._appSpec)));
|
|
559
643
|
},
|
|
560
644
|
/**
|
|
561
645
|
* Sign and send transactions for a call (defaults to no-op)
|
|
@@ -564,8 +648,13 @@ class AppClient {
|
|
|
564
648
|
// Read-only call - do it via simulate
|
|
565
649
|
if (params.onComplete === OnApplicationComplete.NoOpOC ||
|
|
566
650
|
(!params.onComplete && getArc56Method(params.method, this._appSpec).method.readonly)) {
|
|
567
|
-
const result = await this._algorand
|
|
568
|
-
|
|
651
|
+
const result = await this._algorand
|
|
652
|
+
.newGroup()
|
|
653
|
+
.addAppCallMethodCall(await this.params.call(params))
|
|
654
|
+
.simulate({
|
|
655
|
+
allowUnnamedResources: params.populateAppCallResources,
|
|
656
|
+
});
|
|
657
|
+
return this.processMethodCallReturn({
|
|
569
658
|
...result,
|
|
570
659
|
transaction: result.transactions.at(-1),
|
|
571
660
|
confirmation: result.confirmations.at(-1),
|
|
@@ -573,67 +662,48 @@ class AppClient {
|
|
|
573
662
|
return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
|
|
574
663
|
}, getArc56Method(params.method, this._appSpec));
|
|
575
664
|
}
|
|
576
|
-
return this.handleCallErrors(() => this.
|
|
665
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), getArc56Method(params.method, this._appSpec)));
|
|
577
666
|
},
|
|
578
667
|
};
|
|
579
668
|
}
|
|
580
|
-
|
|
669
|
+
getMethodCallCreateTransactionMethods() {
|
|
581
670
|
return {
|
|
582
671
|
/** Return transaction for a payment transaction to fund the app account */
|
|
583
672
|
fundAppAccount: (params) => {
|
|
584
|
-
return this._algorand.
|
|
673
|
+
return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
|
|
585
674
|
},
|
|
586
675
|
/**
|
|
587
676
|
* Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
588
677
|
*/
|
|
589
678
|
update: async (params) => {
|
|
590
|
-
return this._algorand.
|
|
679
|
+
return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
|
|
591
680
|
},
|
|
592
681
|
/**
|
|
593
682
|
* Return transactions for an opt-in ABI call
|
|
594
683
|
*/
|
|
595
|
-
optIn: (params) => {
|
|
596
|
-
return this._algorand.
|
|
684
|
+
optIn: async (params) => {
|
|
685
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
|
|
597
686
|
},
|
|
598
687
|
/**
|
|
599
688
|
* Return transactions for a delete ABI call
|
|
600
689
|
*/
|
|
601
|
-
delete: (params) => {
|
|
602
|
-
return this._algorand.
|
|
690
|
+
delete: async (params) => {
|
|
691
|
+
return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
|
|
603
692
|
},
|
|
604
693
|
/**
|
|
605
694
|
* Return transactions for a close out ABI call
|
|
606
695
|
*/
|
|
607
|
-
closeOut: (params) => {
|
|
608
|
-
return this._algorand.
|
|
696
|
+
closeOut: async (params) => {
|
|
697
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
|
|
609
698
|
},
|
|
610
699
|
/**
|
|
611
700
|
* Return transactions for an ABI call (defaults to no-op)
|
|
612
701
|
*/
|
|
613
|
-
call: (params) => {
|
|
614
|
-
return this._algorand.
|
|
702
|
+
call: async (params) => {
|
|
703
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
|
|
615
704
|
},
|
|
616
705
|
};
|
|
617
706
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
620
|
-
* performing any provided deploy-time parameter replacement and stores
|
|
621
|
-
* the source maps.
|
|
622
|
-
*
|
|
623
|
-
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
624
|
-
*
|
|
625
|
-
* Will store any generated source maps for later use in debugging.
|
|
626
|
-
*/
|
|
627
|
-
async compile(compilation) {
|
|
628
|
-
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
629
|
-
if (result.compiledApproval) {
|
|
630
|
-
this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
631
|
-
}
|
|
632
|
-
if (result.compiledClear) {
|
|
633
|
-
this._clearSourceMap = result.compiledClear.sourceMap;
|
|
634
|
-
}
|
|
635
|
-
return result;
|
|
636
|
-
}
|
|
637
707
|
/** Returns the sender for a call, using the `defaultSender`
|
|
638
708
|
* if none provided and throws an error if neither provided */
|
|
639
709
|
getSender(sender) {
|
|
@@ -650,13 +720,14 @@ class AppClient {
|
|
|
650
720
|
onComplete,
|
|
651
721
|
};
|
|
652
722
|
}
|
|
653
|
-
getABIParams(params, onComplete) {
|
|
723
|
+
async getABIParams(params, onComplete) {
|
|
724
|
+
const sender = this.getSender(params.sender);
|
|
654
725
|
const method = getArc56Method(params.method, this._appSpec);
|
|
655
|
-
const args =
|
|
726
|
+
const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender);
|
|
656
727
|
return {
|
|
657
728
|
...params,
|
|
658
729
|
appId: this._appId,
|
|
659
|
-
sender:
|
|
730
|
+
sender: sender,
|
|
660
731
|
method,
|
|
661
732
|
onComplete,
|
|
662
733
|
args,
|
|
@@ -1036,7 +1107,7 @@ class ApplicationClient {
|
|
|
1036
1107
|
}
|
|
1037
1108
|
}
|
|
1038
1109
|
/**
|
|
1039
|
-
* @deprecated Use `appClient.send.update` or `appClient.
|
|
1110
|
+
* @deprecated Use `appClient.send.update` or `appClient.createTransaction.update` from an `AppClient` instance instead.
|
|
1040
1111
|
*
|
|
1041
1112
|
* Updates the smart contract app.
|
|
1042
1113
|
* @param update The parameters to update the app with
|
|
@@ -1070,7 +1141,7 @@ class ApplicationClient {
|
|
|
1070
1141
|
}
|
|
1071
1142
|
}
|
|
1072
1143
|
/**
|
|
1073
|
-
* @deprecated Use `appClient.send.call` or `appClient.
|
|
1144
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1074
1145
|
*
|
|
1075
1146
|
* Issues a no_op (normal) call to the app.
|
|
1076
1147
|
* @param call The call details.
|
|
@@ -1105,7 +1176,7 @@ class ApplicationClient {
|
|
|
1105
1176
|
return await this.callOfType(call, 'no_op');
|
|
1106
1177
|
}
|
|
1107
1178
|
/**
|
|
1108
|
-
* @deprecated Use `appClient.send.optIn` or `appClient.
|
|
1179
|
+
* @deprecated Use `appClient.send.optIn` or `appClient.createTransaction.optIn` from an `AppClient` instance instead.
|
|
1109
1180
|
*
|
|
1110
1181
|
* Issues a opt_in call to the app.
|
|
1111
1182
|
* @param call The call details.
|
|
@@ -1115,7 +1186,7 @@ class ApplicationClient {
|
|
|
1115
1186
|
return await this.callOfType(call, 'opt_in');
|
|
1116
1187
|
}
|
|
1117
1188
|
/**
|
|
1118
|
-
* @deprecated Use `appClient.send.closeOut` or `appClient.
|
|
1189
|
+
* @deprecated Use `appClient.send.closeOut` or `appClient.createTransaction.closeOut` from an `AppClient` instance instead.
|
|
1119
1190
|
*
|
|
1120
1191
|
* Issues a close_out call to the app.
|
|
1121
1192
|
* @param call The call details.
|
|
@@ -1125,7 +1196,7 @@ class ApplicationClient {
|
|
|
1125
1196
|
return await this.callOfType(call, 'close_out');
|
|
1126
1197
|
}
|
|
1127
1198
|
/**
|
|
1128
|
-
* @deprecated Use `appClient.send.clearState` or `appClient.
|
|
1199
|
+
* @deprecated Use `appClient.send.clearState` or `appClient.createTransaction.clearState` from an `AppClient` instance instead.
|
|
1129
1200
|
*
|
|
1130
1201
|
* Issues a clear_state call to the app.
|
|
1131
1202
|
* @param call The call details.
|
|
@@ -1135,7 +1206,7 @@ class ApplicationClient {
|
|
|
1135
1206
|
return await this.callOfType(call, 'clear_state');
|
|
1136
1207
|
}
|
|
1137
1208
|
/**
|
|
1138
|
-
* @deprecated Use `appClient.send.delete` or `appClient.
|
|
1209
|
+
* @deprecated Use `appClient.send.delete` or `appClient.createTransaction.delete` from an `AppClient` instance instead.
|
|
1139
1210
|
*
|
|
1140
1211
|
* Issues a delete_application call to the app.
|
|
1141
1212
|
* @param call The call details.
|
|
@@ -1145,7 +1216,7 @@ class ApplicationClient {
|
|
|
1145
1216
|
return await this.callOfType(call, 'delete_application');
|
|
1146
1217
|
}
|
|
1147
1218
|
/**
|
|
1148
|
-
* @deprecated Use `appClient.send.call` or `appClient.
|
|
1219
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1149
1220
|
*
|
|
1150
1221
|
* Issues a call to the app with the given call type.
|
|
1151
1222
|
* @param call The call details.
|