@algorandfoundation/algokit-utils 7.0.0-beta.7 → 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 +76 -100
- package/types/app-client.js +25 -5
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +25 -5
- package/types/app-client.mjs.map +1 -1
- package/types/app-factory.d.ts +27 -202
- package/types/app-factory.js +19 -2
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +19 -2
- package/types/app-factory.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/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.
|
|
@@ -394,9 +399,7 @@ class AppClient {
|
|
|
394
399
|
}
|
|
395
400
|
return {
|
|
396
401
|
approvalProgram: Buffer.from(appSpec.byteCode.approval, 'base64'),
|
|
397
|
-
compiledApproval: undefined,
|
|
398
402
|
clearStateProgram: Buffer.from(appSpec.byteCode.clear, 'base64'),
|
|
399
|
-
compiledClear: undefined,
|
|
400
403
|
};
|
|
401
404
|
}
|
|
402
405
|
const approvalTemplate = Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
@@ -540,7 +543,11 @@ class AppClient {
|
|
|
540
543
|
return {
|
|
541
544
|
/** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
542
545
|
update: async (params) => {
|
|
543
|
-
|
|
546
|
+
const compiled = await this.compile(params);
|
|
547
|
+
return {
|
|
548
|
+
...(await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)))),
|
|
549
|
+
...compiled,
|
|
550
|
+
};
|
|
544
551
|
},
|
|
545
552
|
/** Signs and sends an opt-in call */
|
|
546
553
|
optIn: (params) => {
|
|
@@ -571,6 +578,7 @@ class AppClient {
|
|
|
571
578
|
return {
|
|
572
579
|
...params,
|
|
573
580
|
sender: this.getSender(params.sender),
|
|
581
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
574
582
|
receiver: this.appAddress,
|
|
575
583
|
};
|
|
576
584
|
},
|
|
@@ -643,7 +651,11 @@ class AppClient {
|
|
|
643
651
|
const result = await this._algorand
|
|
644
652
|
.newGroup()
|
|
645
653
|
.addAppCallMethodCall(await this.params.call(params))
|
|
646
|
-
.simulate(
|
|
654
|
+
.simulate({
|
|
655
|
+
allowUnnamedResources: params.populateAppCallResources,
|
|
656
|
+
// Simulate calls for a readonly method shouldn't invoke signing
|
|
657
|
+
skipSignatures: true,
|
|
658
|
+
});
|
|
647
659
|
return this.processMethodCallReturn({
|
|
648
660
|
...result,
|
|
649
661
|
transaction: result.transactions.at(-1),
|
|
@@ -694,7 +706,7 @@ class AppClient {
|
|
|
694
706
|
},
|
|
695
707
|
};
|
|
696
708
|
}
|
|
697
|
-
/** Returns the sender for a call, using the `defaultSender`
|
|
709
|
+
/** Returns the sender for a call, using the provided sender or using the `defaultSender`
|
|
698
710
|
* if none provided and throws an error if neither provided */
|
|
699
711
|
getSender(sender) {
|
|
700
712
|
if (!sender && !this._defaultSender) {
|
|
@@ -702,11 +714,18 @@ class AppClient {
|
|
|
702
714
|
}
|
|
703
715
|
return sender ?? this._defaultSender;
|
|
704
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
|
+
}
|
|
705
723
|
getBareParams(params, onComplete) {
|
|
706
724
|
return {
|
|
707
725
|
...params,
|
|
708
726
|
appId: this._appId,
|
|
709
727
|
sender: this.getSender(params?.sender),
|
|
728
|
+
signer: this.getSigner(params?.sender, params?.signer),
|
|
710
729
|
onComplete,
|
|
711
730
|
};
|
|
712
731
|
}
|
|
@@ -718,6 +737,7 @@ class AppClient {
|
|
|
718
737
|
...params,
|
|
719
738
|
appId: this._appId,
|
|
720
739
|
sender: sender,
|
|
740
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
721
741
|
method,
|
|
722
742
|
onComplete,
|
|
723
743
|
args,
|