Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Fix default compute limit deprecation warning #177

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-comics-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/flow-js-testing": patch
---

Fix the warning about deprecated default compute limit for transactions
9 changes: 9 additions & 0 deletions dev-test/config.test.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
15 changes: 15 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down