@algorandfoundation/algokit-utils 9.1.1-beta.4 → 9.1.1-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.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "**"
7
7
  ],
8
8
  "name": "@algorandfoundation/algokit-utils",
9
- "version": "9.1.1-beta.4",
9
+ "version": "9.1.1-beta.5",
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",
@@ -1826,7 +1826,7 @@ export declare class ApplicationClient {
1826
1826
  deletable?: boolean | undefined;
1827
1827
  updatable?: boolean | undefined;
1828
1828
  return?: ABIReturn | undefined;
1829
- /** Configuration to resolve app by creator and name `getCreatorAppsByName` */
1829
+ /** The maximum opcode budget for a simulate call as per https://github.com/algorand/go-algorand/blob/807b29a91c371d225e12b9287c5d56e9b33c4e4c/ledger/simulation/trace.go#L104 */
1830
1830
  operationPerformed: "update" | "create";
1831
1831
  } | {
1832
1832
  compiledApproval: import("./app").CompiledTeal;
@@ -20,6 +20,8 @@ var getApplicationAddress = algosdk.getApplicationAddress;
20
20
  var Indexer = algosdk.Indexer;
21
21
  var OnApplicationComplete = algosdk.OnApplicationComplete;
22
22
  var SourceMap = algosdk.ProgramSourceMap;
23
+ /** The maximum opcode budget for a simulate call as per https://github.com/algorand/go-algorand/blob/807b29a91c371d225e12b9287c5d56e9b33c4e4c/ledger/simulation/trace.go#L104 */
24
+ const MAX_SIMULATE_OPCODE_BUDGET = 20000 * 16;
23
25
  /**
24
26
  * Determines deploy time control (UPDATABLE, DELETABLE) value by inspecting application specification
25
27
  * @param approval TEAL Approval program, not the base64 version found on the appSpec
@@ -915,13 +917,11 @@ class AppClient {
915
917
  ...params,
916
918
  };
917
919
  // Read-only calls do not require fees to be paid, as they are only simulated on the network.
918
- // Therefore there is no value in calculating the minimum fee needed for a successful app call with inner transactions.
919
- // As a a result we only need to send a single simulate call,
920
- // however to do this successfully we need to ensure fees for the transaction are fully covered using maxFee.
921
- if (params.coverAppCallInnerTransactionFees) {
922
- if (params.maxFee === undefined) {
923
- throw Error(`Please provide a maxFee for the transaction when coverAppCallInnerTransactionFees is enabled.`);
924
- }
920
+ // With maximum opcode budget provided, ensure_budget (and similar op-up utilities) won't need to create inner transactions,
921
+ // so fee coverage for op-up inner transactions does not need to be accounted for in readonly calls.
922
+ // If max_fee is provided, use it as static_fee, as there may still be inner transactions sent which need to be covered by the outermost transaction,
923
+ // even though ARC-22 specifies that readonly methods should not send inner transactions.
924
+ if (params.coverAppCallInnerTransactionFees && params.maxFee) {
925
925
  readonlyParams.staticFee = params.maxFee;
926
926
  readonlyParams.extraFee = undefined;
927
927
  }
@@ -933,6 +933,8 @@ class AppClient {
933
933
  allowUnnamedResources: params.populateAppCallResources ?? true,
934
934
  // Simulate calls for a readonly method shouldn't invoke signing
935
935
  skipSignatures: true,
936
+ // Simulate calls for a readonly method can use the max opcode budget
937
+ extraOpcodeBudget: MAX_SIMULATE_OPCODE_BUDGET,
936
938
  });
937
939
  return this.processMethodCallReturn({
938
940
  ...result,
@@ -944,6 +946,8 @@ class AppClient {
944
946
  }
945
947
  catch (e) {
946
948
  const error = e;
949
+ // For read-only calls with max opcode budget, fee issues should be rare
950
+ // but we can still provide helpful error message if they occur
947
951
  if (params.coverAppCallInnerTransactionFees && error && error.message && error.message.match(/fee too small/)) {
948
952
  throw Error(`Fees were too small. You may need to increase the transaction maxFee.`);
949
953
  }