Skip to content

Commit

Permalink
Merge branch 'release-1.6' into jribbink/ts-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Aug 14, 2023
2 parents e39c14e + 5a552f6 commit d28eeb9
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 62 deletions.
7 changes: 7 additions & 0 deletions packages/fcl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
- @onflow/types@1.2.0-alpha.0
- @onflow/rlp@1.2.0-alpha.0
- @onflow/sdk@1.3.0-alpha.0
## 1.5.1

### Patch Changes

- [#1754](https://github.com/onflow/fcl-js/pull/1754) [`c0ba4d26`](https://github.com/onflow/fcl-js/commit/c0ba4d268ce307ddbd83b812db5136f0f29afdc4) Thanks [@jribbink](https://github.com/jribbink)! - Fix `fcl.mutate` typedef

- [#1755](https://github.com/onflow/fcl-js/pull/1755) [`28d16a13`](https://github.com/onflow/fcl-js/commit/28d16a134f9afea265400b49df81f77ac02a520d) Thanks [@jribbink](https://github.com/jribbink)! - Fix react-native platform for `fcl.mutate`

## 1.5.0

Expand Down
Binary file removed packages/fcl/onflow-fcl-1.5.0-alpha.2.tgz
Binary file not shown.
108 changes: 52 additions & 56 deletions packages/fcl/src/exec/mutate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,55 @@ import {prepTemplateOpts} from "./utils/prep-template-opts.js"
import {preMutate} from "./utils/pre.js"
import {isNumber} from "./utils/is"

/**
* @typedef {function(*)Promise<string>} MutateFn
*
* @description
* Allows you to submit transactions to the blockchain to potentially mutate the state.
*
* @param {object} opts - Mutation Options and configuration
* @param {string} opts.platform - platform that runs the function
* @param {string} opts.cadence - Cadence Transaction used to mutate Flow
* @param {import("../fcl").ArgsFn} [opts.args] - Arguments passed to cadence transaction
* @param {object} [opts.template] - Interaction Template for a transaction
* @param {number} [opts.limit] - Compute Limit for transaction
* @returns {Promise<string>} Transaction Id
*
* @example
* fcl.mutate({
* cadence: `
* transaction(a: Int, b: Int, c: Address) {
* prepare(acct: AuthAccount) {
* log(acct)
* log(a)
* log(b)
* log(c)
* }
* }
* `,
* args: (arg, t) => [
* arg(6, t.Int),
* arg(7, t.Int),
* arg("0xba1132bc08f82fe2", t.Address),
* ],
* })
*
*
* Options:
* type Options = {
* template: InteractionTemplate | String // InteractionTemplate or url to one
* cadence: String!,
* args: (arg, t) => Array<Arg>,
* limit: Number,
* authz: AuthzFn, // will overload the trinity of signatory roles
* proposer: AuthzFn, // will overload the proposer signatory role
* payer: AuthzFn, // will overload the payer signatory role
* authorizations: [AuthzFn], // an array of authorization functions used as authorizations signatory roles
* }
*/

/**
* Gets a function that allows you to submit transactions to the blockchain to potentially mutate the state.
* @param {object} opts - Mutation Options and configuration
* @param {string} opts.platform - platform that runs the function
* @returns {MutateFn}
*/
export const getMutate =
({platform}) =>
async (opts = {}) => {
export const getMutate = ({platform}) => {
/**
* @description
* Allows you to submit transactions to the blockchain to potentially mutate the state.
*
* @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 {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
* @param {Function} [opts.proposer] - Proposer Authorization function for transaction
* @param {Function} [opts.payer] - Payer Authorization function for transaction
* @param {Array<Function>} [opts.authorizations] - Authorizations function for transaction
* @returns {Promise<string>} Transaction Id
*
* @example
* fcl.mutate({
* cadence: `
* transaction(a: Int, b: Int, c: Address) {
* prepare(acct: AuthAccount) {
* log(acct)
* log(a)
* log(b)
* log(c)
* }
* }
* `,
* args: (arg, t) => [
* arg(6, t.Int),
* arg(7, t.Int),
* arg("0xba1132bc08f82fe2", t.Address),
* ],
* })
*
*
* Options:
* type Options = {
* template: InteractionTemplate | String // InteractionTemplate or url to one
* cadence: String!,
* args: (arg, t) => Array<Arg>,
* limit: Number,
* authz: AuthzFn, // will overload the trinity of signatory roles
* proposer: AuthzFn, // will overload the proposer signatory role
* payer: AuthzFn, // will overload the payer signatory role
* authorizations: [AuthzFn], // an array of authorization functions used as authorizations signatory roles
* }
*/
const mutate = async (opts = {}) => {
var txid
try {
await preMutate(opts)
Expand Down Expand Up @@ -95,3 +88,6 @@ export const getMutate =
throw error
}
}

return mutate
}
15 changes: 10 additions & 5 deletions packages/fcl/src/fcl-react-native.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from './shared-exports';
export * from "./shared-exports"

import {getMutate} from "./exec/mutate"
export const mutate = getMutate({platform: "web"})
export const mutate = getMutate({platform: "react-native"})

import {getCurrentUser} from "./current-user"
const currentUser = getCurrentUser({platform:"react-native"})
const currentUser = getCurrentUser({platform: "react-native"})

export {currentUser}

Expand All @@ -20,9 +20,14 @@ export const logIn = (opts = {}) => currentUser().authenticate(opts)
export const authz = currentUser().authorization

import {config} from "@onflow/config"
import {coreStrategies, getDefaultConfig, useServiceDiscovery, ServiceDiscovery} from "./utils/react-native"
import {
coreStrategies,
getDefaultConfig,
useServiceDiscovery,
ServiceDiscovery,
} from "./utils/react-native"
import {initServiceRegistry} from "./current-user/exec-service/plugins"
import {setIsReactNative} from './utils/is-react-native';
import {setIsReactNative} from "./utils/is-react-native"

config(getDefaultConfig())

Expand Down
1 change: 0 additions & 1 deletion packages/fcl/src/shared-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +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.
Expand Down

0 comments on commit d28eeb9

Please sign in to comment.