Skip to content

Commit

Permalink
Fix args type for fcl.query & fcl.mutate (#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink authored Jan 26, 2025
1 parent 893835f commit 3fccbef
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-wombats-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/fcl-core": patch
---

Fix args type for `fcl.query` & `fcl.mutate`
11 changes: 11 additions & 0 deletions packages/fcl-core/src/exec/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {arg} from "@onflow/sdk"
import * as t from "@onflow/types"

type ArgFn = typeof arg
type Types = typeof t
/**
* @param arg - Argument function to define a single argument
* @param t - Cadence Types object used to define the type
* @returns {any[]}
*/
export type ArgsFn = (arg: ArgFn, t: Types) => any[]
2 changes: 1 addition & 1 deletion packages/fcl-core/src/exec/mutate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getMutate = currentUserOrConfig => {
*
* @param {object} [opts] - Mutation Options and configuration
* @param {string} [opts.cadence] - Cadence Transaction used to mutate Flow
* @param {import("../shared-exports").ArgsFn} [opts.args] - Arguments passed to cadence transaction
* @param {import("./args").ArgsFn} [opts.args] - Arguments passed to cadence transaction
* @param {object | string} [opts.template] - Interaction Template for a transaction
* @param {number} [opts.limit] - Compute Limit for transaction
* @param {Function} [opts.authz] - Authorization function for transaction
Expand Down
2 changes: 1 addition & 1 deletion packages/fcl-core/src/exec/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {preQuery} from "./utils/pre.js"
*
* @param {object} opts - Query Options and configuration
* @param {string} opts.cadence - Cadence Script used to query Flow
* @param {import("../fcl").ArgsFn} [opts.args] - Arguments passed to cadence script
* @param {import("./args").ArgsFn} [opts.args] - Arguments passed to cadence script
* @param {object | string} [opts.template] - Interaction Template for a script
* @param {number} [opts.limit] - Compute Limit for Query
* @returns {Promise}
Expand Down
53 changes: 0 additions & 53 deletions packages/fcl-core/src/fcl-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,59 +69,6 @@ export {params, param} from "@onflow/sdk"
export {validator} from "@onflow/sdk"
export {invariant} from "@onflow/sdk"

/**
* @typedef {object} Types
* @property {any} Identity - Represents the Identity type.
* @property {any} UInt - Represents the UInt type.
* @property {any} Int - Represents the Int type.
* @property {any} UInt8 - Represents the UInt8 type.
* @property {any} Int8 - Represents the Int8 type.
* @property {any} UInt16 - Represents the UInt16 type.
* @property {any} Int16 - Represents the Int16 type.
* @property {any} UInt32 - Represents the UInt32 type.
* @property {any} Int32 - Represents the Int32 type.
* @property {any} UInt64 - Represents the UInt64 type.
* @property {any} Int64 - Represents the Int64 type.
* @property {any} UInt128 - Represents the UInt128 type.
* @property {any} Int128 - Represents the Int128 type.
* @property {any} UInt256 - Represents the UInt256 type.
* @property {any} Int256 - Represents the Int256 type.
* @property {any} Word8 - Represents the Word8 type.
* @property {any} Word16 - Represents the Word16 type.
* @property {any} Word32 - Represents the Word32 type.
* @property {any} Word64 - Represents the Word64 type.
* @property {any} UFix64 - Represents the UFix64 type.
* @property {any} Fix64 - Represents the Fix64 type.
* @property {any} String - Represents the String type.
* @property {any} Character - Represents the Character type.
* @property {any} Bool - Represents the Bool type.
* @property {any} Address - Represents the Address type.
* @property {any} Void - Represents the Void type.
* @property {any} Optional - Represents the Optional type.
* @property {any} Reference - Represents the Reference type.
* @property {any} Array - Represents the Array type.
* @property {any} Dictionary - Represents the Dictionary type.
* @property {any} Event - Represents the Event type.
* @property {any} Resource - Represents the Resource type.
* @property {any} Struct - Represents the Struct type.
* @property {any} Enum - Represents the Enum type.
* @property {any} Path - Represents the Path type.
*/

/**
* @callback ArgsFn
* @param {ArgFn} arg - Argument function to define a single argument
* @param {Types} t - Cadence Types object used to define the type
* @returns {any[]}
*/

/**
* @callback ArgFn
* @param {any} value - the value of the argument
* @param {any} type - the cadence type of the value
* @returns {any}
*/

import {watchForChainIdChanges} from "./utils"

// Set chain id default on access node change
Expand Down

0 comments on commit 3fccbef

Please sign in to comment.