From 08f4dd6b0efc2204feb8fae8a480980688a49141 Mon Sep 17 00:00:00 2001 From: Alex <12097569+nialexsan@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:44:21 -0400 Subject: [PATCH 1/2] OPS -- fcl -- move utils (#1793) * OPS -- fcl -- move utils * Update packages/fcl/src/exec/utils/prep-template-opts.js Co-authored-by: Jordan Ribbink * changeset --------- Co-authored-by: Jordan Ribbink --- .changeset/twenty-zoos-battle.md | 5 +++++ packages/fcl/src/app-utils/verify-signatures.js | 2 +- packages/fcl/src/current-user/exec-service/plugins.js | 2 +- packages/fcl/src/exec/mutate.js | 2 +- packages/fcl/src/exec/utils/normalize-args.js | 2 +- packages/fcl/src/exec/utils/pre.js | 2 +- packages/fcl/src/exec/utils/prep-template-opts.js | 2 +- packages/fcl/src/{exec => }/utils/is.js | 0 8 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/twenty-zoos-battle.md rename packages/fcl/src/{exec => }/utils/is.js (100%) diff --git a/.changeset/twenty-zoos-battle.md b/.changeset/twenty-zoos-battle.md new file mode 100644 index 000000000..9593838a6 --- /dev/null +++ b/.changeset/twenty-zoos-battle.md @@ -0,0 +1,5 @@ +--- +"@onflow/fcl": patch +--- + +Move is-helpers to utils diff --git a/packages/fcl/src/app-utils/verify-signatures.js b/packages/fcl/src/app-utils/verify-signatures.js index ccd7748f7..184df57eb 100644 --- a/packages/fcl/src/app-utils/verify-signatures.js +++ b/packages/fcl/src/app-utils/verify-signatures.js @@ -2,7 +2,7 @@ import {invariant} from "@onflow/util-invariant" import {withPrefix, sansPrefix} from "@onflow/util-address" import {query} from "../exec/query" import {encodeAccountProof} from "../wallet-utils" -import {isString} from "../exec/utils/is" +import {isString} from "../utils/is" import {getChainId} from "../utils" const ACCOUNT_PROOF = "ACCOUNT_PROOF" diff --git a/packages/fcl/src/current-user/exec-service/plugins.js b/packages/fcl/src/current-user/exec-service/plugins.js index 026374789..8aaf9f449 100644 --- a/packages/fcl/src/current-user/exec-service/plugins.js +++ b/packages/fcl/src/current-user/exec-service/plugins.js @@ -1,6 +1,6 @@ import {invariant} from "@onflow/util-invariant" import {LEVELS, log} from "@onflow/util-logger" -import {isRequired, isString, isObject, isFunc} from "../../exec/utils/is" +import {isRequired, isString, isObject, isFunc} from "../../utils/is" import { CORE_STRATEGIES } from "../../utils/constants" const stub = () => { diff --git a/packages/fcl/src/exec/mutate.js b/packages/fcl/src/exec/mutate.js index c1dae1eec..1d1120617 100644 --- a/packages/fcl/src/exec/mutate.js +++ b/packages/fcl/src/exec/mutate.js @@ -3,7 +3,7 @@ import {normalizeArgs} from "./utils/normalize-args" import {getCurrentUser} from "../current-user" import {prepTemplateOpts} from "./utils/prep-template-opts.js" import {preMutate} from "./utils/pre.js" -import {isNumber} from "./utils/is" +import {isNumber} from "../utils/is" export const getMutate = ({platform}) => { /** diff --git a/packages/fcl/src/exec/utils/normalize-args.js b/packages/fcl/src/exec/utils/normalize-args.js index 957600c72..b0cc38589 100644 --- a/packages/fcl/src/exec/utils/normalize-args.js +++ b/packages/fcl/src/exec/utils/normalize-args.js @@ -1,4 +1,4 @@ -import {isFunc} from "./is" +import {isFunc} from "../../utils/is" import * as sdk from "@onflow/sdk" import * as t from "@onflow/types" diff --git a/packages/fcl/src/exec/utils/pre.js b/packages/fcl/src/exec/utils/pre.js index 6057553dc..a92962836 100644 --- a/packages/fcl/src/exec/utils/pre.js +++ b/packages/fcl/src/exec/utils/pre.js @@ -1,6 +1,6 @@ import {invariant} from "@onflow/util-invariant" import * as sdk from "@onflow/sdk" -import {isRequired, isObject, isString} from "./is" +import {isRequired, isObject, isString} from "../../utils/is" async function pre(type, opts) { // prettier-ignore diff --git a/packages/fcl/src/exec/utils/prep-template-opts.js b/packages/fcl/src/exec/utils/prep-template-opts.js index 66db578b5..29f5e0bc6 100644 --- a/packages/fcl/src/exec/utils/prep-template-opts.js +++ b/packages/fcl/src/exec/utils/prep-template-opts.js @@ -2,7 +2,7 @@ import {retrieve} from "../../document/document.js" import {normalizeInteractionTemplate} from "../../normalizers/interaction-template/interaction-template" import {deriveCadenceByNetwork} from "../../interaction-template-utils/derive-cadence-by-network.js" import {deriveDependencies} from "./derive-dependencies" -import {isString} from "./is" +import {isString} from "../../utils/is" import {getChainId} from "../../utils" export async function prepTemplateOpts(opts) { diff --git a/packages/fcl/src/exec/utils/is.js b/packages/fcl/src/utils/is.js similarity index 100% rename from packages/fcl/src/exec/utils/is.js rename to packages/fcl/src/utils/is.js From 06846f8e9c1e2cdf10aa8dfdff6e6c5b31af81e5 Mon Sep 17 00:00:00 2001 From: Jeff Doyle Date: Mon, 30 Oct 2023 16:51:15 -0700 Subject: [PATCH 2/2] PKG -- [sdk] Refactor Resolve Accounts (#1532) * PKG -- [sdk] Refactor Resolve Accounts to user role based async decomposition for resolving internal accounts * PKG -- [sdk] Adds reusable accountId generation mechanic in resolve-accounts * PKG -- [sdk] Adds reusable accountId generation mechanic in resolve-accounts * PKG -- [sdk] Adds reusable accountId generation mechanic in resolve-accounts * PKG -- [sdk] Ensure role base deduplication for each role * PKG -- [sdk] Adds changeset * PKG -- [sdk] Removes console.log from test * PKG -- [transport-http] Fixes broken test * PKG -- [sdk] Rename variable * PKG -- [sdk] Regenerate package-lock * PKG -- [sdk] Rename resolved accounts variable * PKG -- [sdk] Adds additional test * PKG -- [sdk] Adds resolve account test cases for payer from pre-authz and not * PKG -- [sdk] Allow multiple authorization functions to be passed in for payer * PKG -- [sdk] Adds test case for multiple payer authorizations * PKG -- [sdk] Adds deep resolve test case * PKG -- [sdk] Ensure deep resolve-accounts resolve successfully * PKG -- [sdk] Adds deep resolve testcase * PKG -- [sdk] Adds depth limit of 5 to resolve accounts recursion * PKG -- [sdk] Adds deep authz resolve util * PKG -- [sdk] fixed infinite loop (#1673) * OPS -- [sdk] workaround in test * PKG -- [sdk] Correct invariant function name * PKG -- [sdk] Updates resolve-account to cache resolve requests per account, adds debugger * PKG -- [sdk] fixed tests (#1708) * PKG -- [sdk] fixed tests * VSN -- [sdk] changeset * fixed types * check for duplicates * pre accounts * version * fixed signature resolver * revert changes for loop * add comments for alternative approach * fix tests * changeset * accounts version * update lock * exit pre * replace uuid with standard library * test with multiple authorizers --------- Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Co-authored-by: Alex Ni <12097569+nialexsan@users.noreply.github.com> --- .changeset/big-mangos-explode.md | 6 + .changeset/brave-mirrors-report.md | 7 + .changeset/lemon-adults-shout.md | 5 + .changeset/pre.json | 32 + .changeset/wet-chicken-unite.md | 9 + package-lock.json | 667 ++++++++++++++---- packages/fcl-wc/CHANGELOG.md | 17 +- packages/fcl-wc/package.json | 4 +- packages/fcl/CHANGELOG.md | 22 +- packages/fcl/package.json | 5 +- packages/sdk/CHANGELOG.md | 22 + packages/sdk/package.json | 7 +- packages/sdk/src/build/build-payer.js | 11 +- packages/sdk/src/interaction/interaction.js | 8 +- .../__tests__/resolve-accounts.test.js | 75 ++ packages/sdk/src/resolve/resolve-accounts.js | 357 +++++++--- .../sdk/src/resolve/resolve-accounts.test.js | 309 +++++++- .../sdk/src/resolve/resolve-signatures.js | 16 +- packages/sdk/src/test-utils/authz-fn.js | 15 + packages/sdk/src/test-utils/index.js | 9 +- packages/transport-grpc/CHANGELOG.md | 6 + packages/transport-grpc/package.json | 4 +- packages/transport-http/CHANGELOG.md | 14 + packages/transport-http/package.json | 4 +- .../transport-http/src/send-transaction.js | 10 +- .../src/send-transaction.test.js | 140 ++-- 26 files changed, 1442 insertions(+), 339 deletions(-) create mode 100644 .changeset/big-mangos-explode.md create mode 100644 .changeset/brave-mirrors-report.md create mode 100644 .changeset/lemon-adults-shout.md create mode 100644 .changeset/pre.json create mode 100644 .changeset/wet-chicken-unite.md diff --git a/.changeset/big-mangos-explode.md b/.changeset/big-mangos-explode.md new file mode 100644 index 000000000..de27106a9 --- /dev/null +++ b/.changeset/big-mangos-explode.md @@ -0,0 +1,6 @@ +--- +"@onflow/transport-http": patch +"@onflow/sdk": patch +--- + +Updated packages diff --git a/.changeset/brave-mirrors-report.md b/.changeset/brave-mirrors-report.md new file mode 100644 index 000000000..5a9100b55 --- /dev/null +++ b/.changeset/brave-mirrors-report.md @@ -0,0 +1,7 @@ +--- +"@onflow/transport-http": patch +"@onflow/fcl": patch +"@onflow/sdk": patch +--- + +testing refactored accounts resolver diff --git a/.changeset/lemon-adults-shout.md b/.changeset/lemon-adults-shout.md new file mode 100644 index 000000000..599b43277 --- /dev/null +++ b/.changeset/lemon-adults-shout.md @@ -0,0 +1,5 @@ +--- +"@onflow/sdk": patch +--- + +Refactor Resolve Accounts to user role based async decomposition for resolving internal accounts diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..a1d75e764 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,32 @@ +{ + "mode": "exit", + "tag": "accounts", + "initialVersions": { + "@onflow/config": "1.1.1", + "@onflow/fcl": "1.5.2", + "@onflow/fcl-bundle": "1.3.1", + "@onflow/fcl-wc": "3.0.0", + "@onflow/protobuf": "1.2.1", + "@onflow/rlp": "1.1.0", + "@onflow/sdk": "1.2.2", + "@onflow/transport-grpc": "1.2.1", + "@onflow/transport-http": "1.7.1", + "@onflow/typedefs": "1.1.1", + "@onflow/types": "1.1.0", + "@onflow/util-actor": "1.2.0", + "@onflow/util-address": "1.1.0", + "@onflow/util-encode-key": "1.1.0", + "@onflow/util-invariant": "1.1.0", + "@onflow/util-logger": "1.2.1", + "@onflow/util-template": "1.1.0", + "@onflow/util-uid": "1.1.0" + }, + "changesets": [ + "big-mangos-explode", + "brave-mirrors-report", + "lemon-adults-shout", + "six-cherries-clap", + "slow-peaches-vanish", + "wet-chicken-unite" + ] +} diff --git a/.changeset/wet-chicken-unite.md b/.changeset/wet-chicken-unite.md new file mode 100644 index 000000000..422dabe01 --- /dev/null +++ b/.changeset/wet-chicken-unite.md @@ -0,0 +1,9 @@ +--- +"@onflow/transport-grpc": patch +"@onflow/transport-http": patch +"@onflow/fcl-wc": patch +"@onflow/fcl": patch +"@onflow/sdk": patch +--- + +fixed sig resolution diff --git a/package-lock.json b/package-lock.json index 60c5978ee..7e45b3aef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,13 @@ "prettier": "^2.6.2" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "license": "Apache-2.0", @@ -163,7 +170,7 @@ "license": "ISC" }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.22.6", + "version": "7.22.9", "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", @@ -171,10 +178,10 @@ "@babel/helper-function-name": "^7.22.5", "@babel/helper-member-expression-to-functions": "^7.22.5", "@babel/helper-optimise-call-expression": "^7.22.5", - "@babel/helper-replace-supers": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.9", "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@nicolo-ribaudo/semver-v6": "^6.3.3" + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -183,6 +190,13 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-regexp-features-plugin": { "version": "7.21.0", "license": "MIT", @@ -328,18 +342,18 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.22.5", + "version": "7.22.9", "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-member-expression-to-functions": "^7.22.5", - "@babel/helper-optimise-call-expression": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-optimise-call-expression": "^7.22.5" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-simple-access": { @@ -1552,12 +1566,12 @@ "license": "MIT" }, "node_modules/@changesets/apply-release-plan": { - "version": "6.1.3", + "version": "6.1.4", "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/config": "^2.3.0", + "@changesets/config": "^2.3.1", "@changesets/get-version-range-type": "^0.3.2", "@changesets/git": "^2.0.0", "@changesets/types": "^5.2.1", @@ -1568,20 +1582,70 @@ "outdent": "^0.5.0", "prettier": "^2.7.1", "resolve-from": "^5.0.0", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/apply-release-plan/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/apply-release-plan/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/assemble-release-plan": { - "version": "5.2.3", + "version": "5.2.4", "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", + "@changesets/get-dependents-graph": "^1.3.6", "@changesets/types": "^5.2.1", "@manypkg/get-packages": "^1.1.3", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/assemble-release-plan/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/assemble-release-plan/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/changelog-git": { @@ -1603,18 +1667,18 @@ } }, "node_modules/@changesets/cli": { - "version": "2.26.0", + "version": "2.26.2", "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/apply-release-plan": "^6.1.3", - "@changesets/assemble-release-plan": "^5.2.3", + "@changesets/apply-release-plan": "^6.1.4", + "@changesets/assemble-release-plan": "^5.2.4", "@changesets/changelog-git": "^0.1.14", - "@changesets/config": "^2.3.0", + "@changesets/config": "^2.3.1", "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", - "@changesets/get-release-plan": "^3.0.16", + "@changesets/get-dependents-graph": "^1.3.6", + "@changesets/get-release-plan": "^3.0.17", "@changesets/git": "^2.0.0", "@changesets/logger": "^0.0.5", "@changesets/pre": "^1.0.14", @@ -1623,7 +1687,7 @@ "@changesets/write": "^0.2.3", "@manypkg/get-packages": "^1.1.3", "@types/is-ci": "^3.0.0", - "@types/semver": "^6.0.0", + "@types/semver": "^7.5.0", "ansi-colors": "^4.1.3", "chalk": "^2.1.0", "enquirer": "^2.3.0", @@ -1636,7 +1700,7 @@ "p-limit": "^2.2.0", "preferred-pm": "^3.0.0", "resolve-from": "^5.0.0", - "semver": "^5.4.1", + "semver": "^7.5.3", "spawndamnit": "^2.0.0", "term-size": "^2.1.0", "tty-table": "^4.1.5" @@ -1645,13 +1709,38 @@ "changeset": "bin.js" } }, + "node_modules/@changesets/cli/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/cli/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@changesets/config": { - "version": "2.3.0", + "version": "2.3.1", "dev": true, "license": "MIT", "dependencies": { "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", + "@changesets/get-dependents-graph": "^1.3.6", "@changesets/logger": "^0.0.5", "@changesets/types": "^5.2.1", "@manypkg/get-packages": "^1.1.3", @@ -1668,7 +1757,7 @@ } }, "node_modules/@changesets/get-dependents-graph": { - "version": "1.3.5", + "version": "1.3.6", "dev": true, "license": "MIT", "dependencies": { @@ -1676,7 +1765,32 @@ "@manypkg/get-packages": "^1.1.3", "chalk": "^2.1.0", "fs-extra": "^7.0.1", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/get-dependents-graph/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/get-dependents-graph/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/get-github-info": { @@ -1689,13 +1803,13 @@ } }, "node_modules/@changesets/get-release-plan": { - "version": "3.0.16", + "version": "3.0.17", "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/assemble-release-plan": "^5.2.3", - "@changesets/config": "^2.3.0", + "@changesets/assemble-release-plan": "^5.2.4", + "@changesets/config": "^2.3.1", "@changesets/pre": "^1.0.14", "@changesets/read": "^0.5.9", "@changesets/types": "^5.2.1", @@ -1826,13 +1940,33 @@ "node": "^14 || ^16 || ^17 || ^18 || ^19" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.6.2", + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.0.0", + "version": "2.1.2", "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -1862,7 +1996,7 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", + "version": "8.47.0", "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1874,7 +2008,7 @@ "license": "MIT" }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", + "version": "0.11.10", "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -3543,13 +3677,6 @@ "tslib": "^2.3.1" } }, - "node_modules/@nicolo-ribaudo/semver-v6": { - "version": "6.3.3", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -5078,7 +5205,7 @@ "license": "MIT" }, "node_modules/@types/semver": { - "version": "6.2.3", + "version": "7.5.0", "dev": true, "license": "MIT" }, @@ -5620,7 +5747,7 @@ } }, "node_modules/acorn": { - "version": "8.8.2", + "version": "8.10.0", "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -5791,6 +5918,14 @@ "dev": true, "license": "ISC" }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/are-we-there-yet": { "version": "3.0.1", "dev": true, @@ -8155,24 +8290,25 @@ } }, "node_modules/eslint": { - "version": "8.35.0", + "version": "8.47.0", "license": "MIT", "dependencies": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -8180,23 +8316,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -8266,7 +8398,7 @@ } }, "node_modules/eslint-scope": { - "version": "7.1.1", + "version": "7.2.2", "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", @@ -8274,33 +8406,13 @@ }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "license": "Apache-2.0", - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.1", + "version": "3.4.3", "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -8455,12 +8567,12 @@ } }, "node_modules/espree": { - "version": "9.4.1", + "version": "9.6.1", "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -9560,7 +9672,7 @@ } }, "node_modules/globals": { - "version": "13.20.0", + "version": "13.21.0", "license": "MIT", "dependencies": { "type-fest": "^0.20.2" @@ -9627,6 +9739,11 @@ }, "node_modules/grapheme-splitter": { "version": "1.0.4", + "dev": true, + "license": "MIT" + }, + "node_modules/graphemer": { + "version": "1.4.0", "license": "MIT" }, "node_modules/growly": { @@ -12328,14 +12445,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sdsl": { - "version": "4.3.0", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "license": "MIT" @@ -12915,6 +13024,18 @@ "dev": true, "license": "MIT" }, + "node_modules/lerna/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/lerna/node_modules/universalify": { "version": "2.0.0", "dev": true, @@ -15115,15 +15236,15 @@ } }, "node_modules/optionator": { - "version": "0.9.1", + "version": "0.9.3", "license": "MIT", "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -16606,16 +16727,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/regexpu-core": { "version": "5.3.1", "license": "MIT", @@ -18118,15 +18229,17 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "4.9.5", + "version": "5.1.6", "dev": true, "license": "Apache-2.0", + "optional": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uglify-js": { @@ -18557,6 +18670,7 @@ }, "node_modules/word-wrap": { "version": "1.2.3", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -18858,7 +18972,7 @@ }, "packages/config": { "name": "@onflow/config", - "version": "1.1.1-alpha.0", + "version": "1.1.2", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -18867,7 +18981,7 @@ "eslint-plugin-jsdoc": "^40.0.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", "@types/estree": "^1.0.1", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -18925,28 +19039,41 @@ "node": ">=10" } }, + "packages/config/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.5.0-alpha.3", + "version": "1.6.0-accounts.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0", + "@onflow/config": "^1.1.2", "@onflow/interaction": "0.0.11", "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.1-alpha.0", + "@onflow/sdk": "^1.2.3-accounts.1", "@onflow/types": "^1.1.0", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", + "@onflow/util-logger": "^1.2.2", "@onflow/util-template": "^1.1.0", "@onflow/util-uid": "^1.1.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/typedefs": "^1.1.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", + "@onflow/typedefs": "^1.1.1", + "@types/estree": "^1.0.1", "@types/node": "^18.13.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", @@ -18981,7 +19108,7 @@ }, "packages/fcl-bundle": { "name": "@onflow/fcl-bundle", - "version": "1.3.1-alpha.0", + "version": "1.3.1", "license": "Apache-2.0", "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", @@ -19009,25 +19136,25 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "3.0.0-alpha.2", + "version": "4.0.0-accounts.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.1-alpha.0", + "@onflow/config": "^1.1.2", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", + "@onflow/util-logger": "^1.2.2", "@walletconnect/modal": "^2.4.7", "@walletconnect/sign-client": "^2.8.1", "@walletconnect/types": "^2.8.1", "@walletconnect/utils": "^2.8.1" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl": "^1.5.0-alpha.3" + "@onflow/fcl": "^1.6.0-accounts.1" } }, "packages/fcl/node_modules/eslint-plugin-jsdoc": { @@ -19086,9 +19213,21 @@ "node": ">=10" } }, + "packages/fcl/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/protobuf": { "name": "@onflow/protobuf", - "version": "1.2.1-alpha.0", + "version": "1.2.1", "license": "Apache-2.0", "dependencies": { "@improbable-eng/grpc-web": "^0.12.0", @@ -19567,24 +19706,25 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.2.1-alpha.0", + "version": "1.2.3-accounts.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0", + "@onflow/config": "^1.1.1", "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.0-alpha.0", + "@onflow/transport-http": "^1.7.2-accounts.1", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", + "@onflow/util-logger": "^1.2.1", "@onflow/util-template": "^1.1.0", "deepmerge": "^4.2.2", - "sha3": "^2.1.4" + "sha3": "^2.1.4", + "uuid": "^9.0.1" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/typedefs": "^1.1.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", + "@onflow/typedefs": "^1.1.1", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", @@ -19647,23 +19787,47 @@ "node": ">=10" } }, + "packages/sdk/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "packages/sdk/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "packages/transport-grpc": { "name": "@onflow/transport-grpc", - "version": "1.2.1-alpha.0", + "version": "1.2.2-accounts.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@improbable-eng/grpc-web": "^0.14.0", "@improbable-eng/grpc-web-node-http-transport": "^0.14.0", - "@onflow/protobuf": "^1.2.1-alpha.0", + "@onflow/protobuf": "^1.2.1", "@onflow/rlp": "^1.1.0", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", "@onflow/util-template": "^1.1.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/sdk": "^1.2.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", + "@onflow/sdk": "^1.2.3-accounts.1", "jest": "^29.5.0" } }, @@ -19691,34 +19855,34 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.7.0-alpha.0", + "version": "1.7.2-accounts.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", + "@onflow/util-logger": "^1.2.1", "@onflow/util-template": "^1.1.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.1-alpha.0", + "@onflow/sdk": "^1.2.3-accounts.1", "@onflow/types": "^1.1.0", "jest": "^29.5.0" } }, "packages/typedefs": { "name": "@onflow/typedefs", - "version": "1.1.1-alpha.0", + "version": "1.1.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", @@ -19727,6 +19891,18 @@ "typescript": "^4.9.5" } }, + "packages/typedefs/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/types": { "name": "@onflow/types", "version": "1.1.0", @@ -19769,6 +19945,105 @@ "typescript": "^4.9.5" } }, + "packages/util-address/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "dev": true, + "license": "MIT", + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-address/node_modules/comment-parser": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-address/node_modules/escape-string-regexp": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-address/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-address/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-address/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-address/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-address/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/util-encode-key": { "name": "@onflow/util-encode-key", "version": "1.1.0", @@ -19788,6 +20063,105 @@ "typescript": "^4.9.5" } }, + "packages/util-encode-key/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "dev": true, + "license": "MIT", + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-encode-key/node_modules/comment-parser": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-encode-key/node_modules/escape-string-regexp": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-encode-key/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-encode-key/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-encode-key/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-encode-key/node_modules/semver": { + "version": "7.5.4", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-encode-key/node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "packages/util-invariant": { "name": "@onflow/util-invariant", "version": "1.1.0", @@ -19803,15 +20177,22 @@ }, "packages/util-logger": { "name": "@onflow/util-logger", - "version": "1.2.1-alpha.0", + "version": "1.2.2", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0" + "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.3.1", "jest": "^29.5.0" + }, + "peerDependencies": { + "@onflow/util-config": ">1.1.1" + }, + "peerDependenciesMeta": { + "@onflow/util-config": { + "optional": true + } } }, "packages/util-template": { diff --git a/packages/fcl-wc/CHANGELOG.md b/packages/fcl-wc/CHANGELOG.md index 612d3c282..9b5ef0375 100644 --- a/packages/fcl-wc/CHANGELOG.md +++ b/packages/fcl-wc/CHANGELOG.md @@ -1,13 +1,20 @@ # @onflow/fcl-wc -## 4.0.0 +## 4.0.0-accounts.1 ### Patch Changes -- Updated dependencies [[`3c99c856`](https://github.com/onflow/fcl-js/commit/3c99c8560f61b5b38238cbd0e93814936aee282e), [`5edbd823`](https://github.com/onflow/fcl-js/commit/5edbd823b1a6d25eb7bb52dc55338f95beae73b1)]: - - @onflow/fcl@1.6.0 - - @onflow/util-logger@1.2.2 - - @onflow/config@1.1.2 +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - fixed sig resolution + +- Updated dependencies [[`e0d0d144`](https://github.com/onflow/fcl-js/commit/e0d0d1449524f4c65e3f7a263b5c0a3ab5ac4a89), [`3d037e84`](https://github.com/onflow/fcl-js/commit/3d037e8470d56935bbc07ad7177ac40907def660), [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789)]: + - @onflow/fcl@1.6.0-accounts.1 + +## 3.0.1-accounts.0 + +### Patch Changes + +- Updated dependencies []: + - @onflow/fcl@1.5.3-accounts.0 ## 3.0.0 diff --git a/packages/fcl-wc/package.json b/packages/fcl-wc/package.json index b2bce4dd5..e2c398411 100644 --- a/packages/fcl-wc/package.json +++ b/packages/fcl-wc/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/fcl-wc", - "version": "4.0.0", + "version": "4.0.0-accounts.1", "description": "WalletConnect adapter for FCL", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -40,6 +40,6 @@ "@walletconnect/utils": "^2.8.1" }, "peerDependencies": { - "@onflow/fcl": "^1.6.0" + "@onflow/fcl": "^1.6.0-accounts.1" } } \ No newline at end of file diff --git a/packages/fcl/CHANGELOG.md b/packages/fcl/CHANGELOG.md index 9dcb3b080..3cba68d25 100644 --- a/packages/fcl/CHANGELOG.md +++ b/packages/fcl/CHANGELOG.md @@ -1,16 +1,28 @@ # @onflow/fcl -## 1.6.0 +## 1.6.0-accounts.1 ### Minor Changes -- [#1763](https://github.com/onflow/fcl-js/pull/1763) [`3c99c856`](https://github.com/onflow/fcl-js/commit/3c99c8560f61b5b38238cbd0e93814936aee282e) Thanks [@jribbink](https://github.com/jribbink)! - Add VIEW/DEEPLINK +- [#1775](https://github.com/onflow/fcl-js/pull/1775) [`e0d0d144`](https://github.com/onflow/fcl-js/commit/e0d0d1449524f4c65e3f7a263b5c0a3ab5ac4a89) Thanks [@chasefleming](https://github.com/chasefleming)! - Send suggested features to discovery + +- [#1782](https://github.com/onflow/fcl-js/pull/1782) [`3d037e84`](https://github.com/onflow/fcl-js/commit/3d037e8470d56935bbc07ad7177ac40907def660) Thanks [@jribbink](https://github.com/jribbink)! - Use localStorage as default & export LOCAL_STORAGE/SESSION_STORAGE as helpers for fcl.storage.default configuration key ### Patch Changes -- Updated dependencies [[`5edbd823`](https://github.com/onflow/fcl-js/commit/5edbd823b1a6d25eb7bb52dc55338f95beae73b1)]: - - @onflow/util-logger@1.2.2 - - @onflow/config@1.1.2 +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - fixed sig resolution + +- Updated dependencies [[`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789)]: + - @onflow/sdk@1.2.3-accounts.1 + +## 1.5.3-accounts.0 + +### Patch Changes + +- testing refactored accounts resolver + +- Updated dependencies [[`f5f185b7`](https://github.com/onflow/fcl-js/commit/f5f185b7e18f19b1b2b2abe335050b0ba80b594f), [`6f4a0067`](https://github.com/onflow/fcl-js/commit/6f4a006712e94089c3e0ffbcb1cfbf625ab8d18f)]: + - @onflow/sdk@1.2.3-accounts.0 ## 1.5.2 diff --git a/packages/fcl/package.json b/packages/fcl/package.json index f81994819..baeb34553 100644 --- a/packages/fcl/package.json +++ b/packages/fcl/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/fcl", - "version": "1.6.0", + "version": "1.6.0-accounts.1", "description": "Flow Client Library", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -21,6 +21,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.3.1", "@onflow/typedefs": "^1.1.1", + "@types/estree": "^1.0.1", "@types/node": "^18.13.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", @@ -60,7 +61,7 @@ "@onflow/config": "^1.1.2", "@onflow/interaction": "0.0.11", "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.2", + "@onflow/sdk": "^1.2.3-accounts.1", "@onflow/types": "^1.1.0", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index f8358f112..827f52091 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,27 @@ # @onflow/sdk +## 1.2.3-accounts.1 + +### Patch Changes + +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - fixed sig resolution + +- Updated dependencies [[`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789)]: + - @onflow/transport-http@1.7.2-accounts.1 + +## 1.2.3-accounts.0 + +### Patch Changes + +- [#1708](https://github.com/onflow/fcl-js/pull/1708) [`f5f185b7`](https://github.com/onflow/fcl-js/commit/f5f185b7e18f19b1b2b2abe335050b0ba80b594f) Thanks [@nialexsan](https://github.com/nialexsan)! - Updated packages + +- testing refactored accounts resolver + +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`6f4a0067`](https://github.com/onflow/fcl-js/commit/6f4a006712e94089c3e0ffbcb1cfbf625ab8d18f) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - Refactor Resolve Accounts to user role based async decomposition for resolving internal accounts + +- Updated dependencies [[`f5f185b7`](https://github.com/onflow/fcl-js/commit/f5f185b7e18f19b1b2b2abe335050b0ba80b594f)]: + - @onflow/transport-http@1.7.2-accounts.0 + ## 1.2.2 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index c0b7c8913..3c276e47d 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/sdk", - "version": "1.2.2", + "version": "1.2.3-accounts.1", "description": "Flow SDK", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -44,13 +44,14 @@ "@babel/runtime": "^7.18.6", "@onflow/config": "^1.1.1", "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.1", + "@onflow/transport-http": "^1.7.2-accounts.1", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", "@onflow/util-logger": "^1.2.1", "@onflow/util-template": "^1.1.0", "deepmerge": "^4.2.2", - "sha3": "^2.1.4" + "sha3": "^2.1.4", + "uuid": "^9.0.1" } } diff --git a/packages/sdk/src/build/build-payer.js b/packages/sdk/src/build/build-payer.js index b088c527a..7e27fa817 100644 --- a/packages/sdk/src/build/build-payer.js +++ b/packages/sdk/src/build/build-payer.js @@ -1,5 +1,10 @@ -import {prepAccount, PAYER} from "../interaction/interaction.js" +import {pipe, prepAccount, PAYER} from "../interaction/interaction.js" -export async function payer(authz) { - return prepAccount(authz, {role: PAYER}) +export function payer(ax = []) { + if (!Array.isArray(ax)) ax = [ax] + return pipe( + ax.map(authz => { + return prepAccount(authz, {role: PAYER}) + }) + ) } diff --git a/packages/sdk/src/interaction/interaction.js b/packages/sdk/src/interaction/interaction.js index 8dca33b36..703ba18f6 100644 --- a/packages/sdk/src/interaction/interaction.js +++ b/packages/sdk/src/interaction/interaction.js @@ -1,4 +1,5 @@ import {invariant} from "@onflow/util-invariant" +import {v4 as uuidv4} from "uuid" export const UNKNOWN /* */ = "UNKNOWN" export const SCRIPT /* */ = "SCRIPT" @@ -108,9 +109,6 @@ const KEYS = new Set(Object.keys(JSON.parse(IX))) export const interaction = () => JSON.parse(IX) -const CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".split("") -const randChar = () => CHARS[~~(Math.random() * CHARS.length)] -export const uuid = () => Array.from({length: 10}, randChar).join("") export const isNumber = d => typeof d === "number" export const isArray = d => Array.isArray(d) export const isObj = d => d !== null && typeof d === "object" @@ -158,7 +156,7 @@ export const prepAccount = (acct, opts = {}) => ix => { const ACCOUNT = JSON.parse(ACCT) const role = opts.role - const tempId = uuid() + const tempId = uuidv4() if (acct.authorization && isFn(acct.authorization)) acct = {resolve: acct.authorization} @@ -196,7 +194,7 @@ export const prepAccount = (acct, opts = {}) => ix => { } export const makeArgument = arg => ix => { - let tempId = uuid() + let tempId = uuidv4() ix.message.arguments.push(tempId) ix.arguments[tempId] = JSON.parse(ARG) diff --git a/packages/sdk/src/resolve/__tests__/resolve-accounts.test.js b/packages/sdk/src/resolve/__tests__/resolve-accounts.test.js index b1cf2d8ac..1cf452395 100644 --- a/packages/sdk/src/resolve/__tests__/resolve-accounts.test.js +++ b/packages/sdk/src/resolve/__tests__/resolve-accounts.test.js @@ -170,3 +170,78 @@ test("The PreAuthz Usecase - mixed signatories (wallet covers transaction fees)" } ) }) + +test("Deep resolve usecase - multiple layer deep resolves on account", async () => { + await config.overload( + { + "sdk.transport": TestUtils.mockSend(), + "debug.accounts": false, + }, + async c => { + const authz = TestUtils.authzDeepResolveMany({ + tempId: "CURRENT_USER", + proposer: S1a, + authorizations: [S1a, S1b, S1c], + payer: S2a, // wallet covers transaction + }) + + var ix = await TestUtils.run([ + sdk.transaction`CODE`, + sdk.proposer(authz), + sdk.payer(authz), + sdk.authorizations([authz]), + ]) + + // Four Signatories + expect(Object.keys(ix.accounts).length).toBe(4) + expect(ix.accounts[TestUtils.idof(S1a)]).toBeDefined() + expect(ix.accounts[TestUtils.idof(S1b)]).toBeDefined() + expect(ix.accounts[TestUtils.idof(S1c)]).toBeDefined() + expect(ix.accounts[TestUtils.idof(S2a)]).toBeDefined() + + expect(ix.proposer).toBe(TestUtils.idof(S1a)) + expect(ix.payer).toEqual([TestUtils.idof(S2a)]) + + expect(ix.authorizations.length).toBe(3) + expect(ix.authorizations).toEqual([ + TestUtils.idof(S1a), + TestUtils.idof(S1b), + TestUtils.idof(S1c), + ]) + } + ) +}) + +test.skip("Deep resolve usecase - excess resolves throw an eror", async () => { + await config.overload( + { + "sdk.transport": TestUtils.mockSend(), + "debug.accounts": false, + }, + async c => { + const authz = TestUtils.authzDeepResolveMany( + { + tempId: "CURRENT_USER", + proposer: S1a, + authorizations: [S1a, S1b, S1c], + payer: S2a, // wallet covers transaction + }, + 5 + ) + // expect(...).toThrow doesn't work in this case + let error + try{ + await TestUtils.run([ + sdk.transaction`CODE`, + sdk.proposer(authz), + sdk.payer(authz), + sdk.authorizations([authz]), + ]) + } catch (e){ + error = e + + } + expect(error).toMatchInlineSnapshot("[Error: recurseResolveAccount Error: Depth limit (5) reached. Ensure your authorization functions resolve to an account after 5 resolves.]") + } + ) +}) diff --git a/packages/sdk/src/resolve/resolve-accounts.js b/packages/sdk/src/resolve/resolve-accounts.js index a94c05f2c..8376d8e55 100644 --- a/packages/sdk/src/resolve/resolve-accounts.js +++ b/packages/sdk/src/resolve/resolve-accounts.js @@ -3,9 +3,51 @@ import {invariant} from "@onflow/util-invariant" import {log} from "@onflow/util-logger" import {isTransaction} from "../interaction/interaction.js" import {createSignableVoucher} from "./voucher.js" +import {v4 as uuidv4} from "uuid" + +const MAX_DEPTH_LIMIT = 5 const idof = acct => `${withPrefix(acct.addr)}-${acct.keyId}` -const isFn = v => typeof v === "function" +const isFn = v => + v && + (Object.prototype.toString.call(v) === "[object Function]" || + "function" === typeof v || + v instanceof Function) + +const genAccountId = (...ids) => ids.join("-") + +const ROLES = { + PAYER: "payer", + PROPOSER: "proposer", + AUTHORIZATIONS: "authorizations", +} + +function debug() { + const SPACE = " " + const SPACE_COUNT_PER_INDENT = 4 + const DEBUG_MESSAGE = [] + return [ + function (msg, indent = 0) { + DEBUG_MESSAGE.push( + Array(indent * SPACE_COUNT_PER_INDENT) + .fill(SPACE) + .join("-") + msg + ) + }, + function () { + return DEBUG_MESSAGE.reduce((prev, curr) => prev + "\n" + curr) + }, + ] +} + +function recurseFlatMap(el, depthLimit = 3) { + if (depthLimit <= 0) return el + if (!Array.isArray(el)) return el + return recurseFlatMap( + el.flatMap(e => e), + depthLimit - 1 + ) +} export function buildPreSignable(acct, ix) { try { @@ -25,100 +67,235 @@ export function buildPreSignable(acct, ix) { } } -async function collectAccounts(ix, accounts, last, depth = 3) { - invariant(depth, "Account Resolve Recursion Limit Exceeded", {ix, accounts}) +async function removeUnusedIxAccounts(ix) { + const payerTempIds = Array.isArray(ix.payer) ? ix.payer : [ix.payer] + const authorizersTempIds = Array.isArray(ix.authorizations) + ? ix.authorizations + : [ix.authorizations] + const proposerTempIds = Array.isArray(ix.proposer) + ? ix.proposer + : [ix.proposer] - let authorizations = [] - for (let ax of accounts) { - let resolve = ax.resolve - ax.resolve = null - var old = last || ax - if (isFn(resolve)) ax = await resolve(ax, buildPreSignable(ax, ix)) + const ixAccountKeys = Object.keys(ix.accounts) + const uniqueTempIds = [ + ...new Set(payerTempIds.concat(authorizersTempIds, proposerTempIds)), + ] - if (Array.isArray(ax)) { - await collectAccounts(ix, ax, old, depth - 1) - } else { - if (ax.addr) { - ax.addr = sansPrefix(ax.addr) - } - if (ax.addr != null && ax.keyId != null) { - ax.tempId = idof(ax) - } - ix.accounts[ax.tempId] = ix.accounts[ax.tempId] || ax - ix.accounts[ax.tempId].role.proposer = - ix.accounts[ax.tempId].role.proposer || ax.role.proposer - ix.accounts[ax.tempId].role.payer = - ix.accounts[ax.tempId].role.payer || ax.role.payer - ix.accounts[ax.tempId].role.authorizer = - ix.accounts[ax.tempId].role.authorizer || ax.role.authorizer - - if (ix.accounts[ax.tempId].role.proposer && ix.proposer === old.tempId) { - ix.proposer = ax.tempId - } + for (const ixAccountKey of ixAccountKeys) { + if (!uniqueTempIds.find(id => id === ixAccountKey)) { + delete ix.accounts[ixAccountKey] + } + } +} - if (ix.accounts[ax.tempId].role.payer) { - if (Array.isArray(ix.payer)) { - ix.payer = Array.from( - new Set( - [...ix.payer, ax.tempId].map(d => - d === old.tempId ? ax.tempId : d - ) - ) - ) - } else { - ix.payer = Array.from( - new Set( - [ix.payer, ax.tempId].map(d => (d === old.tempId ? ax.tempId : d)) - ) - ) - } - if (ix.payer.length > 1) { - // remove payer dups based on addr and keyId - const dupList = [] - const payerAccts = [] - ix.payer = ix.payer.reduce((g, tempId) => { - const {addr} = ix.accounts[tempId] - const key = idof(ix.accounts[tempId]) - payerAccts.push(addr) - if (dupList.includes(key)) return g - dupList.push(key) - return [...g, tempId] - }, []) - const multiAccts = Array.from(new Set(payerAccts)) - if (multiAccts.length > 1) { - throw new Error("Payer can not be different accounts") - } - } - } +function addAccountToIx(ix, newAccount) { + if ( + typeof newAccount.addr === "string" && + (typeof newAccount.keyId === "number" || + typeof newAccount.keyId === "string") + ) { + newAccount.tempId = idof(newAccount) + } else { + newAccount.tempId = newAccount.tempId || uuidv4() + } + + const existingAccount = ix.accounts[newAccount.tempId] || newAccount + + if (!ix.accounts[newAccount.tempId]) { + ix.accounts[newAccount.tempId] = newAccount + } + + ix.accounts[newAccount.tempId].role.proposer = + existingAccount.role.proposer || newAccount.role.proposer + ix.accounts[newAccount.tempId].role.payer = + existingAccount.role.payer || newAccount.role.payer + ix.accounts[newAccount.tempId].role.authorizer = + existingAccount.role.authorizer || newAccount.role.authorizer + + return ix.accounts[newAccount.tempId] +} + +function uniqueAccountsFlatMap(accounts) { + const flatMapped = recurseFlatMap(accounts) + const seen = new Set() + + const uniqueAccountsFlatMapped = flatMapped + .map(account => { + const accountId = genAccountId( + account.tempId, + account.role.payer, + account.role.proposer, + account.role.authorizer, + account.role.param + ) + if (seen.has(accountId)) return null + seen.add(accountId) + return account + }) + .filter(e => e !== null) + + return uniqueAccountsFlatMapped +} + +async function recurseResolveAccount( + ix, + currentAccountTempId, + depthLimit = MAX_DEPTH_LIMIT, + {debugLogger} +) { + if (depthLimit <= 0) { + throw new Error( + `recurseResolveAccount Error: Depth limit (${MAX_DEPTH_LIMIT}) reached. Ensure your authorization functions resolve to an account after ${MAX_DEPTH_LIMIT} resolves.` + ) + } + + let account = ix.accounts[currentAccountTempId] + + if (!account) return null + + debugLogger( + `account: ${account.tempId}`, + Math.max(MAX_DEPTH_LIMIT - depthLimit, 0) + ) + + if (account?.resolve) { + if (isFn(account?.resolve)) { + debugLogger( + `account: ${account.tempId} -- cache MISS`, + Math.max(MAX_DEPTH_LIMIT - depthLimit, 0) + ) + + const {resolve, ...accountWithoutResolve} = account - if (ix.accounts[ax.tempId].role.authorizer) { - if (last) { - // do group replacement - authorizations = Array.from(new Set([...authorizations, ax.tempId])) - } else { - // do 1-1 replacement - ix.authorizations = ix.authorizations.map(d => - d === old.tempId ? ax.tempId : d + let resolvedAccounts = await resolve( + accountWithoutResolve, + buildPreSignable(accountWithoutResolve, ix) + ) + + resolvedAccounts = Array.isArray(resolvedAccounts) + ? resolvedAccounts + : [resolvedAccounts] + + let flatResolvedAccounts = recurseFlatMap(resolvedAccounts) + + flatResolvedAccounts = flatResolvedAccounts.map(flatResolvedAccount => + addAccountToIx(ix, flatResolvedAccount) + ) + + account.resolve = flatResolvedAccounts.map( + flatResolvedAccount => flatResolvedAccount.tempId + ) + + account = addAccountToIx(ix, account) + + const recursedAccounts = await Promise.all( + flatResolvedAccounts.map(async resolvedAccount => { + return await recurseResolveAccount( + ix, + resolvedAccount.tempId, + depthLimit - 1, + {debugLogger} ) - } - } + }) + ) + + return recursedAccounts + ? recurseFlatMap(recursedAccounts) + : account.tempId + } else { + debugLogger( + `account: ${account.tempId} -- cache HIT`, + Math.max(MAX_DEPTH_LIMIT - depthLimit, 0) + ) + + return account.resolve } - if (old.tempId != ax.tempId) delete ix.accounts[old.tempId] } + return account.tempId +} - if (last) { - // complete (flatmap) group replacement - ix.authorizations = ix.authorizations - .map(d => (d === last.tempId ? authorizations : d)) - .reduce( - (prev, curr) => - Array.isArray(curr) ? [...prev, ...curr] : [...prev, curr], - [] - ) +async function resolveAccountType(ix, type, {debugLogger}) { + invariant( + ix && typeof ix === "object", + "resolveAccountType Error: ix not defined" + ) + invariant( + type === ROLES.PAYER || + type === ROLES.PROPOSER || + type === ROLES.AUTHORIZATIONS, + "resolveAccountType Error: type must be 'payer', 'proposer' or 'authorizations'" + ) + + let accountTempIDs = Array.isArray(ix[type]) ? ix[type] : [ix[type]] + + let allResolvedAccounts = [] + for (let accountId of accountTempIDs) { + let account = ix.accounts[accountId] + invariant(account, `resolveAccountType Error: account not found`) + + let resolvedAccountTempIds = await recurseResolveAccount( + ix, + accountId, + MAX_DEPTH_LIMIT, + { + debugLogger, + } + ) + + resolvedAccountTempIds = Array.isArray(resolvedAccountTempIds) + ? resolvedAccountTempIds + : [resolvedAccountTempIds] + + let resolvedAccounts = resolvedAccountTempIds.map( + resolvedAccountTempId => ix.accounts[resolvedAccountTempId] + ) + + let flatResolvedAccounts = uniqueAccountsFlatMap(resolvedAccounts) + + allResolvedAccounts = allResolvedAccounts.concat(flatResolvedAccounts) + } + + invariant( + allResolvedAccounts.length > 0, + "resolveAccountType Error: failed to resolve any accounts" + ) + + if (type === ROLES.PAYER) { + allResolvedAccounts = allResolvedAccounts.filter( + acct => acct.role.payer === true + ) + } + if (type === ROLES.PROPOSER) { + allResolvedAccounts = allResolvedAccounts.filter( + acct => acct.role.proposer === true + ) + } + if (type === ROLES.AUTHORIZATIONS) { + allResolvedAccounts = allResolvedAccounts.filter( + acct => acct.role.authorizer === true + ) + } + + ix[type] = Array.isArray(ix[type]) + ? [...new Set(allResolvedAccounts.map(acct => acct.tempId))] + : allResolvedAccounts[0].tempId + + // Ensure all payers are of the same account + if (type === ROLES.PAYER) { + let address + for (const payerTempID of ix[ROLES.PAYER]) { + let pAcct = ix.accounts[payerTempID] + if (!address) address = pAcct.addr + else if (address !== pAcct.addr) { + throw new Error( + "resolveAccountType Error: payers from different accounts detected" + ) + } + } } } -export async function resolveAccounts(ix) { +export async function resolveAccounts(ix, opts = {}) { if (isTransaction(ix)) { if (!Array.isArray(ix.payer)) { log.deprecate({ @@ -128,9 +305,17 @@ export async function resolveAccounts(ix) { message: "See changelog for more info.", }) } + let [debugLogger, getDebugMessage] = debug() try { - await collectAccounts(ix, Object.values(ix.accounts)) - await collectAccounts(ix, Object.values(ix.accounts)) + await resolveAccountType(ix, ROLES.PROPOSER, {debugLogger}) + await resolveAccountType(ix, ROLES.AUTHORIZATIONS, {debugLogger}) + await resolveAccountType(ix, ROLES.PAYER, {debugLogger}) + + await removeUnusedIxAccounts(ix, {debugLogger}) + + if (opts.enableDebug) { + console.debug(getDebugMessage()) + } } catch (error) { console.error("=== SAD PANDA ===\n\n", error, "\n\n=== SAD PANDA ===") throw error diff --git a/packages/sdk/src/resolve/resolve-accounts.test.js b/packages/sdk/src/resolve/resolve-accounts.test.js index c50bd6378..c370bb93d 100644 --- a/packages/sdk/src/resolve/resolve-accounts.test.js +++ b/packages/sdk/src/resolve/resolve-accounts.test.js @@ -8,7 +8,7 @@ import { limit, authorizations, } from "../sdk.js" -import {buildPreSignable} from "./resolve-accounts" +import {buildPreSignable, resolveAccounts} from "./resolve-accounts" test("Voucher in PreSignable", async () => { const authz = { @@ -25,7 +25,6 @@ test("Voucher in PreSignable", async () => { authorizations([authz]), payer({ addr: "0x02", - tempId: "payerAcct", signingFunction: () => ({signature: "123"}), keyId: 0, sequenceNum: 123, @@ -55,7 +54,6 @@ test("Voucher in PreSignable", async () => { test("Voucher in PreSignable multiple payer keys", async () => { const authz = { addr: "0x01", - tempId: "0x01-1", signingFunction: () => ({signature: "123"}), keyId: 1, sequenceNum: 123, @@ -66,7 +64,6 @@ test("Voucher in PreSignable multiple payer keys", async () => { resolve: (account, preSignable) => [ { ...account, - tempId: "0x02-0", addr: "0x02", keyId: 0, sequenceNum: 123, @@ -78,7 +75,6 @@ test("Voucher in PreSignable multiple payer keys", async () => { }, { ...account, - tempId: "0x02-1", addr: "0x02", keyId: 1, sequenceNum: 123, @@ -127,7 +123,6 @@ test("Voucher in PreSignable multiple payer keys", async () => { test("Voucher in PreSignable multiple payer keys different accounts", async () => { const authz = { addr: "0x01", - tempId: "0x01-1", signingFunction: () => ({signature: "123"}), keyId: 1, sequenceNum: 123, @@ -139,7 +134,6 @@ test("Voucher in PreSignable multiple payer keys different accounts", async () = resolve: (account, preSignable) => [ { ...account, - tempId: "0x02-0", addr: "0x02", keyId: 0, sequenceNum: 123, @@ -151,7 +145,6 @@ test("Voucher in PreSignable multiple payer keys different accounts", async () = }, { ...account, - tempId: "0x01-1", addr: "0x01", keyId: 1, sequenceNum: 123, @@ -175,3 +168,303 @@ test("Voucher in PreSignable multiple payer keys different accounts", async () = await expect(resolve(built)).rejects.toThrow() }) + +test("mulitple payer scenario (One from dev and one from pre-authz)", async () => { + const authzPayer = { + addr: "0x01", + signingFunction: () => ({signature: "123"}), + keyId: 1, + sequenceNum: 123, + } + + const authz = { + kind: "ACCOUNT", + addr: null, + keyId: null, + signature: null, + signingFunction: null, + resolve: (account, preSignable) => [ + { + addr: "72f6325947f76d3a", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: true, payer: false, authorizer: false}, + }, + { + addr: "f086a545ce3c552d", + signingFunction: () => ({signature: "2"}), + keyId: 12, + role: {proposer: false, payer: true, authorizer: false}, + }, + { + addr: "72f6325947f76d3a", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: false, payer: false, authorizer: true}, + }, + ], + role: { + proposer: true, + authorizer: true, + payer: false, + param: false, + }, + } + + const built = await build([ + transaction``, + limit(156), + proposer(authz), + authorizations([authz]), + payer(authzPayer), + ref("123"), + ]) + + const ix = await resolve(built) + + const ps = buildPreSignable(ix.accounts[ix.proposer], ix) + + expect(ps.voucher).toEqual({ + cadence: "", + refBlock: "123", + computeLimit: 156, + arguments: [], + proposalKey: {address: "0x72f6325947f76d3a", keyId: 1, sequenceNum: 12}, + payer: "0x01", + authorizers: ["0x72f6325947f76d3a"], + payloadSigs: [ + {address: "0x72f6325947f76d3a", keyId: 1, sig: "1"}, + ], + envelopeSigs: [{address: "0x01", keyId: 1, sig: "123"}], + }) +}) + +test("mulitple payer scenario (One from dev and one from pre-authz) as array", async () => { + const authzPayer1 = { + addr: "0x01", + signingFunction: () => ({signature: "123"}), + keyId: 1, + sequenceNum: 123, + } + const authzPayer2 = { + addr: "0x01", + signingFunction: () => ({signature: "456"}), + keyId: 2, + sequenceNum: 456, + } + + const authz = { + kind: "ACCOUNT", + addr: null, + keyId: null, + signature: null, + signingFunction: null, + resolve: (account, preSignable) => [ + { + addr: "02", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: true, payer: false, authorizer: false}, + }, + { + addr: "01", + signingFunction: () => ({signature: "2"}), + keyId: 12, + role: {proposer: false, payer: true, authorizer: false}, + }, + { + addr: "02", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: false, payer: false, authorizer: true}, + }, + ], + role: { + proposer: true, + authorizer: true, + payer: false, + param: false, + }, + } + + const built = await build([ + transaction``, + limit(156), + proposer(authz), + authorizations([authz]), + payer([authzPayer1, authzPayer2]), + ref("123"), + ]) + + const ix = await resolve(built) + + const ps = buildPreSignable(ix.accounts[ix.proposer], ix) + + expect(ps.voucher).toEqual({ + cadence: "", + refBlock: "123", + computeLimit: 156, + arguments: [], + proposalKey: {address: "0x02", keyId: 1, sequenceNum: 12}, + payer: "0x01", + authorizers: ["0x02"], + payloadSigs: [ + {address: "0x02", keyId: 1, sig: "1"}, + ], + envelopeSigs: [ + {address: "0x01", keyId: 1, sig: "123"}, + {address: "0x01", keyId: 2, sig: "456"}, + ], + }) +}) + +test("payer from pre-authz", async () => { + const authz = { + kind: "ACCOUNT", + addr: null, + keyId: null, + signature: null, + signingFunction: null, + resolve: (account, preSignable) => [ + { + addr: "72f6325947f76d3a", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: true, payer: false, authorizer: false}, + }, + { + addr: "f086a545ce3c552d", + signingFunction: () => ({signature: "2"}), + keyId: 12, + role: {proposer: false, payer: true, authorizer: false}, + }, + { + addr: "72f6325947f76d3a", + sequenceNum: 12, + signingFunction: () => ({signature: "1"}), + keyId: 1, + role: {proposer: false, payer: false, authorizer: true}, + }, + ], + role: { + proposer: true, + authorizer: true, + payer: false, + param: false, + }, + } + + const built = await build([ + transaction``, + limit(156), + proposer(authz), + authorizations([authz]), + payer(authz), + ref("123"), + ]) + + const ix = await resolve(built) + + const ps = buildPreSignable(ix.accounts[ix.proposer], ix) + + expect(ps.voucher).toEqual({ + cadence: "", + refBlock: "123", + computeLimit: 156, + arguments: [], + proposalKey: {address: "0x72f6325947f76d3a", keyId: 1, sequenceNum: 12}, + payer: "0xf086a545ce3c552d", + authorizers: ["0x72f6325947f76d3a"], + payloadSigs: [ + {address: "0x72f6325947f76d3a", keyId: 1, sig: "1"}, + ], + envelopeSigs: [{address: "0xf086a545ce3c552d", keyId: 12, sig: "2"}], + }) +}) + +test("Voucher in PreSignable multiple payer keys and multiple authorizers", async () => { + const proposerAcc = { + addr: "0x04", + signingFunction: () => ({signature: "456"}), + keyId: 4, + sequenceNum: 345, + } + const authz1 = { + addr: "0x01", + signingFunction: () => ({signature: "123"}), + keyId: 1, + sequenceNum: 123, + } + const authz2 = { + addr: "0x03", + signingFunction: () => ({signature: "444"}), + keyId: 2, + sequenceNum: 234, + } + + const authzPayer = { + addr: "0x02", + resolve: (account, preSignable) => [ + { + ...account, + addr: "0x02", + keyId: 0, + sequenceNum: 123, + signingFunction: signable => ({ + signature: "123", + addr: "0x02", + keyId: 0, + }), + }, + { + ...account, + addr: "0x02", + keyId: 1, + sequenceNum: 123, + signingFunction: signable => ({ + signature: "333", + addr: "0x02", + keyId: 1, + }), + }, + ], + } + + const built = await build([ + transaction``, + limit(156), + proposer(proposerAcc), + authorizations([authz1, authz2]), + payer(authzPayer), + ref("123"), + ]) + + const ix = await resolve(built) + expect(ix.payer).toEqual(["0x02-0", "0x02-1"]) + + const ps = buildPreSignable(ix.accounts[ix.proposer], ix) + + expect(ps.voucher).toEqual({ + cadence: "", + refBlock: "123", + computeLimit: 156, + arguments: [], + proposalKey: {address: "0x04", keyId: 4, sequenceNum: 345}, + payer: "0x02", + authorizers: ["0x01", "0x03"], + payloadSigs: [ + {address: "0x01", keyId: 1, sig: "123"}, + {address: "0x03", keyId: 2, sig: "444"}, + {address: "0x04", keyId: 4, sig: "456"}, + ], + envelopeSigs: [ + {address: "0x02", keyId: 0, sig: "123"}, + {address: "0x02", keyId: 1, sig: "333"}, + ], + }) +}) diff --git a/packages/sdk/src/resolve/resolve-signatures.js b/packages/sdk/src/resolve/resolve-signatures.js index f6d37836c..83bf7f117 100644 --- a/packages/sdk/src/resolve/resolve-signatures.js +++ b/packages/sdk/src/resolve/resolve-signatures.js @@ -15,6 +15,13 @@ export async function resolveSignatures(ix) { try { let insideSigners = findInsideSigners(ix) const insidePayload = encodeInsideMessage(prepForEncoding(ix)) + + // Promise.all could potentially break the flow if there are multiple inside signers trying to resolve at the same time + // causing multiple triggers of authz function that tries to render multiple auth iiframes/tabs/extensions + // as an alternative, use this: + // for(const insideSigner of insideSigners) { + // await fetchSignature(ix, insidePayload)(insideSigner); + // } await Promise.all(insideSigners.map(fetchSignature(ix, insidePayload))) let outsideSigners = findOutsideSigners(ix) @@ -26,6 +33,13 @@ export async function resolveSignatures(ix) { sig: ix.accounts[id].signature, })), }) + + // Promise.all could potentially break the flow if there are multiple outside signers trying to resolve at the same time + // causing multiple triggers of authz function that tries to render multiple auth iframes/tabs/extensions + // as an alternative, use this: + // for(const outsideSigner of outsideSigners) { + // await fetchSignature(ix, outsidePayload)(outsideSigner); + // } await Promise.all(outsideSigners.map(fetchSignature(ix, outsidePayload))) } catch (error) { console.error("Signatures", error, {ix}) @@ -38,7 +52,7 @@ export async function resolveSignatures(ix) { function fetchSignature(ix, payload) { return async function innerFetchSignature(id) { const acct = ix.accounts[id] - if (acct.signature != null) return + if (acct.signature != null && acct.signature !== undefined) return const {signature} = await acct.signingFunction( buildSignable(acct, payload, ix) ) diff --git a/packages/sdk/src/test-utils/authz-fn.js b/packages/sdk/src/test-utils/authz-fn.js index fe5d93919..7085e4a89 100644 --- a/packages/sdk/src/test-utils/authz-fn.js +++ b/packages/sdk/src/test-utils/authz-fn.js @@ -11,6 +11,7 @@ export function authzFn(opts = {}) { const acct = { ...account, ...opts, + resolve: null, signingFunction: opts.signingFunction || account.signingFunction || @@ -61,3 +62,17 @@ export function authzResolveMany(opts = {}) { } } } + +export function authzDeepResolveMany(opts = {}, depth = 1) { + return function (account) { + const tempId = opts.tempId || "AUTHZ_DEEP_RESOLVE_MANY" + return { + ...account, + tempId, + resolve: + depth > 0 + ? authzDeepResolveMany(opts, depth - 1)(account).resolve + : authzResolveMany(opts)(account).resolve + } + } +} diff --git a/packages/sdk/src/test-utils/index.js b/packages/sdk/src/test-utils/index.js index 17ff8f79b..ef559595a 100644 --- a/packages/sdk/src/test-utils/index.js +++ b/packages/sdk/src/test-utils/index.js @@ -1,3 +1,10 @@ export {mockSend} from "./mock-send" -export {authzFn, authzResolve, authzResolveMany, sig, idof} from "./authz-fn" +export { + authzFn, + authzResolve, + authzResolveMany, + authzDeepResolveMany, + sig, + idof, +} from "./authz-fn" export {run} from "./run" diff --git a/packages/transport-grpc/CHANGELOG.md b/packages/transport-grpc/CHANGELOG.md index 24cb60afb..8d3fc3d74 100644 --- a/packages/transport-grpc/CHANGELOG.md +++ b/packages/transport-grpc/CHANGELOG.md @@ -1,5 +1,11 @@ # @onflow/transport-grpc +## 1.2.2-accounts.0 + +### Patch Changes + +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - fixed sig resolution + ## 1.2.1 ### Patch Changes diff --git a/packages/transport-grpc/package.json b/packages/transport-grpc/package.json index 8f02d2008..85c805c95 100644 --- a/packages/transport-grpc/package.json +++ b/packages/transport-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-grpc", - "version": "1.2.1", + "version": "1.2.2-accounts.0", "description": "Flow SDK GRPC Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.1", + "@onflow/sdk": "^1.2.3-accounts.1", "jest": "^29.5.0" }, "source": "src/sdk-send-grpc.js", diff --git a/packages/transport-http/CHANGELOG.md b/packages/transport-http/CHANGELOG.md index bcd070d1b..84b2a7ffa 100644 --- a/packages/transport-http/CHANGELOG.md +++ b/packages/transport-http/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/transport-http +## 1.7.2-accounts.1 + +### Patch Changes + +- [#1532](https://github.com/onflow/fcl-js/pull/1532) [`d736e157`](https://github.com/onflow/fcl-js/commit/d736e157794cf9950dc5dee9a8c21a43dada9789) Thanks [@JeffreyDoyle](https://github.com/JeffreyDoyle)! - fixed sig resolution + +## 1.7.2-accounts.0 + +### Patch Changes + +- [#1708](https://github.com/onflow/fcl-js/pull/1708) [`f5f185b7`](https://github.com/onflow/fcl-js/commit/f5f185b7e18f19b1b2b2abe335050b0ba80b594f) Thanks [@nialexsan](https://github.com/nialexsan)! - Updated packages + +- testing refactored accounts resolver + ## 1.7.1 ### Patch Changes diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index cd27d29fd..ea2980700 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-http", - "version": "1.7.1", + "version": "1.7.2-accounts.1", "description": "Flow SDK HTTP Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -15,7 +15,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.3.1", "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.2", + "@onflow/sdk": "^1.2.3-accounts.1", "@onflow/types": "^1.1.0", "jest": "^29.5.0" }, diff --git a/packages/transport-http/src/send-transaction.js b/packages/transport-http/src/send-transaction.js index 3367bfef2..0286cfa33 100644 --- a/packages/transport-http/src/send-transaction.js +++ b/packages/transport-http/src/send-transaction.js @@ -24,13 +24,19 @@ export async function sendTransaction(ix, context = {}, opts = {}) { for (let acct of Object.values(ix.accounts)) { try { if (!acct.role.payer && acct.signature != null) { - payloadSignatures.push({ + const signature = { address: sansPrefix(acct.addr), key_index: String(acct.keyId), signature: context.Buffer.from(acct.signature, "hex").toString( "base64" ), - }) + } + if (!payloadSignatures.find(existingSignature => existingSignature.address === signature.address + && existingSignature.key_index === signature.key_index + && existingSignature.signature === signature.signature + )) { + payloadSignatures.push(signature) + } } } catch (error) { console.error("SDK HTTP Send Error: Trouble applying payload signature", { diff --git a/packages/transport-http/src/send-transaction.test.js b/packages/transport-http/src/send-transaction.test.js index f39d6db8c..27c548dfd 100644 --- a/packages/transport-http/src/send-transaction.test.js +++ b/packages/transport-http/src/send-transaction.test.js @@ -22,70 +22,72 @@ describe("Transaction", () => { httpRequestMock.mockReturnValue({id: returnedTransactionId}) - const response = await sendTransaction( - await resolve( - await build([ - transaction`cadence transaction`, - proposer({ - addr: "f8d6e0586b0a20c7", - keyId: 1, - sequenceNum: 123, - signingFunction: () => ({ - addr: "f8d6e0586b0a20c7", - keyId: 1, - signature: "abc123", - }), - resolve: null, - roles: { - proposer: true, - authorizer: false, - payer: false, - param: false, - }, - }), - payer({ - addr: "f8d6e0586b0a20c7", + const built = await build([ + transaction`cadence transaction`, + proposer({ + addr: "abc", + keyId: 1, + sequenceNum: 123, + signingFunction: () => ({ + addr: "abc", + keyId: 1, + signature: "abc123", + }), + resolve: null, + role: { + proposer: true, + authorizer: false, + payer: false, + param: false, + }, + }), + payer({ + addr: "def", + keyId: 1, + sequenceNum: 123, + signingFunction: () => ({ + addr: "def", + keyId: 1, + signature: "def456", + }), + resolve: null, + role: { + proposer: false, + authorizer: false, + payer: true, + param: false, + }, + }), + authorizations([ + { + addr: "abc", + keyId: 1, + sequenceNum: 123, + signingFunction: () => ({ + addr: "abc", keyId: 1, - sequenceNum: 123, - signingFunction: () => ({ - addr: "f8d6e0586b0a20c7", - keyId: 1, - signature: "abc123", - }), - resolve: null, - roles: { - proposer: false, - authorizer: false, - payer: true, - param: false, - }, - }), - authorizations([ - { - addr: "f8d6e0586b0a20c7", - keyId: 1, - sequenceNum: 123, - signingFunction: () => ({ - addr: "f8d6e0586b0a20c7", - keyId: 1, - signature: "abc123", - }), - resolve: null, - roles: { - proposer: false, - authorizer: true, - payer: false, - param: false, - }, - }, - ]), - ref("abc123"), - limit(500), - voucherIntercept(async voucher => { - voucherToTxId(voucher) + signature: "abc123", }), - ]) - ), + resolve: null, + role: { + proposer: false, + authorizer: true, + payer: false, + param: false, + }, + }, + ]), + ref("aaaa"), + limit(500), + voucherIntercept(async voucher => { + voucherToTxId(voucher) + }), + ]) + + const resolved = await resolve(built) + + const response = await sendTransaction( + resolved, { response: responseADT, Buffer, @@ -111,27 +113,27 @@ describe("Transaction", () => { body: { script: "Y2FkZW5jZSB0cmFuc2FjdGlvbg==", arguments: [], - reference_block_id: "abc123", + reference_block_id: "aaaa", gas_limit: "500", - payer: "f8d6e0586b0a20c7", + payer: "def", proposal_key: { - address: "f8d6e0586b0a20c7", + address: "abc", key_index: "1", sequence_number: "123", }, - authorizers: ["f8d6e0586b0a20c7"], + authorizers: ["abc"], payload_signatures: [ { - address: "f8d6e0586b0a20c7", + address: "abc", key_index: "1", signature: "q8Ej", }, ], envelope_signatures: [ { - address: "f8d6e0586b0a20c7", + address: "def", key_index: "1", - signature: "q8Ej", + signature: "3vRW", }, ], },