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

Commit 8d75426

Browse files
authored
Fix default compute limit deprecation warning (#177)
* Fix default compute limit deprecation warning * Add changeset
1 parent 75f8a14 commit 8d75426

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.changeset/bright-comics-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@onflow/flow-js-testing": patch
3+
---
4+
5+
Fix the warning about deprecated default compute limit for transactions

dev-test/config.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {getConfigValue} from "../src"
2+
3+
describe("configuration tests", () => {
4+
test("defaultComputeLimit - set default compute limit", async () => {
5+
const limit = await getConfigValue("fcl.limit")
6+
7+
expect(limit).toBe(999)
8+
})
9+
})

src/config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919
import {flowConfig} from "@onflow/fcl-config"
2020
import {config} from "@onflow/fcl"
2121

22+
/**
23+
* The default compute limit for transactions.
24+
*/
25+
export const DEFAULT_COMPUTE_LIMIT = 999
26+
27+
/**
28+
* Set the default compute limit for transactions.
29+
*
30+
* Previously, providing a compute limit for transactions was optional and
31+
* a fallback existed (DEFAULT_COMPUTE_LIMIT=10). Compute limits may still
32+
* be applied explicitly in a transaction.
33+
* @link https://github.com/onflow/fcl-js/blob/master/packages/sdk/TRANSITIONS.md#0009-deprecate-default-compute-limit
34+
*/
35+
config().put("fcl.limit", DEFAULT_COMPUTE_LIMIT)
36+
2237
/**
2338
* Get value from provided scope and path.
2439
* @param scope - scope value.

src/interaction.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import * as fcl from "@onflow/fcl"
2020
import {resolveArguments} from "@onflow/flow-cadut"
21+
import {DEFAULT_COMPUTE_LIMIT} from "./config"
2122
import {authorization} from "./crypto"
2223
import emulator from "./emulator/emulator"
2324
import {getTransactionCode, getScriptCode, defaultsByName} from "./file"
@@ -26,8 +27,6 @@ import {getServiceAddress} from "./utils"
2627
import {applyTransformers, builtInMethods} from "./transformers"
2728
import {isObject} from "./utils"
2829

29-
const DEFAULT_LIMIT = 999
30-
3130
export const extractParameters = ixType => {
3231
return async params => {
3332
let ixCode, ixName, ixSigners, ixArgs, ixService, ixTransformers, ixLimit
@@ -67,7 +66,7 @@ export const extractParameters = ixType => {
6766
}
6867

6968
// Check that limit is always set
70-
ixLimit = ixLimit || DEFAULT_LIMIT
69+
ixLimit = ixLimit || DEFAULT_COMPUTE_LIMIT
7170

7271
if (ixName) {
7372
const getIxTemplate =

0 commit comments

Comments
 (0)