From 55afc1c81f9ff17dd1befa16667a4b0c14c98aa3 Mon Sep 17 00:00:00 2001 From: adbario Date: Sat, 27 Aug 2022 19:40:29 +0100 Subject: [PATCH 1/2] Fix default compute limit deprecation warning --- dev-test/config.test.js | 9 +++++++++ src/config.js | 15 +++++++++++++++ src/interaction.js | 5 ++--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 dev-test/config.test.js diff --git a/dev-test/config.test.js b/dev-test/config.test.js new file mode 100644 index 00000000..0ce4dff2 --- /dev/null +++ b/dev-test/config.test.js @@ -0,0 +1,9 @@ +import {getConfigValue} from "../src" + +describe("configuration tests", () => { + test("defaultComputeLimit - set default compute limit", async () => { + const limit = await getConfigValue("fcl.limit") + + expect(limit).toBe(999) + }) +}) diff --git a/src/config.js b/src/config.js index 662d44d9..2464d415 100644 --- a/src/config.js +++ b/src/config.js @@ -19,6 +19,21 @@ import {flowConfig} from "@onflow/fcl-config" import {config} from "@onflow/fcl" +/** + * The default compute limit for transactions. + */ +export const DEFAULT_COMPUTE_LIMIT = 999 + +/** + * Set the default compute limit for transactions. + * + * Previously, providing a compute limit for transactions was optional and + * a fallback existed (DEFAULT_COMPUTE_LIMIT=10). Compute limits may still + * be applied explicitly in a transaction. + * @link https://github.com/onflow/fcl-js/blob/master/packages/sdk/TRANSITIONS.md#0009-deprecate-default-compute-limit + */ +config().put("fcl.limit", DEFAULT_COMPUTE_LIMIT) + /** * Get value from provided scope and path. * @param scope - scope value. diff --git a/src/interaction.js b/src/interaction.js index 50ae930b..e622b53b 100644 --- a/src/interaction.js +++ b/src/interaction.js @@ -18,6 +18,7 @@ import * as fcl from "@onflow/fcl" import {resolveArguments} from "@onflow/flow-cadut" +import {DEFAULT_COMPUTE_LIMIT} from "./config" import {authorization} from "./crypto" import emulator from "./emulator/emulator" import {getTransactionCode, getScriptCode, defaultsByName} from "./file" @@ -26,8 +27,6 @@ import {getServiceAddress} from "./utils" import {applyTransformers, builtInMethods} from "./transformers" import {isObject} from "./utils" -const DEFAULT_LIMIT = 999 - export const extractParameters = ixType => { return async params => { let ixCode, ixName, ixSigners, ixArgs, ixService, ixTransformers, ixLimit @@ -67,7 +66,7 @@ export const extractParameters = ixType => { } // Check that limit is always set - ixLimit = ixLimit || DEFAULT_LIMIT + ixLimit = ixLimit || DEFAULT_COMPUTE_LIMIT if (ixName) { const getIxTemplate = From dd4ecbae37fd94e1422c7fe5283a62748f5880e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Riku=20S=C3=A4rkinen?= Date: Mon, 19 Sep 2022 21:09:32 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/bright-comics-fold.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/bright-comics-fold.md diff --git a/.changeset/bright-comics-fold.md b/.changeset/bright-comics-fold.md new file mode 100644 index 00000000..e5a14940 --- /dev/null +++ b/.changeset/bright-comics-fold.md @@ -0,0 +1,5 @@ +--- +"@onflow/flow-js-testing": patch +--- + +Fix the warning about deprecated default compute limit for transactions