@algorandfoundation/algokit-utils 7.0.0-beta.8 → 7.0.0-beta.9
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 +1 -1
- package/types/app-client.d.ts +78 -70
- package/types/app-client.js +31 -21
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +31 -21
- package/types/app-client.mjs.map +1 -1
- package/types/app-factory.d.ts +16 -6
- package/types/app-factory.js +26 -18
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +26 -18
- package/types/app-factory.mjs.map +1 -1
- package/types/composer.d.ts +4 -1
- package/types/composer.js +19 -4
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +19 -4
- package/types/composer.mjs.map +1 -1
package/types/app-client.mjs
CHANGED
|
@@ -50,6 +50,7 @@ class AppClient {
|
|
|
50
50
|
this._appName = params.appName ?? this._appSpec.name;
|
|
51
51
|
this._algorand = params.algorand;
|
|
52
52
|
this._defaultSender = params.defaultSender;
|
|
53
|
+
this._defaultSigner = params.defaultSigner;
|
|
53
54
|
this._approvalSourceMap = params.approvalSourceMap;
|
|
54
55
|
this._clearSourceMap = params.clearSourceMap;
|
|
55
56
|
this._localStateMethods = (address) => this.getStateMethods(() => this.getLocalState(address), () => this._appSpec.state.keys.local, () => this._appSpec.state.maps.local);
|
|
@@ -145,6 +146,10 @@ class AppClient {
|
|
|
145
146
|
get appSpec() {
|
|
146
147
|
return this._appSpec;
|
|
147
148
|
}
|
|
149
|
+
/** A reference to the underlying `AlgorandClient` this app client is using. */
|
|
150
|
+
get algorand() {
|
|
151
|
+
return this._algorand;
|
|
152
|
+
}
|
|
148
153
|
/** Get parameters to create transactions for the current app.
|
|
149
154
|
*
|
|
150
155
|
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
@@ -338,11 +343,11 @@ class AppClient {
|
|
|
338
343
|
*/
|
|
339
344
|
async compile(compilation) {
|
|
340
345
|
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
341
|
-
if (result.
|
|
342
|
-
this._approvalSourceMap = result.
|
|
346
|
+
if (result.compiledApproval) {
|
|
347
|
+
this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
343
348
|
}
|
|
344
|
-
if (result.
|
|
345
|
-
this._clearSourceMap = result.
|
|
349
|
+
if (result.compiledClear) {
|
|
350
|
+
this._clearSourceMap = result.compiledClear.sourceMap;
|
|
346
351
|
}
|
|
347
352
|
return result;
|
|
348
353
|
}
|
|
@@ -398,25 +403,25 @@ class AppClient {
|
|
|
398
403
|
};
|
|
399
404
|
}
|
|
400
405
|
const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
401
|
-
const
|
|
406
|
+
const compiledApproval = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {
|
|
402
407
|
updatable,
|
|
403
408
|
deletable,
|
|
404
409
|
});
|
|
405
410
|
const clearTemplate = Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
|
|
406
|
-
const
|
|
411
|
+
const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
|
|
407
412
|
if (Config.debug) {
|
|
408
413
|
await Config.events.emitAsync(EventType.AppCompiled, {
|
|
409
414
|
sources: [
|
|
410
|
-
{ compiledTeal:
|
|
411
|
-
{ compiledTeal:
|
|
415
|
+
{ compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },
|
|
416
|
+
{ compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },
|
|
412
417
|
],
|
|
413
418
|
});
|
|
414
419
|
}
|
|
415
420
|
return {
|
|
416
|
-
approvalProgram:
|
|
417
|
-
|
|
418
|
-
clearStateProgram:
|
|
419
|
-
|
|
421
|
+
approvalProgram: compiledApproval.compiledBase64ToBytes,
|
|
422
|
+
compiledApproval,
|
|
423
|
+
clearStateProgram: compiledClear.compiledBase64ToBytes,
|
|
424
|
+
compiledClear,
|
|
420
425
|
};
|
|
421
426
|
}
|
|
422
427
|
/**
|
|
@@ -541,10 +546,7 @@ class AppClient {
|
|
|
541
546
|
const compiled = await this.compile(params);
|
|
542
547
|
return {
|
|
543
548
|
...(await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)))),
|
|
544
|
-
...
|
|
545
|
-
compiledApproval: compiled.approvalProgramCompilationResult,
|
|
546
|
-
compiledClear: compiled.clearStateProgramCompilationResult,
|
|
547
|
-
},
|
|
549
|
+
...compiled,
|
|
548
550
|
};
|
|
549
551
|
},
|
|
550
552
|
/** Signs and sends an opt-in call */
|
|
@@ -576,6 +578,7 @@ class AppClient {
|
|
|
576
578
|
return {
|
|
577
579
|
...params,
|
|
578
580
|
sender: this.getSender(params.sender),
|
|
581
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
579
582
|
receiver: this.appAddress,
|
|
580
583
|
};
|
|
581
584
|
},
|
|
@@ -617,10 +620,7 @@ class AppClient {
|
|
|
617
620
|
const compiled = await this.compile(params);
|
|
618
621
|
return {
|
|
619
622
|
...(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
|
-
},
|
|
623
|
+
...compiled,
|
|
624
624
|
};
|
|
625
625
|
},
|
|
626
626
|
/**
|
|
@@ -653,6 +653,8 @@ class AppClient {
|
|
|
653
653
|
.addAppCallMethodCall(await this.params.call(params))
|
|
654
654
|
.simulate({
|
|
655
655
|
allowUnnamedResources: params.populateAppCallResources,
|
|
656
|
+
// Simulate calls for a readonly method shouldn't invoke signing
|
|
657
|
+
skipSignatures: true,
|
|
656
658
|
});
|
|
657
659
|
return this.processMethodCallReturn({
|
|
658
660
|
...result,
|
|
@@ -704,7 +706,7 @@ class AppClient {
|
|
|
704
706
|
},
|
|
705
707
|
};
|
|
706
708
|
}
|
|
707
|
-
/** Returns the sender for a call, using the `defaultSender`
|
|
709
|
+
/** Returns the sender for a call, using the provided sender or using the `defaultSender`
|
|
708
710
|
* if none provided and throws an error if neither provided */
|
|
709
711
|
getSender(sender) {
|
|
710
712
|
if (!sender && !this._defaultSender) {
|
|
@@ -712,11 +714,18 @@ class AppClient {
|
|
|
712
714
|
}
|
|
713
715
|
return sender ?? this._defaultSender;
|
|
714
716
|
}
|
|
717
|
+
/** Returns the signer for a call, using the provided signer or the `defaultSigner`
|
|
718
|
+
* if no signer was provided and the call will use default sender
|
|
719
|
+
* or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */
|
|
720
|
+
getSigner(sender, signer) {
|
|
721
|
+
return signer ?? (!sender ? this._defaultSigner : undefined);
|
|
722
|
+
}
|
|
715
723
|
getBareParams(params, onComplete) {
|
|
716
724
|
return {
|
|
717
725
|
...params,
|
|
718
726
|
appId: this._appId,
|
|
719
727
|
sender: this.getSender(params?.sender),
|
|
728
|
+
signer: this.getSigner(params?.sender, params?.signer),
|
|
720
729
|
onComplete,
|
|
721
730
|
};
|
|
722
731
|
}
|
|
@@ -728,6 +737,7 @@ class AppClient {
|
|
|
728
737
|
...params,
|
|
729
738
|
appId: this._appId,
|
|
730
739
|
sender: sender,
|
|
740
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
731
741
|
method,
|
|
732
742
|
onComplete,
|
|
733
743
|
args,
|