@algorandfoundation/algokit-utils 8.1.1-beta.1 → 8.1.1-beta.2

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  "**"
7
7
  ],
8
8
  "name": "@algorandfoundation/algokit-utils",
9
- "version": "8.1.1-beta.1",
9
+ "version": "8.1.1-beta.2",
10
10
  "private": false,
11
11
  "description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
12
12
  "author": "Algorand Foundation",
@@ -755,21 +755,44 @@ class AppClient {
755
755
  // Read-only call - do it via simulate
756
756
  if ((params.onComplete === OnApplicationComplete.NoOpOC || !params.onComplete) &&
757
757
  types_appArc56.getArc56Method(params.method, this._appSpec).method.readonly) {
758
- const result = await this._algorand
759
- .newGroup()
760
- .addAppCallMethodCall(await this.params.call(params))
761
- .simulate({
762
- allowUnnamedResources: params.populateAppCallResources ?? true,
763
- // Simulate calls for a readonly method shouldn't invoke signing
764
- skipSignatures: true,
765
- });
766
- return this.processMethodCallReturn({
767
- ...result,
768
- transaction: result.transactions.at(-1),
769
- confirmation: result.confirmations.at(-1),
770
- // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
771
- return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
772
- }, types_appArc56.getArc56Method(params.method, this._appSpec));
758
+ const readonlyParams = {
759
+ ...params,
760
+ };
761
+ // Read-only calls do not require fees to be paid, as they are only simulated on the network.
762
+ // Therefore there is no value in calculating the minimum fee needed for a successful app call with inner transactions.
763
+ // As a a result we only need to send a single simulate call,
764
+ // however to do this successfully we need to ensure fees for the transaction are fully covered using maxFee.
765
+ if (params.coverAppCallInnerTransactionFees) {
766
+ if (params.maxFee === undefined) {
767
+ throw Error(`Please provide a maxFee for the transaction when coverAppCallInnerTransactionFees is enabled.`);
768
+ }
769
+ readonlyParams.staticFee = params.maxFee;
770
+ readonlyParams.extraFee = undefined;
771
+ }
772
+ try {
773
+ const result = await this._algorand
774
+ .newGroup()
775
+ .addAppCallMethodCall(await this.params.call(readonlyParams))
776
+ .simulate({
777
+ allowUnnamedResources: params.populateAppCallResources ?? true,
778
+ // Simulate calls for a readonly method shouldn't invoke signing
779
+ skipSignatures: true,
780
+ });
781
+ return this.processMethodCallReturn({
782
+ ...result,
783
+ transaction: result.transactions.at(-1),
784
+ confirmation: result.confirmations.at(-1),
785
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
786
+ return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
787
+ }, types_appArc56.getArc56Method(params.method, this._appSpec));
788
+ }
789
+ catch (e) {
790
+ const error = e;
791
+ if (params.coverAppCallInnerTransactionFees && error && error.message && error.message.match(/fee too small/)) {
792
+ throw Error(`Fees were too small. You may need to increase the transaction maxFee.`);
793
+ }
794
+ throw e;
795
+ }
773
796
  }
774
797
  return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
775
798
  },