From b4b3bccedd4b497f462bee8e51f51136108d738f Mon Sep 17 00:00:00 2001 From: Alex <12097569+nialexsan@users.noreply.github.com> Date: Fri, 4 Aug 2023 10:48:16 -0400 Subject: [PATCH 01/45] Nialexsan/add types (#1710) * switch to uuid from @onflow/utils-uid * create tsconfigs * typedefs in ts * types for actor util * types for address util * Revert "switch to uuid from @onflow/utils-uid" This reverts commit 2a15ef5d2d8f14a2302f2783d5ad8bef5a3f0ee8. * PKG -- [util-actor] converted to ts * updated tsconfig * fixed ts types generation * Resolve circular dependency * ts rlp * change type location * more types * build types during regular build * fix tests * VSN -- [root] Changeset * Merge remote-tracking branch 'origin/master' into nialexsan/add-types * Revert "Resolve circular dependency" This reverts commit 36efc7d3957b4952a7e2caea3113716f6204f5a0. * update lock * VSN -- [root] changeset --- package-lock.json | 205 ++++++++++++- package.json | 7 +- packages/config/package.json | 3 +- packages/config/tsconfig.json | 15 +- packages/fcl-bundle/package.json | 1 + .../fcl-bundle/src/build/get-input-options.js | 2 + packages/fcl-bundle/tsconfig.json | 11 + packages/fcl-wc/tsconfig.json | 11 + packages/fcl/package.json | 4 +- ...cl-react-native.js => fcl-react-native.ts} | 0 packages/fcl/src/{fcl.js => fcl.ts} | 0 packages/rlp/package.json | 3 +- .../rlp/src/{index.test.js => index.test.ts} | 0 packages/rlp/src/{index.js => index.ts} | 0 packages/rlp/tsconfig.json | 11 + packages/sdk/package.json | 5 +- .../sdk/src/resolve/resolve-accounts.test.js | 4 +- .../sdk/src/resolve/resolve-arguments.test.js | 2 +- .../src/resolve/resolve-signatures.test.js | 2 +- packages/sdk/src/sdk.test.js | 2 +- packages/sdk/src/{sdk.js => sdk.ts} | 0 packages/sdk/tsconfig.json | 15 +- packages/transport-grpc/tsconfig.json | 11 + packages/transport-http/tsconfig.json | 11 + packages/typedefs/package.json | 5 +- packages/typedefs/src/index.js | 117 ------- packages/typedefs/src/index.ts | 290 ++++++++++++++++++ packages/typedefs/tsconfig.json | 16 +- packages/types/tsconfig.json | 11 + packages/util-actor/.babelrc | 3 +- packages/util-actor/jest.config.ts | 8 + packages/util-actor/package.json | 2 +- .../src/{index.test.js => index.test.ts} | 8 +- .../util-actor/src/{index.js => index.ts} | 101 +++--- .../mailbox/{index.test.js => index.test.ts} | 0 .../src/mailbox/{index.js => index.ts} | 6 +- packages/util-actor/tsconfig.json | 11 + packages/util-address/package.json | 5 +- .../util-address/src/{index.js => index.ts} | 6 +- packages/util-address/tsconfig.json | 16 +- packages/util-encode-key/package.json | 7 +- ...{index.test.js.snap => index.test.ts.snap} | 0 .../src/{index.test.js => index.test.ts} | 2 +- .../src/{index.js => index.ts} | 0 packages/util-encode-key/tsconfig.json | 16 +- packages/util-invariant/package.json | 3 +- .../util-invariant/src/{index.js => index.ts} | 0 packages/util-invariant/tsconfig.json | 11 + packages/util-logger/package.json | 2 +- ...til-logger.test.js => util-logger.test.ts} | 0 .../src/{util-logger.js => util-logger.ts} | 0 packages/util-logger/tsconfig.json | 11 + packages/util-template/tsconfig.json | 11 + packages/util-uid/tsconfig.json | 11 + tsconfig.json | 23 ++ 55 files changed, 747 insertions(+), 280 deletions(-) create mode 100644 packages/fcl-bundle/tsconfig.json create mode 100644 packages/fcl-wc/tsconfig.json rename packages/fcl/src/{fcl-react-native.js => fcl-react-native.ts} (100%) rename packages/fcl/src/{fcl.js => fcl.ts} (100%) rename packages/rlp/src/{index.test.js => index.test.ts} (100%) rename packages/rlp/src/{index.js => index.ts} (100%) create mode 100644 packages/rlp/tsconfig.json rename packages/sdk/src/{sdk.js => sdk.ts} (100%) create mode 100644 packages/transport-grpc/tsconfig.json create mode 100644 packages/transport-http/tsconfig.json delete mode 100644 packages/typedefs/src/index.js create mode 100644 packages/typedefs/src/index.ts create mode 100644 packages/types/tsconfig.json create mode 100644 packages/util-actor/jest.config.ts rename packages/util-actor/src/{index.test.js => index.test.ts} (97%) rename packages/util-actor/src/{index.js => index.ts} (57%) rename packages/util-actor/src/mailbox/{index.test.js => index.test.ts} (100%) rename packages/util-actor/src/mailbox/{index.js => index.ts} (75%) create mode 100644 packages/util-actor/tsconfig.json rename packages/util-address/src/{index.js => index.ts} (78%) rename packages/util-encode-key/src/__snapshots__/{index.test.js.snap => index.test.ts.snap} (100%) rename packages/util-encode-key/src/{index.test.js => index.test.ts} (98%) rename packages/util-encode-key/src/{index.js => index.ts} (100%) rename packages/util-invariant/src/{index.js => index.ts} (100%) create mode 100644 packages/util-invariant/tsconfig.json rename packages/util-logger/src/{util-logger.test.js => util-logger.test.ts} (100%) rename packages/util-logger/src/{util-logger.js => util-logger.ts} (100%) create mode 100644 packages/util-logger/tsconfig.json create mode 100644 packages/util-template/tsconfig.json create mode 100644 packages/util-uid/tsconfig.json create mode 100644 tsconfig.json diff --git a/package-lock.json b/package-lock.json index f1bcdc64b..837b64c6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,16 @@ "./packages/*" ], "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@changesets/changelog-github": "^0.4.4", "@changesets/cli": "^2.21.1", + "@types/jest": "^29.5.3", "@types/node": "^18.11.18", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", - "prettier": "^2.6.2" + "prettier": "^2.6.2", + "ts-jest": "^29.1.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -171,6 +174,8 @@ }, "node_modules/@babel/helper-create-class-features-plugin": { "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.9.tgz", + "integrity": "sha512-Pwyi89uO4YrGKxL/eNJ8lfEH55DnRloGPOseaA8NFNL6jAUnn+KccaISiFazCj5IolPPDjGSdzQzXVzODVRqUQ==", "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", @@ -192,6 +197,8 @@ }, "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -343,6 +350,8 @@ }, "node_modules/@babel/helper-replace-supers": { "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", + "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.22.5", @@ -1361,6 +1370,24 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.9.tgz", + "integrity": "sha512-BnVR1CpKiuD0iobHPaM1iLvcwPYN2uVFAqoLVSpEDKWuOikoCv5HbKLxclhKYUXlWkX86DoZGtqI4XhbOsyrMg==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-create-class-features-plugin": "^7.22.9", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-typescript": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-unicode-escapes": { "version": "7.18.10", "license": "MIT", @@ -1496,6 +1523,25 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz", + "integrity": "sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "@babel/plugin-transform-modules-commonjs": "^7.22.5", + "@babel/plugin-transform-typescript": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/regjsgen": { "version": "0.8.0", "license": "MIT" @@ -4796,6 +4842,31 @@ "node": ">=10" } }, + "node_modules/@rollup/plugin-typescript": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.2.tgz", + "integrity": "sha512-0ghSOCMcA7fl1JM+0gYRf+Q/HWyg+zg7/gDSc+fRLmlJWcW5K1I+CLRzaRhXf4Y3DRyPnnDo4M2ktw+a6JcDEg==", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.0.2", "license": "MIT", @@ -5159,6 +5230,16 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz", + "integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "node_modules/@types/jsdom": { "version": "20.0.1", "dev": true, @@ -6446,6 +6527,18 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/bser": { "version": "2.1.1", "dev": true, @@ -13536,6 +13629,12 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "license": "MIT" @@ -13678,9 +13777,7 @@ "node_modules/make-error": { "version": "1.3.6", "dev": true, - "license": "ISC", - "optional": true, - "peer": true + "license": "ISC" }, "node_modules/make-fetch-happen": { "version": "11.1.1", @@ -17942,6 +18039,85 @@ "node": ">=8" } }, + "node_modules/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/ts-node": { "version": "10.9.1", "dev": true, @@ -18234,9 +18410,7 @@ }, "node_modules/typescript": { "version": "5.1.6", - "dev": true, "license": "Apache-2.0", - "optional": true, "peer": true, "bin": { "tsc": "bin/tsc", @@ -19057,14 +19231,14 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.6.0", + "version": "1.7.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@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", "@onflow/types": "^1.1.0", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", @@ -19123,6 +19297,7 @@ "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", + "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", @@ -19141,7 +19316,7 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "4.0.0-accounts.1", + "version": "4.0.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", @@ -19711,13 +19886,13 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.2.2", + "version": "1.2.3", "license": "Apache-2.0", "dependencies": { "@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", "@onflow/util-actor": "^1.2.0", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", @@ -19818,7 +19993,7 @@ }, "packages/transport-grpc": { "name": "@onflow/transport-grpc", - "version": "1.2.2-accounts.0", + "version": "1.2.2", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -19832,7 +20007,7 @@ }, "devDependencies": { "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.2", + "@onflow/sdk": "^1.2.3", "jest": "^29.5.0" } }, @@ -19860,7 +20035,7 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.7.1", + "version": "1.7.2", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -19874,7 +20049,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.3.1", "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.2", + "@onflow/sdk": "^1.2.3", "@onflow/types": "^1.1.0", "jest": "^29.5.0" } diff --git a/package.json b/package.json index 7bfe3842e..1e457e04c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "./packages/*" ], "scripts": { - "build": "lerna run build:types && lerna run build", + "build": "lerna run build", "start": "npm run build && lerna run start --parallel", "test": "jest", "release": "npm run build && npm run changeset publish", @@ -11,12 +11,15 @@ }, "name": "fcl-js", "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@changesets/changelog-github": "^0.4.4", "@changesets/cli": "^2.21.1", + "@types/jest": "^29.5.3", "@types/node": "^18.11.18", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", - "prettier": "^2.6.2" + "prettier": "^2.6.2", + "ts-jest": "^29.1.1" } } diff --git a/packages/config/package.json b/packages/config/package.json index 2dd2ebbc1..521b0838f 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -26,8 +26,7 @@ "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "npm run lint && fcl-bundle", - "build:types": "tsc", + "build": "tsc && npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index ef17eba8e..88be905eb 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,24 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 8da987fa7..14663bec8 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -20,6 +20,7 @@ "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", + "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index e3906a391..e867fb0a9 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -5,6 +5,7 @@ const replace = require("@rollup/plugin-replace") const {nodeResolve} = require("@rollup/plugin-node-resolve") const {babel} = require("@rollup/plugin-babel") const terser = require('@rollup/plugin-terser') +const typescript = require('@rollup/plugin-typescript') const builtinModules = require("builtin-modules") @@ -53,6 +54,7 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ + typescript(), replace({ preventAssignment: true, PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), diff --git a/packages/fcl-bundle/tsconfig.json b/packages/fcl-bundle/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/fcl-bundle/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/fcl-wc/tsconfig.json b/packages/fcl-wc/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/fcl-wc/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/fcl/package.json b/packages/fcl/package.json index 7a6314f4a..74635d5e9 100644 --- a/packages/fcl/package.json +++ b/packages/fcl/package.json @@ -30,12 +30,12 @@ "typescript": "^4.9.5" }, "source": { - "src/fcl.js": { + "src/fcl.ts": { "cjs": "./dist/fcl.js", "esm": "./dist/fcl.module.js", "umd": "./dist/fcl.umd.min.js" }, - "src/fcl-react-native.js": { + "src/fcl-react-native.ts": { "cjs": "./dist/fcl-react-native.js", "esm": "./dist/fcl-react-native.module.js", "umd": "./dist/fcl-react-native.umd.min.js" diff --git a/packages/fcl/src/fcl-react-native.js b/packages/fcl/src/fcl-react-native.ts similarity index 100% rename from packages/fcl/src/fcl-react-native.js rename to packages/fcl/src/fcl-react-native.ts diff --git a/packages/fcl/src/fcl.js b/packages/fcl/src/fcl.ts similarity index 100% rename from packages/fcl/src/fcl.js rename to packages/fcl/src/fcl.ts diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 8ef472694..0980763b8 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -16,10 +16,11 @@ "@onflow/fcl-bundle": "^1.3.1-alpha.0", "jest": "^29.5.0" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/rlp.js", "module": "dist/rlp.module.js", "unpkg": "dist/rlp.umd.js", + "types": "dist/types/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/rlp/src/index.test.js b/packages/rlp/src/index.test.ts similarity index 100% rename from packages/rlp/src/index.test.js rename to packages/rlp/src/index.test.ts diff --git a/packages/rlp/src/index.js b/packages/rlp/src/index.ts similarity index 100% rename from packages/rlp/src/index.js rename to packages/rlp/src/index.ts diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/rlp/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/sdk/package.json b/packages/sdk/package.json index bdb95abfa..e6b4eb84e 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -25,7 +25,7 @@ "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/sdk.js", + "source": "src/sdk.ts", "main": "dist/sdk.js", "module": "dist/sdk.module.js", "unpkg": "dist/sdk.umd.js", @@ -34,8 +34,7 @@ "alpha": "npm publish --tag alpha", "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "npm run lint && fcl-bundle", - "build:types": "tsc", + "build": "tsc && npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/sdk/src/resolve/resolve-accounts.test.js b/packages/sdk/src/resolve/resolve-accounts.test.js index c370bb93d..0f4017874 100644 --- a/packages/sdk/src/resolve/resolve-accounts.test.js +++ b/packages/sdk/src/resolve/resolve-accounts.test.js @@ -7,8 +7,8 @@ import { payer, limit, authorizations, -} from "../sdk.js" -import {buildPreSignable, resolveAccounts} from "./resolve-accounts" +} from "../sdk" +import {buildPreSignable} from "./resolve-accounts" test("Voucher in PreSignable", async () => { const authz = { diff --git a/packages/sdk/src/resolve/resolve-arguments.test.js b/packages/sdk/src/resolve/resolve-arguments.test.js index 79ec830c4..ebf30cea7 100644 --- a/packages/sdk/src/resolve/resolve-arguments.test.js +++ b/packages/sdk/src/resolve/resolve-arguments.test.js @@ -1,4 +1,4 @@ -import {resolveArguments} from "../sdk.js" +import {resolveArguments} from "../sdk" describe("resolveArguments", () => { const argID = "28948a11n4" diff --git a/packages/sdk/src/resolve/resolve-signatures.test.js b/packages/sdk/src/resolve/resolve-signatures.test.js index 5bbc888f7..30465ad7e 100644 --- a/packages/sdk/src/resolve/resolve-signatures.test.js +++ b/packages/sdk/src/resolve/resolve-signatures.test.js @@ -8,7 +8,7 @@ import { payer, limit, authorizations, -} from "../sdk.js" +} from "../sdk" const signingFunction = jest.fn(() => ({ addr: "foo", diff --git a/packages/sdk/src/sdk.test.js b/packages/sdk/src/sdk.test.js index a86d9ddf8..9ee3543eb 100644 --- a/packages/sdk/src/sdk.test.js +++ b/packages/sdk/src/sdk.test.js @@ -10,7 +10,7 @@ import { payer, authorization, VERSION, -} from "./sdk.js" +} from "./sdk" test("fcl.VERSION needs to match version in package.json", () => { expect(VERSION).toBe("TESTVERSION") diff --git a/packages/sdk/src/sdk.js b/packages/sdk/src/sdk.ts similarity index 100% rename from packages/sdk/src/sdk.js rename to packages/sdk/src/sdk.ts diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index ef17eba8e..88be905eb 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,24 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/transport-grpc/tsconfig.json b/packages/transport-grpc/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/transport-grpc/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/transport-http/tsconfig.json b/packages/transport-http/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/transport-http/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index fbe513cf7..bad746ff2 100644 --- a/packages/typedefs/package.json +++ b/packages/typedefs/package.json @@ -21,16 +21,15 @@ "jest-esm-transformer": "1.0.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/typedefs.js", "module": "dist/typedefs.module.js", "unpkg": "dist/typedefs.umd.js", - "types": "types/index.d.ts", + "types": "dist/types/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/typedefs/src/index.js b/packages/typedefs/src/index.js deleted file mode 100644 index f08314863..000000000 --- a/packages/typedefs/src/index.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @typedef {object} Account - * @property {string} address - The address of the account - * @property {number} balance - The FLOW balance of the account in 10^8 - * @property {number} code - The code of any Cadence contracts stored in the account - * @property {object} contracts - An object with keys as the contract name deployed and the value as the the cadence string - * @property {object} keys - Any contracts deployed to this account - */ - -/** - * @typedef {object} Block - * @property {string} id - The id of the block - * @property {string} parentId - The id of the parent block - * @property {number} height - The height of the block - * @property {object} timestamp - Time related fields - * @property {CollectionGuarantee} collectionGuarantees - Contains the ids of collections included in the block - * @property {object} blockSeals - The details of which nodes executed and sealed the blocks - * @property {Array} signatures - The cryptographic signature of the block - */ - -/** - * @typedef {object} CollectionGuarantee - * @property {string} collectionId - The id of the block - * @property {Array} signatures - All signatures - */ - -/** - * @typedef {object} CompositeSignature - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {string} addr - Flow Address (sans prefix) - * @property {number} keyId - Key ID - * @property {string} signature - Signature as a hex string - */ - -/** - * @typedef {object} CurrentUser - * @property {string} [addr] - The public address of the current user - * @property {string} [cid] - A wallet specified content identifier for user metadata - * @property {number} [expiresAt] - A wallet specified time-frame for a valid session - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {boolean} [loggedIn] - Whether or not the current user is logged in - * @property {Array} services - A list of trusted services that express ways of interacting with the current user's identity - */ - -/** - * @typedef {object} Event - * @property {string} blockId - ID of the block that contains the event. - * @property {number} blockHeight - Height of the block that contains the event. - * @property {string} blockTimestamp - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' - * @property {string} type - A string containing the event name. - * @property {string} transactionId - Can be used to query transaction information, eg. via a Flow block explorer. - * @property {number} transactionIndex - Used to prevent replay attacks. - * @property {number} eventIndex - Used to prevent replay attacks. - * @property {any} data - The data emitted from the event. - */ - -/** - * @typedef {object} Key - * @property {number} sequenceNumber - Sequence number of key used by the proposer of this transaction - * @property {number} keyId - The ID of the key in the account used by the proposer of this transaction - * @property {string} address - The address of the proposer of this transaction - */ - -/** - * @typedef {object} Service - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {string} type - Service type - * @property {string} method - Service method - * @property {string} [uid] - Service uid - * @property {string} endpoint - Service endpoint - * @property {Provider} provider - Service provider object - */ - -/** - * @typedef {object} Signature - * @property {string} sequenceNumber - Sequence number of the key used to perform this signature. - * @property {number} keyId - ID of the key in the account used to perform this signature. - * @property {string} signature - The signature represented as a hex string. - */ - -/** - * @typedef {object} Transaction - * @property {string} script - The Cadence code used to execute this transaction. - * @property {Array} args - The JSON-CDC encoded arguments passed in to the transaction. - * @property {string} referenceBlockId - The reference block id for this transaction. - * @property {number} gasLimit - The gas limit for the transaction. - * @property {Key} proposalKey - The key used by the proposer of this transaction. - * @property {string} sequenceNumber - Sequence number of the key used by the proposer of this transaction. - * @property {number} keyId - The ID of the key in the account used by the proposer of this transaction. - * @property {string} address - The address of the proposer of this transaction. - * @property {string} payer - Address of the payer of the transaction. - * @property {string} proposer - Address of the proposer of this transaction. - * @property {Array} authorizers - Array of addresses of authorizers of this transaction. - * @property {Array} payloadSignatures - The payload signatures for the transaction. - * @property {Array} envelopeSignatures - The envelope signatures for the transaction. - */ - -/** - * @typedef {object} TransactionStatus - * @property {string} blockId - The ID of the Block the transaction is included in. - * @property {number} status - The status code of the transaction. - * @property {string} statusString - The status as as descriptive text (e.g. "FINALIZED"). - * @property {string} errorMessage - The error message of the transaction. - * @property {Array} events - The events for this result. - */ - -/** - * @typedef {object} Provider - * @property {string} name - Provider name. - * @todo fill the rest - */ - -// Needed for bundler to export this file -exports.unused = {} diff --git a/packages/typedefs/src/index.ts b/packages/typedefs/src/index.ts new file mode 100644 index 000000000..40b40b54f --- /dev/null +++ b/packages/typedefs/src/index.ts @@ -0,0 +1,290 @@ +export type Account = { + /** + * - The address of the account + */ + address: string; + /** + * - The FLOW balance of the account in 10^8 + */ + balance: number; + /** + * - The code of any Cadence contracts stored in the account + */ + code: number; + /** + * - An object with keys as the contract name deployed and the value as the the cadence string + */ + contracts: object; + /** + * - Any contracts deployed to this account + */ + keys: object; +}; +export type Block = { + /** + * - The id of the block + */ + id: string; + /** + * - The id of the parent block + */ + parentId: string; + /** + * - The height of the block + */ + height: number; + /** + * - Time related fields + */ + timestamp: object; + /** + * - Contains the ids of collections included in the block + */ + collectionGuarantees: CollectionGuarantee; + /** + * - The details of which nodes executed and sealed the blocks + */ + blockSeals: object; + /** + * - The cryptographic signature of the block + */ + signatures: Array; +}; +export type CollectionGuarantee = { + /** + * - The id of the block + */ + collectionId: string; + /** + * - All signatures + */ + signatures: Array; +}; +export type CompositeSignature = { + /** + * - A type identifier used internally by FCL + */ + f_type: string; + /** + * - FCL protocol version + */ + f_vsn: string; + /** + * - Flow Address (sans prefix) + */ + addr: string; + /** + * - Key ID + */ + keyId: number; + /** + * - Signature as a hex string + */ + signature: string; +}; +export type CurrentUser = { + /** + * - The public address of the current user + */ + addr?: string; + /** + * - A wallet specified content identifier for user metadata + */ + cid?: string; + /** + * - A wallet specified time-frame for a valid session + */ + expiresAt?: number; + /** + * - A type identifier used internally by FCL + */ + f_type: string; + /** + * - FCL protocol version + */ + f_vsn: string; + /** + * - Whether or not the current user is logged in + */ + loggedIn?: boolean; + /** + * - A list of trusted services that express ways of interacting with the current user's identity + */ + services: Array; +}; +export type Event = { + /** + * - ID of the block that contains the event. + */ + blockId: string; + /** + * - Height of the block that contains the event. + */ + blockHeight: number; + /** + * - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' + */ + blockTimestamp: string; + /** + * - A string containing the event name. + */ + type: string; + /** + * - Can be used to query transaction information, eg. via a Flow block explorer. + */ + transactionId: string; + /** + * - Used to prevent replay attacks. + */ + transactionIndex: number; + /** + * - Used to prevent replay attacks. + */ + eventIndex: number; + /** + * - The data emitted from the event. + */ + data: any; +}; +export type Key = { + /** + * - Sequence number of key used by the proposer of this transaction + */ + sequenceNumber: number; + /** + * - The ID of the key in the account used by the proposer of this transaction + */ + keyId: number; + /** + * - The address of the proposer of this transaction + */ + address: string; +}; +export type Service = { + /** + * - A type identifier used internally by FCL + */ + f_type: string; + /** + * - FCL protocol version + */ + f_vsn: string; + /** + * - Service type + */ + type: string; + /** + * - Service method + */ + method: string; + /** + * - Service uid + */ + uid?: string; + /** + * - Service endpoint + */ + endpoint: string; + /** + * - Service provider object + */ + provider: Provider; + + params: Record +}; +export type Signature = { + /** + * - Sequence number of the key used to perform this signature. + */ + sequenceNumber: string; + /** + * - ID of the key in the account used to perform this signature. + */ + keyId: number; + /** + * - The signature represented as a hex string. + */ + signature: string; +}; +export type Transaction = { + /** + * - The Cadence code used to execute this transaction. + */ + script: string; + /** + * - The JSON-CDC encoded arguments passed in to the transaction. + */ + args: Array; + /** + * - The reference block id for this transaction. + */ + referenceBlockId: string; + /** + * - The gas limit for the transaction. + */ + gasLimit: number; + /** + * - The key used by the proposer of this transaction. + */ + proposalKey: Key; + /** + * - Sequence number of the key used by the proposer of this transaction. + */ + sequenceNumber: string; + /** + * - The ID of the key in the account used by the proposer of this transaction. + */ + keyId: number; + /** + * - The address of the proposer of this transaction. + */ + address: string; + /** + * - Address of the payer of the transaction. + */ + payer: string; + /** + * - Address of the proposer of this transaction. + */ + proposer: string; + /** + * - Array of addresses of authorizers of this transaction. + */ + authorizers: Array; + /** + * - The payload signatures for the transaction. + */ + payloadSignatures: Array; + /** + * - The envelope signatures for the transaction. + */ + envelopeSignatures: Array; +}; +export type TransactionStatus = { + /** + * - The ID of the Block the transaction is included in. + */ + blockId: string; + /** + * - The status code of the transaction. + */ + status: number; + /** + * - The status as as descriptive text (e.g. "FINALIZED"). + */ + statusString: string; + /** + * - The error message of the transaction. + */ + errorMessage: string; + /** + * - The events for this result. + */ + events: Array; +}; +export type Provider = { + /** + * - Provider name. + */ + name: string; +}; diff --git a/packages/typedefs/tsconfig.json b/packages/typedefs/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/typedefs/tsconfig.json +++ b/packages/typedefs/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/types/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-actor/.babelrc b/packages/util-actor/.babelrc index 67fc2886b..f57936a43 100644 --- a/packages/util-actor/.babelrc +++ b/packages/util-actor/.babelrc @@ -2,6 +2,7 @@ "presets": [ [ "@babel/preset-env" - ] + ], + "@babel/preset-typescript" ] } diff --git a/packages/util-actor/jest.config.ts b/packages/util-actor/jest.config.ts new file mode 100644 index 000000000..22291c790 --- /dev/null +++ b/packages/util-actor/jest.config.ts @@ -0,0 +1,8 @@ +import type {Config} from 'jest'; + +const config: Config = { + verbose: true, + preset: "ts-jest", +}; + +export default config; \ No newline at end of file diff --git a/packages/util-actor/package.json b/packages/util-actor/package.json index ce51944fd..8b0bedd6e 100644 --- a/packages/util-actor/package.json +++ b/packages/util-actor/package.json @@ -20,7 +20,7 @@ "@babel/runtime": "^7.18.6", "queue-microtask": "1.2.3" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/actor.js", "module": "dist/actor.module.js", "unpkg": "dist/actor.umd.js", diff --git a/packages/util-actor/src/index.test.js b/packages/util-actor/src/index.test.ts similarity index 97% rename from packages/util-actor/src/index.test.js rename to packages/util-actor/src/index.test.ts index 5efce9f47..da4441b8c 100644 --- a/packages/util-actor/src/index.test.js +++ b/packages/util-actor/src/index.test.ts @@ -72,13 +72,13 @@ const idle = async () => new Promise(resolve => setTimeout(resolve, 0)) describe("golden path", () => { describe("init, send, receive", () => { test("rpc initial value", async () => { - const c = counter() + const c = counter("") expect(await dump(c)).toBe(0) kill(c) }) test("send message and rpc value", async () => { - const c = counter() + const c = counter("value") inc(c, 5) expect(await dump(c)).toBe(5) kill(c) @@ -152,8 +152,8 @@ describe("golden path", () => { test("actors with same name only spawn once", async () => { const fn = jest.fn() - const c1 = spawn(fn, "foo") - const c2 = spawn(fn, "foo") + const c1 = spawn(fn, 0) + const c2 = spawn(fn, 0) await idle() expect(c1).toBe(c2) diff --git a/packages/util-actor/src/index.js b/packages/util-actor/src/index.ts similarity index 57% rename from packages/util-actor/src/index.js rename to packages/util-actor/src/index.ts index d697091dd..f89b9b4d2 100644 --- a/packages/util-actor/src/index.js +++ b/packages/util-actor/src/index.ts @@ -1,5 +1,5 @@ -import {mailbox as createMailbox} from "./mailbox" -import queueMicrotask from "queue-microtask" +import {mailbox as createMailbox, type IMailbox} from "./mailbox" +const queueMicrotask = require("queue-microtask") export const INIT = "INIT" export const SUBSCRIBE = "SUBSCRIBE" @@ -8,19 +8,39 @@ export const UPDATED = "UPDATED" export const SNAPSHOT = "SNAPSHOT" export const EXIT = "EXIT" export const TERMINATE = "TERMINATE" +const DUMP = "DUMP" +const INC = "INC" +const KEYS = "KEYS" + +interface IRegistryRecord { + addr: string + mailbox: IMailbox + subs: Set + kvs: Record + error: any +} +interface IRoot { + FCL_REGISTRY: Record | null +} -const root = - (typeof self === "object" && self.self === self && self) || - (typeof global === "object" && global.global === global && global) || - (typeof window === "object" && window.window === window && window) +const root: IRoot = + (typeof self === "object" && self.self === self && (self as unknown) as IRoot) || + (typeof global === "object" && global.global === global && (global as unknown) as IRoot) || + (typeof window === "object" && window.window === window && (window as unknown) as IRoot) || + {FCL_REGISTRY: null} root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY + +const FCL_REGISTRY = root.FCL_REGISTRY var pid = 0b0 const DEFAULT_TIMEOUT = 5000 const DEFAULT_TAG = "---" -export const send = (addr, tag, data, opts = {}) => - new Promise((reply, reject) => { + +type Tag = typeof INIT | typeof SUBSCRIBE | typeof UNSUBSCRIBE | typeof UPDATED | typeof SNAPSHOT | typeof EXIT | typeof TERMINATE | "@EXIT" | typeof DUMP | typeof INC | typeof KEYS; + +export const send = (addr: string, tag: Tag, data?: Record | null, opts: Record = {}) => + new Promise((reply, reject) => { const expectReply = opts.expectReply || false const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT @@ -43,21 +63,21 @@ export const send = (addr, tag, data, opts = {}) => } try { - root.FCL_REGISTRY[addr] && - root.FCL_REGISTRY[addr].mailbox.deliver(payload) + FCL_REGISTRY[addr] && + FCL_REGISTRY[addr].mailbox.deliver(payload) if (!expectReply) reply(true) } catch (error) { console.error( "FCL.Actor -- Could Not Deliver Message", payload, - root.FCL_REGISTRY[addr], + FCL_REGISTRY[addr], error ) } }) export const kill = addr => { - delete root.FCL_REGISTRY[addr] + delete FCL_REGISTRY[addr] } const fromHandlers = @@ -82,11 +102,18 @@ const fromHandlers = } } -export const spawn = (fn, addr = null) => { - if (addr == null) addr = ++pid - if (root.FCL_REGISTRY[addr] != null) return addr +const parseAddr = (addr): string => { + if (addr == null) { + return String(++pid) + } + return String(addr) +} + +export const spawn = (fn, rawAddr: number | null = null) => { + const addr = parseAddr(rawAddr) + if (FCL_REGISTRY[addr] != null) return addr - root.FCL_REGISTRY[addr] = { + FCL_REGISTRY[addr] = { addr, mailbox: createMailbox(), subs: new Set(), @@ -96,57 +123,57 @@ export const spawn = (fn, addr = null) => { const ctx = { self: () => addr, - receive: () => root.FCL_REGISTRY[addr].mailbox.receive(), - send: (to, tag, data, opts = {}) => { + receive: () => FCL_REGISTRY[addr].mailbox.receive(), + send: (to: string, tag: Tag, data: Record | null, opts: Record = {}) => { opts.from = addr return send(to, tag, data, opts) }, sendSelf: (tag, data, opts) => { - if (root.FCL_REGISTRY[addr]) send(addr, tag, data, opts) + if (FCL_REGISTRY[addr]) send(addr, tag, data, opts) }, - broadcast: (tag, data, opts = {}) => { + broadcast: (tag, data, opts: Record = {}) => { opts.from = addr - for (let to of root.FCL_REGISTRY[addr].subs) send(to, tag, data, opts) + for (let to of FCL_REGISTRY[addr].subs) send(to, tag, data, opts) }, - subscribe: sub => sub != null && root.FCL_REGISTRY[addr].subs.add(sub), - unsubscribe: sub => sub != null && root.FCL_REGISTRY[addr].subs.delete(sub), - subscriberCount: () => root.FCL_REGISTRY[addr].subs.size, - hasSubs: () => !!root.FCL_REGISTRY[addr].subs.size, + subscribe: sub => sub != null && FCL_REGISTRY[addr].subs.add(sub), + unsubscribe: sub => sub != null && FCL_REGISTRY[addr].subs.delete(sub), + subscriberCount: () => FCL_REGISTRY[addr].subs.size, + hasSubs: () => !!FCL_REGISTRY[addr].subs.size, put: (key, value) => { - if (key != null) root.FCL_REGISTRY[addr].kvs[key] = value + if (key != null) FCL_REGISTRY[addr].kvs[key] = value }, get: (key, fallback) => { - const value = root.FCL_REGISTRY[addr].kvs[key] + const value = FCL_REGISTRY[addr].kvs[key] return value == null ? fallback : value }, delete: key => { - delete root.FCL_REGISTRY[addr].kvs[key] + delete FCL_REGISTRY[addr].kvs[key] }, update: (key, fn) => { if (key != null) - root.FCL_REGISTRY[addr].kvs[key] = fn(root.FCL_REGISTRY[addr].kvs[key]) + FCL_REGISTRY[addr].kvs[key] = fn(FCL_REGISTRY[addr].kvs[key]) }, keys: () => { - return Object.keys(root.FCL_REGISTRY[addr].kvs) + return Object.keys(FCL_REGISTRY[addr].kvs) }, all: () => { - return root.FCL_REGISTRY[addr].kvs + return FCL_REGISTRY[addr].kvs }, where: pattern => { - return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce((acc, key) => { + return Object.keys(FCL_REGISTRY[addr].kvs).reduce((acc, key) => { return pattern.test(key) - ? {...acc, [key]: root.FCL_REGISTRY[addr].kvs[key]} + ? {...acc, [key]: FCL_REGISTRY[addr].kvs[key]} : acc }, {}) }, merge: (data = {}) => { Object.keys(data).forEach( - key => (root.FCL_REGISTRY[addr].kvs[key] = data[key]) + key => (FCL_REGISTRY[addr].kvs[key] = data[key]) ) }, fatalError: error => { - root.FCL_REGISTRY[addr].error = error - for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED) + FCL_REGISTRY[addr].error = error + for (let to of FCL_REGISTRY[addr].subs) send(to, UPDATED) }, } @@ -175,7 +202,7 @@ export function subscriber(address, spawnFn, callback) { ctx.send(address, SUBSCRIBE) while (1) { const letter = await ctx.receive() - const error = root.FCL_REGISTRY[address].error + const error = FCL_REGISTRY[address].error if (letter.tag === EXIT) { ctx.send(address, UNSUBSCRIBE) return diff --git a/packages/util-actor/src/mailbox/index.test.js b/packages/util-actor/src/mailbox/index.test.ts similarity index 100% rename from packages/util-actor/src/mailbox/index.test.js rename to packages/util-actor/src/mailbox/index.test.ts diff --git a/packages/util-actor/src/mailbox/index.js b/packages/util-actor/src/mailbox/index.ts similarity index 75% rename from packages/util-actor/src/mailbox/index.js rename to packages/util-actor/src/mailbox/index.ts index ca1cd6be9..83714d3ea 100644 --- a/packages/util-actor/src/mailbox/index.js +++ b/packages/util-actor/src/mailbox/index.ts @@ -1,5 +1,9 @@ +export interface IMailbox { + deliver(msg: any): Promise; + receive(): Promise; +} export const mailbox = () => { - const queue = [] + const queue: any[] = [] var next return { diff --git a/packages/util-actor/tsconfig.json b/packages/util-actor/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-actor/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-address/package.json b/packages/util-address/package.json index 19242e4e0..33454e365 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -21,16 +21,15 @@ "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-address.js", "module": "dist/util-address.module.js", "unpkg": "dist/util-address.umd.js", - "types": "types/index.d.ts", + "types": "dist/types/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/util-address/src/index.js b/packages/util-address/src/index.ts similarity index 78% rename from packages/util-address/src/index.js rename to packages/util-address/src/index.ts index 38d51151d..63ea0705a 100644 --- a/packages/util-address/src/index.js +++ b/packages/util-address/src/index.ts @@ -3,7 +3,7 @@ * @param {string} address - Flow address * @returns {string} - Flow address without 0x prefix */ - export function sansPrefix(address) { + export function sansPrefix(address: string | null): string { if (address == null) return null return address.replace(/^0x/, "").replace(/^Fx/, "") } @@ -13,7 +13,7 @@ * @param {string} address - Flow address * @returns {string} - Flow address with 0x prefix */ -export function withPrefix(address) { +export function withPrefix(address: string): string | null { if (address == null) return null return "0x" + sansPrefix(address) } @@ -23,6 +23,6 @@ export function withPrefix(address) { * @param {string} address - Flow address * @returns {string} - Flow address with 0x prefix */ -export function display(address) { +export function display(address: string | null): string { return withPrefix(address) } diff --git a/packages/util-address/tsconfig.json b/packages/util-address/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/util-address/tsconfig.json +++ b/packages/util-address/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 8e8012eb7..81bdc006d 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -21,19 +21,18 @@ "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-encode-key.js", "module": "dist/util-encode-key.module.js", "unpkg": "dist/util-encode-key.umd.js", - "types": "types/index.d.ts", + "types": "dist/types/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", - "lint": "eslint ." + "lint": "eslint src/*.ts" }, "dependencies": { "@babel/runtime": "^7.18.6", diff --git a/packages/util-encode-key/src/__snapshots__/index.test.js.snap b/packages/util-encode-key/src/__snapshots__/index.test.ts.snap similarity index 100% rename from packages/util-encode-key/src/__snapshots__/index.test.js.snap rename to packages/util-encode-key/src/__snapshots__/index.test.ts.snap diff --git a/packages/util-encode-key/src/index.test.js b/packages/util-encode-key/src/index.test.ts similarity index 98% rename from packages/util-encode-key/src/index.test.js rename to packages/util-encode-key/src/index.test.ts index fed721890..1caee139f 100644 --- a/packages/util-encode-key/src/index.test.js +++ b/packages/util-encode-key/src/index.test.ts @@ -4,7 +4,7 @@ import { ECDSA_secp256k1, SHA2_256, SHA3_256, -} from "./index.js" +} from "./" const PUBLIC_KEYS = [ "0bfcd8790c3ce88f3fac9d4bd23514f48bf0cdd1f6c3c8bdf87b11489b1bbeca1ef805ec2ee76451e9bdb265284f78febaeacbc8b0827e0a7baafee4e655d0b5", diff --git a/packages/util-encode-key/src/index.js b/packages/util-encode-key/src/index.ts similarity index 100% rename from packages/util-encode-key/src/index.js rename to packages/util-encode-key/src/index.ts diff --git a/packages/util-encode-key/tsconfig.json b/packages/util-encode-key/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/util-encode-key/tsconfig.json +++ b/packages/util-encode-key/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index c005edc92..24c1fbfa0 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -17,10 +17,11 @@ "@onflow/types": "^1.1.0", "jest": "^29.5.0" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-invariant.js", "module": "dist/util-invariant.module.js", "unpkg": "dist/util-invariant.umd.js", + "types": "dist/types/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-invariant/src/index.js b/packages/util-invariant/src/index.ts similarity index 100% rename from packages/util-invariant/src/index.js rename to packages/util-invariant/src/index.ts diff --git a/packages/util-invariant/tsconfig.json b/packages/util-invariant/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-invariant/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index 7d5fe9a75..bb5dd02a9 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -16,7 +16,7 @@ "@onflow/fcl-bundle": "^1.3.1", "jest": "^29.5.0" }, - "source": "src/util-logger.js", + "source": "src/util-logger.ts", "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", diff --git a/packages/util-logger/src/util-logger.test.js b/packages/util-logger/src/util-logger.test.ts similarity index 100% rename from packages/util-logger/src/util-logger.test.js rename to packages/util-logger/src/util-logger.test.ts diff --git a/packages/util-logger/src/util-logger.js b/packages/util-logger/src/util-logger.ts similarity index 100% rename from packages/util-logger/src/util-logger.js rename to packages/util-logger/src/util-logger.ts diff --git a/packages/util-logger/tsconfig.json b/packages/util-logger/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-logger/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-template/tsconfig.json b/packages/util-template/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-template/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-uid/tsconfig.json b/packages/util-uid/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-uid/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..ca733deed --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + // Change this to match your project + "exclude": [ + "**/*.test.ts", + "**/*.test.js" + ], + "compilerOptions": { + "moduleResolution": "NodeNext", + "target": "ES2015", + "types" : ["node", "jest"], + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + // go to js file when using IDE functions like + // "Go to Definition" in VSCode + "declarationMap": false, + } +} \ No newline at end of file From 9fca84a3151d7f6aeb33870a302e9793f024516b Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 15 Aug 2023 14:49:54 -0700 Subject: [PATCH 02/45] Implement typescript for several branches & adjust configuration (#1750) Implements typescript support for: @onflow/rlp, @onflow/util-uid, @onflow/util-template, @onflow/util-logger, @onflow/util-invariant, @onflow/util-encode-key, @onflow/util-address --- .changeset/fifty-buttons-serve.md | 5 + .changeset/giant-ducks-tickle.md | 11 + package-lock.json | 1132 +++++++++++++++-- packages/config/tsconfig.json | 4 +- packages/fcl-bundle/package.json | 5 +- .../fcl-bundle/src/build/get-input-options.js | 34 +- packages/fcl/src/current-user/index.js | 351 ++--- packages/fcl/src/fcl.ts | 5 +- packages/rlp/.babelrc | 6 +- packages/rlp/.eslintrc.json | 30 + packages/rlp/package.json | 10 +- packages/rlp/src/index.ts | 91 +- packages/rlp/tsconfig.json | 4 +- packages/sdk/.babelrc | 3 +- packages/sdk/package.json | 2 +- packages/sdk/src/sdk.ts | 6 +- packages/sdk/tsconfig.json | 4 +- packages/typedefs/package.json | 2 +- packages/typedefs/src/index.ts | 554 ++++---- packages/util-actor/package.json | 1 + packages/util-actor/src/index.ts | 48 +- packages/util-actor/tsconfig.json | 3 +- packages/util-address/.babelrc | 6 +- packages/util-address/.eslintrc.json | 18 +- packages/util-address/package.json | 12 +- .../src/{index.test.js => index.test.ts} | 0 packages/util-address/src/index.ts | 18 +- packages/util-encode-key/.babelrc | 6 +- packages/util-encode-key/.eslintrc.json | 18 +- packages/util-encode-key/package.json | 14 +- packages/util-encode-key/src/index.test.ts | 16 +- packages/util-encode-key/src/index.ts | 44 +- packages/util-invariant/.eslintrc.json | 20 + packages/util-invariant/package.json | 10 +- .../src/{index.test.js => index.test.ts} | 0 packages/util-invariant/src/index.ts | 15 +- packages/util-logger/.babelrc | 6 +- packages/util-logger/.eslintrc.json | 20 + packages/util-logger/package.json | 7 + packages/util-logger/src/util-logger.ts | 121 +- packages/util-template/.babelrc | 6 +- packages/util-template/.eslintrc.json | 20 + packages/util-template/package.json | 14 +- ...ate.test.js.snap => template.test.ts.snap} | 2 +- packages/util-template/src/template.js | 46 - .../{template.test.js => template.test.ts} | 24 +- packages/util-template/src/template.ts | 67 + packages/util-template/tsconfig.json | 7 +- packages/util-uid/.babelrc | 6 +- packages/util-uid/.eslintrc.json | 20 + packages/util-uid/package.json | 11 +- packages/util-uid/src/util-uid.js | 13 - packages/util-uid/src/util-uid.test.js | 5 - packages/util-uid/src/util-uid.test.ts | 12 + packages/util-uid/src/util-uid.ts | 13 + tsconfig.json | 10 +- 56 files changed, 2005 insertions(+), 933 deletions(-) create mode 100644 .changeset/fifty-buttons-serve.md create mode 100644 .changeset/giant-ducks-tickle.md create mode 100644 packages/rlp/.eslintrc.json rename packages/util-address/src/{index.test.js => index.test.ts} (100%) create mode 100644 packages/util-invariant/.eslintrc.json rename packages/util-invariant/src/{index.test.js => index.test.ts} (100%) create mode 100644 packages/util-logger/.eslintrc.json create mode 100644 packages/util-template/.eslintrc.json rename packages/util-template/src/__snapshots__/{template.test.js.snap => template.test.ts.snap} (94%) delete mode 100644 packages/util-template/src/template.js rename packages/util-template/src/{template.test.js => template.test.ts} (72%) create mode 100644 packages/util-template/src/template.ts create mode 100644 packages/util-uid/.eslintrc.json delete mode 100644 packages/util-uid/src/util-uid.js delete mode 100644 packages/util-uid/src/util-uid.test.js create mode 100644 packages/util-uid/src/util-uid.test.ts create mode 100644 packages/util-uid/src/util-uid.ts diff --git a/.changeset/fifty-buttons-serve.md b/.changeset/fifty-buttons-serve.md new file mode 100644 index 000000000..31966c74d --- /dev/null +++ b/.changeset/fifty-buttons-serve.md @@ -0,0 +1,5 @@ +--- +"@onflow/fcl-bundle": minor +--- + +Switched to rollup-plugin-typescript2 diff --git a/.changeset/giant-ducks-tickle.md b/.changeset/giant-ducks-tickle.md new file mode 100644 index 000000000..c93bc0d3f --- /dev/null +++ b/.changeset/giant-ducks-tickle.md @@ -0,0 +1,11 @@ +--- +"@onflow/util-encode-key": minor +"@onflow/util-invariant": minor +"@onflow/util-template": minor +"@onflow/util-address": minor +"@onflow/util-logger": minor +"@onflow/util-uid": minor +"@onflow/rlp": minor +--- + +Convert to Typescript diff --git a/package-lock.json b/package-lock.json index 837b64c6a..bf48f07b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -174,8 +174,6 @@ }, "node_modules/@babel/helper-create-class-features-plugin": { "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.9.tgz", - "integrity": "sha512-Pwyi89uO4YrGKxL/eNJ8lfEH55DnRloGPOseaA8NFNL6jAUnn+KccaISiFazCj5IolPPDjGSdzQzXVzODVRqUQ==", "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", @@ -197,8 +195,6 @@ }, "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -350,8 +346,6 @@ }, "node_modules/@babel/helper-replace-supers": { "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", - "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.22.5", @@ -810,7 +804,6 @@ }, "node_modules/@babel/plugin-syntax-jsx": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -910,7 +903,6 @@ }, "node_modules/@babel/plugin-syntax-typescript": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -1372,9 +1364,7 @@ }, "node_modules/@babel/plugin-transform-typescript": { "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.9.tgz", - "integrity": "sha512-BnVR1CpKiuD0iobHPaM1iLvcwPYN2uVFAqoLVSpEDKWuOikoCv5HbKLxclhKYUXlWkX86DoZGtqI4XhbOsyrMg==", - "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", "@babel/helper-create-class-features-plugin": "^7.22.9", @@ -1525,9 +1515,7 @@ }, "node_modules/@babel/preset-typescript": { "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz", - "integrity": "sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ==", - "dev": true, + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5", "@babel/helper-validator-option": "^7.22.5", @@ -4842,31 +4830,6 @@ "node": ">=10" } }, - "node_modules/@rollup/plugin-typescript": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.2.tgz", - "integrity": "sha512-0ghSOCMcA7fl1JM+0gYRf+Q/HWyg+zg7/gDSc+fRLmlJWcW5K1I+CLRzaRhXf4Y3DRyPnnDo4M2ktw+a6JcDEg==", - "dependencies": { - "@rollup/pluginutils": "^5.0.1", - "resolve": "^1.22.1" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "rollup": "^2.14.0||^3.0.0", - "tslib": "*", - "typescript": ">=3.7.0" - }, - "peerDependenciesMeta": { - "rollup": { - "optional": true - }, - "tslib": { - "optional": true - } - } - }, "node_modules/@rollup/pluginutils": { "version": "5.0.2", "license": "MIT", @@ -5232,9 +5195,8 @@ }, "node_modules/@types/jest": { "version": "29.5.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz", - "integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==", "dev": true, + "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" @@ -5321,6 +5283,276 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", + "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/type-utils": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", + "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", + "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.9.1", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@walletconnect/core": { "version": "2.8.1", "license": "Apache-2.0", @@ -6529,9 +6761,8 @@ }, "node_modules/bs-logger": { "version": "0.2.6", - "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", - "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", "dev": true, + "license": "MIT", "dependencies": { "fast-json-stable-stringify": "2.x" }, @@ -8961,6 +9192,22 @@ "node": ">=0.10.0" } }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, "node_modules/find-up": { "version": "4.1.0", "license": "MIT", @@ -9831,7 +10078,6 @@ }, "node_modules/graceful-fs": { "version": "4.2.10", - "dev": true, "license": "ISC" }, "node_modules/grapheme-splitter": { @@ -13631,9 +13877,8 @@ }, "node_modules/lodash.memoize": { "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.merge": { "version": "4.6.2", @@ -13754,7 +13999,6 @@ }, "node_modules/make-dir": { "version": "3.1.0", - "dev": true, "license": "MIT", "dependencies": { "semver": "^6.0.0" @@ -13768,7 +14012,6 @@ }, "node_modules/make-dir/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -16010,7 +16253,6 @@ }, "node_modules/pkg-dir": { "version": "4.2.0", - "dev": true, "license": "MIT", "dependencies": { "find-up": "^4.0.0" @@ -16989,33 +17231,118 @@ "fsevents": "~2.3.2" } }, - "node_modules/run-async": { - "version": "2.4.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" + "node_modules/rollup-plugin-typescript2": { + "version": "0.35.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.35.0.tgz", + "integrity": "sha512-szcIO9hPUx3PhQl91u4pfNAH2EKbtrXaES+m163xQVE5O1CC0ea6YZV/5woiDDW3CR9jF2CszPrKN+AFiND0bg==", + "dependencies": { + "@rollup/pluginutils": "^4.1.2", + "find-cache-dir": "^3.3.2", + "fs-extra": "^10.0.0", + "semver": "^7.3.7", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "rollup": ">=1.26.3", + "typescript": ">=2.4.0" } }, - "node_modules/run-parallel": { - "version": "1.2.0", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", + "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", "dependencies": { - "queue-microtask": "^1.2.2" + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/run-async": { + "version": "2.4.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" } }, "node_modules/rxjs": { @@ -18039,11 +18366,22 @@ "node": ">=8" } }, + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-jest": { "version": "29.1.1", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", "dev": true, + "license": "MIT", "dependencies": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", @@ -18084,9 +18422,8 @@ }, "node_modules/ts-jest/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -18096,9 +18433,8 @@ }, "node_modules/ts-jest/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -18111,9 +18447,8 @@ }, "node_modules/ts-jest/node_modules/yargs-parser": { "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, + "license": "ISC", "engines": { "node": ">=12" } @@ -19292,16 +19627,17 @@ "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", - "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" @@ -19880,10 +20216,110 @@ "buffer": "^6.0.3" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/rlp/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/rlp/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/rlp/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/rlp/node_modules/eslint-plugin-jsdoc": { + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, + "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/rlp/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/rlp/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/rlp/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/sdk": { "name": "@onflow/sdk", "version": "1.2.3", @@ -19981,12 +20417,11 @@ }, "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" ], + "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } @@ -20116,11 +20551,15 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.7.5", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" } @@ -20234,11 +20673,15 @@ "@onflow/util-invariant": "^1.1.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.8.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" } @@ -20350,66 +20793,483 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, - "packages/util-logger": { - "name": "@onflow/util-logger", - "version": "1.2.2", - "license": "Apache-2.0", + "packages/util-invariant/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, "dependencies": { - "@babel/runtime": "^7.18.6" - }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "jest": "^29.5.0" - }, - "peerDependencies": { - "@onflow/util-config": ">1.1.1" + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" }, - "peerDependenciesMeta": { - "@onflow/util-config": { - "optional": true - } + "engines": { + "node": ">=16" } }, - "packages/util-semver": { - "name": "@onflow/util-semver", - "version": "1.0.0", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime": "^7.18.6" - }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "jest": "^29.5.0" + "packages/util-invariant/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" } }, - "packages/util-template": { - "name": "@onflow/util-template", - "version": "1.1.0", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime": "^7.18.6" + "packages/util-invariant/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "jest": "^29.5.0" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/util-uid": { - "name": "@onflow/util-uid", - "version": "1.1.0", - "license": "Apache-2.0", + "packages/util-invariant/node_modules/eslint-plugin-jsdoc": { + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, "dependencies": { - "@babel/runtime": "^7.18.6" + "@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" }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-invariant/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-invariant/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-invariant/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-logger": { + "name": "@onflow/util-logger", + "version": "1.2.2", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", + "jest": "^29.5.0" + }, + "peerDependencies": { + "@onflow/util-config": ">1.1.1" + }, + "peerDependenciesMeta": { + "@onflow/util-config": { + "optional": true + } + } + }, + "packages/util-logger/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-logger/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-logger/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-logger/node_modules/eslint-plugin-jsdoc": { + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, + "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-logger/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-logger/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-logger/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-semver": { + "name": "@onflow/util-semver", + "version": "1.0.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "devDependencies": { + "@onflow/fcl-bundle": "^1.3.1", + "jest": "^29.5.0" + } + }, + "packages/util-template": { + "name": "@onflow/util-template", + "version": "1.1.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", + "jest": "^29.5.0" + } + }, + "packages/util-template/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-template/node_modules/@onflow/util-logger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@onflow/util-logger/-/util-logger-1.3.0.tgz", + "integrity": "sha512-MIDRS0Nv5mNV631S3VGU7d+v/+/Aw/69eN5HOLzJ5O5vG/0ETWwARgOSQVCOjtzztpX/FYrOwe24Mpu3qtXTyg==", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "peerDependencies": { + "@onflow/util-config": ">1.1.1" + }, + "peerDependenciesMeta": { + "@onflow/util-config": { + "optional": true + } + } + }, + "packages/util-template/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-template/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-template/node_modules/eslint-plugin-jsdoc": { + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, + "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-template/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-template/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-template/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-uid": { + "name": "@onflow/util-uid", + "version": "1.1.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } + }, + "packages/util-uid/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-uid/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-uid/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-uid/node_modules/eslint-plugin-jsdoc": { + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, + "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-uid/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-uid/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-uid/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } } } } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 14663bec8..db64a9c83 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -15,16 +15,17 @@ "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", - "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index e867fb0a9..b84ffe284 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -4,8 +4,9 @@ const commonjs = require("@rollup/plugin-commonjs") const replace = require("@rollup/plugin-replace") const {nodeResolve} = require("@rollup/plugin-node-resolve") const {babel} = require("@rollup/plugin-babel") -const terser = require('@rollup/plugin-terser') -const typescript = require('@rollup/plugin-typescript') +const terser = require("@rollup/plugin-terser") +const typescript = require("rollup-plugin-typescript2") +const {DEFAULT_EXTENSIONS} = require("@babel/core") const builtinModules = require("builtin-modules") @@ -16,12 +17,17 @@ const SUPPRESSED_WARNING_CODES = [ ] module.exports = function getInputOptions(package, build) { + // ensure that that package has the required dependencies if (!package.dependencies["@babel/runtime"]) { throw new Error( `${package.name} is missing required @babel/runtime dependency. Please add this to the package.json and try again.` ) } + // determine if we are building typescript + const source = build.source + const isTypeScript = source.endsWith(".ts") + const babelRuntimeVersion = package.dependencies["@babel/runtime"].replace( /^[^0-9]*/, "" @@ -44,7 +50,11 @@ module.exports = function getInputOptions(package, build) { }, false)) // exclude peer dependencies - const resolveOnly = [new RegExp(`^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*`)] + const resolveOnly = [ + new RegExp( + `^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*` + ), + ] let options = { input: build.source, @@ -54,20 +64,23 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - typescript(), - replace({ - preventAssignment: true, - PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), - }), - commonjs(), nodeResolve({ browser: true, preferBuiltins: build.type !== "umd", resolveOnly, }), + commonjs(), + isTypeScript && + typescript({ + clean: true, + }), + replace({ + preventAssignment: true, + PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), + }), babel({ babelHelpers: "runtime", - presets: [["@babel/preset-env"]], + presets: ["@babel/preset-env", "@babel/preset-typescript"], plugins: [ [ "@babel/plugin-transform-runtime", @@ -77,6 +90,7 @@ module.exports = function getInputOptions(package, build) { ], ], sourceMaps: true, + extensions: [...DEFAULT_EXTENSIONS, ".ts", ".tsx"], }), /\.min\.js$/.test(build.entry) && terser({ diff --git a/packages/fcl/src/current-user/index.js b/packages/fcl/src/current-user/index.js index 6cc83b0dc..20c2e1399 100644 --- a/packages/fcl/src/current-user/index.js +++ b/packages/fcl/src/current-user/index.js @@ -150,81 +150,83 @@ const makeConfig = async ({discoveryAuthnInclude, discoveryFeaturesSuggested}) = * @param {object} [opts.platform] - platform that runs the function * @param {object} [opts.service] - Optional service to use for authentication * @param {boolean} [opts.redir=false] - Optional flag to allow window to stay open after authentication - * @returns {Promise} - User object + * @returns {function(*)Promise} - User object */ -const getAuthenticate = ({platform}) => async ({service, redir = false} = {}) => { - if ( - service && - !service?.provider?.is_installed && - service?.provider?.requires_install - ) { - window.location.href = service?.provider?.install_link - return - } +const getAuthenticate = + ({platform}) => + async ({service, redir = false} = {}) => { + if ( + service && + !service?.provider?.is_installed && + service?.provider?.requires_install + ) { + window.location.href = service?.provider?.install_link + return + } - return new Promise(async (resolve, reject) => { - spawnCurrentUser() - const opts = {redir} - const user = await snapshot() - const discoveryService = await getDiscoveryService(service) - const refreshService = serviceOfType(user.services, "authn-refresh") - let accountProofData - - if (user.loggedIn) { - if (refreshService) { - try { - const response = await execService({ - service: refreshService, - msg: accountProofData, - opts, - platform, - }) - send(NAME, SET_CURRENT_USER, await buildUser(response)) - } catch (error) { - log({ - title: `${error.name} Could not refresh wallet authentication.`, - message: error.message, - level: LEVELS.error, - }) - } finally { - return resolve(await snapshot()) + return new Promise(async (resolve, reject) => { + spawnCurrentUser() + const opts = {redir} + const user = await snapshot() + const discoveryService = await getDiscoveryService(service) + const refreshService = serviceOfType(user.services, "authn-refresh") + let accountProofData + + if (user.loggedIn) { + if (refreshService) { + try { + const response = await execService({ + service: refreshService, + msg: accountProofData, + opts, + platform, + }) + send(NAME, SET_CURRENT_USER, await buildUser(response)) + } catch (error) { + log({ + title: `${error.name} Could not refresh wallet authentication.`, + message: error.message, + level: LEVELS.error, + }) + } finally { + return resolve(await snapshot()) + } + } else { + return resolve(user) } - } else { - return resolve(user) } - } - try { - accountProofData = await getAccountProofData() - } catch (error) { - log({ - title: `${error.name} On Authentication: Could not resolve account proof data.`, - message: error.message, - level: LEVELS.error, - }) - return reject(error) - } + try { + accountProofData = await getAccountProofData() + } catch (error) { + log({ + title: `${error.name} On Authentication: Could not resolve account proof data.`, + message: error.message, + level: LEVELS.error, + }) + return reject(error) + } - try { - const response = await execService({ - service: discoveryService, - msg: accountProofData, - config: await makeConfig(discoveryService), - opts, - platform, - }) - send(NAME, SET_CURRENT_USER, await buildUser(response)) - } catch (error) { - log({ - title: `${error} On Authentication`, - message: error, - level: LEVELS.error, - }) - } finally { - resolve(await snapshot()) - } - }) -} + try { + const response = await execService({ + service: discoveryService, + msg: accountProofData, + config: await makeConfig(discoveryService), + opts, + platform, + }) + send(NAME, SET_CURRENT_USER, await buildUser(response)) + } catch (error) { + log({ + title: `${error} On Authentication`, + message: error, + level: LEVELS.error, + }) + } finally { + resolve(await snapshot()) + } + }) + } /** * @description - Unauthenticate a user @@ -243,98 +245,102 @@ const normalizePreAuthzResponse = authz => ({ authorization: (authz || {}).authorization || [], }) -const getResolvePreAuthz = ({platform}) => (authz) => { - const resp = normalizePreAuthzResponse(authz) - const axs = [] - - if (resp.proposer != null) axs.push(["PROPOSER", resp.proposer]) - for (let az of resp.payer || []) axs.push(["PAYER", az]) - for (let az of resp.authorization || []) axs.push(["AUTHORIZER", az]) - - var result = axs.map(([role, az]) => ({ - tempId: [az.identity.address, az.identity.keyId].join("|"), - addr: az.identity.address, - keyId: az.identity.keyId, - signingFunction(signable) { - return execService({service: az, msg: signable, platform}) - }, - role: { - proposer: role === "PROPOSER", - payer: role === "PAYER", - authorizer: role === "AUTHORIZER", - }, - })) - return result -} +const getResolvePreAuthz = + ({platform}) => + authz => { + const resp = normalizePreAuthzResponse(authz) + const axs = [] + + if (resp.proposer != null) axs.push(["PROPOSER", resp.proposer]) + for (let az of resp.payer || []) axs.push(["PAYER", az]) + for (let az of resp.authorization || []) axs.push(["AUTHORIZER", az]) + + var result = axs.map(([role, az]) => ({ + tempId: [az.identity.address, az.identity.keyId].join("|"), + addr: az.identity.address, + keyId: az.identity.keyId, + signingFunction(signable) { + return execService({service: az, msg: signable, platform}) + }, + role: { + proposer: role === "PROPOSER", + payer: role === "PAYER", + authorizer: role === "AUTHORIZER", + }, + })) + return result + } /** * @description * Produces the needed authorization details for the current user to submit transactions to Flow * It defines a signing function that connects to a user's wallet provider to produce signatures to submit transactions. - * + * * @param {object} ops - running options * @param {string} ops.platform - platform that runs the function * @param {object} account - Account object * @returns {Promise} - Account object with signing function */ -const getAuthorization = ({platform}) => async (account) => { - spawnCurrentUser() +const getAuthorization = + ({platform}) => + async account => { + spawnCurrentUser() - return { - ...account, - tempId: "CURRENT_USER", - async resolve(account, preSignable) { - const user = await getAuthenticate({platform})({redir: true}) - const authz = serviceOfType(user.services, "authz") - const preAuthz = serviceOfType(user.services, "pre-authz") - - if (preAuthz) - return getResolvePreAuthz({platform})( - await execService({ - service: preAuthz, - msg: preSignable, - platform, - }) - ) - if (authz) { - let windowRef - if (isMobile() && authz.method === "WC/RPC") { - windowRef = window.open("", "_blank") - } - return { - ...account, - tempId: "CURRENT_USER", - resolve: null, - addr: sansPrefix(authz.identity.address), - keyId: authz.identity.keyId, - sequenceNum: null, - signature: null, - async signingFunction(signable) { - return normalizeCompositeSignature( - await execService({ - service: authz, - msg: signable, - opts: { - includeOlderJsonRpcCall: true, - windowRef, - }, - platform, - }) - ) - }, + return { + ...account, + tempId: "CURRENT_USER", + async resolve(account, preSignable) { + const user = await getAuthenticate({platform})({redir: true}) + const authz = serviceOfType(user.services, "authz") + const preAuthz = serviceOfType(user.services, "pre-authz") + + if (preAuthz) + return getResolvePreAuthz({platform})( + await execService({ + service: preAuthz, + msg: preSignable, + platform, + }) + ) + if (authz) { + let windowRef + if (isMobile() && authz.method === "WC/RPC") { + windowRef = window.open("", "_blank") + } + return { + ...account, + tempId: "CURRENT_USER", + resolve: null, + addr: sansPrefix(authz.identity.address), + keyId: authz.identity.keyId, + sequenceNum: null, + signature: null, + async signingFunction(signable) { + return normalizeCompositeSignature( + await execService({ + service: authz, + msg: signable, + opts: { + includeOlderJsonRpcCall: true, + windowRef, + }, + platform, + }) + ) + }, + } } - } - throw new Error( - "No Authz or PreAuthz Service configured for CURRENT_USER" - ) - }, + throw new Error( + "No Authz or PreAuthz Service configured for CURRENT_USER" + ) + }, + } } -} /** * @description * The callback passed to subscribe will be called when the user authenticates and un-authenticates, making it easy to update the UI accordingly. - * + * * @param {Function} callback - Callback function * @returns {Function} - Unsubscribe function */ @@ -373,15 +379,17 @@ async function info() { /** * @description - Resolves the current user as an argument - * + * * @param {object} ops - running options * @param {string} ops.platform - platform that runs the function * @returns {Promise} */ -const getResolveArgument = ({platform}) => async () => { - const {addr} = await getAuthenticate({platform})() - return arg(withPrefix(addr), t.Address) -} +const getResolveArgument = + ({platform}) => + async () => { + const {addr} = await getAuthenticate({platform})() + return arg(withPrefix(addr), t.Address) + } const makeSignable = msg => { invariant(/^[0-9a-f]+$/i.test(msg), "Message must be a hex string") @@ -396,33 +404,34 @@ const makeSignable = msg => { * @param {string} msg - Message to sign * @returns {Promise} - Array of CompositeSignatures */ -const getSignUserMessage = ({platform}) => async (msg) => { - spawnCurrentUser() - const user = await getAuthenticate({platform})({redir: true}) +const getSignUserMessage = + ({platform}) => + async msg => { + spawnCurrentUser() + const user = await getAuthenticate({platform})({redir: true}) - const signingService = serviceOfType(user.services, "user-signature") + const signingService = serviceOfType(user.services, "user-signature") - invariant( - signingService, - "Current user must have authorized a signing service." - ) + invariant( + signingService, + "Current user must have authorized a signing service." + ) - try { - const response = await execService({ - service: signingService, - msg: makeSignable(msg), - platform, - }) - if (Array.isArray(response)) { - return response.map(compSigs => normalizeCompositeSignature(compSigs)) - } else { - return [normalizeCompositeSignature(response)] + try { + const response = await execService({ + service: signingService, + msg: makeSignable(msg), + platform, + }) + if (Array.isArray(response)) { + return response.map(compSigs => normalizeCompositeSignature(compSigs)) + } else { + return [normalizeCompositeSignature(response)] + } + } catch (error) { + return error } - } catch (error) { - return error } -} - const getCurrentUser = ({platform}) => { let currentUser = () => { diff --git a/packages/fcl/src/fcl.ts b/packages/fcl/src/fcl.ts index 2b3677330..aad1d821a 100644 --- a/packages/fcl/src/fcl.ts +++ b/packages/fcl/src/fcl.ts @@ -1,10 +1,11 @@ -export * from './shared-exports'; +export * from "./shared-exports" import {getMutate} from "./exec/mutate" + export const mutate = getMutate({platform: "web"}) import {getCurrentUser} from "./current-user" -const currentUser = getCurrentUser({platform:"web"}) +const currentUser = getCurrentUser({platform: "web"}) export {currentUser} diff --git a/packages/rlp/.babelrc b/packages/rlp/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/rlp/.babelrc +++ b/packages/rlp/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/rlp/.eslintrc.json b/packages/rlp/.eslintrc.json new file mode 100644 index 000000000..815f845bc --- /dev/null +++ b/packages/rlp/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "jsdoc/require-jsdoc": 0, + "jsdoc/tag-lines": 0, + "jsdoc/require-param-description": 0, + "jsdoc/require-param": 0, + "jsdoc/valid-types": 0, + "jsdoc/require-returns-description": 0, + "jsdoc/require-returns": 0, + "@typescript-eslint/no-explicit-any": "off" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 0980763b8..9e84502ee 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -13,14 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "source": "src/index.ts", "main": "dist/rlp.js", "module": "dist/rlp.module.js", "unpkg": "dist/rlp.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/rlp/src/index.ts b/packages/rlp/src/index.ts index 3bd3a4d29..1ed6933f2 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -2,6 +2,15 @@ import {Buffer} from "buffer" export {Buffer} +type EncodeInput = + | Buffer + | string + | number + | Uint8Array + | null + | undefined + | EncodeInput[] + /** * Built on top of rlp library, removing the BN dependency for the flow. * Package : https://github.com/ethereumjs/rlp @@ -10,22 +19,22 @@ export {Buffer} * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @returns returns buffer of encoded data - **/ -export function encode(input) { + */ +export function encode(input: EncodeInput): Buffer { if (Array.isArray(input)) { - var output = [] - for (var i = 0; i < input.length; i++) { + const output = [] + for (let i = 0; i < input.length; i++) { output.push(encode(input[i])) } - var buf = Buffer.concat(output) + const buf = Buffer.concat(output) return Buffer.concat([encodeLength(buf.length, 192), buf]) } else { - var inputBuf = toBuffer(input) + const inputBuf = toBuffer(input) return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]) @@ -37,19 +46,19 @@ export function encode(input) { * @param v The value to parse * @param base The base to parse the integer into */ -function safeParseInt(v, base) { +function safeParseInt(v: string, base: number): number { if (v.slice(0, 2) === "00") { throw new Error("invalid RLP: extra zeros") } return parseInt(v, base) } -function encodeLength(len, offset) { +function encodeLength(len: number, offset: number): Buffer { if (len < 56) { return Buffer.from([len + offset]) } else { - var hexLength = intToHex(len) - var lLength = hexLength.length / 2 - var firstByte = intToHex(offset + 55 + lLength) + const hexLength = intToHex(len) + const lLength = hexLength.length / 2 + const firstByte = intToHex(offset + 55 + lLength) return Buffer.from(firstByte + hexLength, "hex") } } @@ -62,22 +71,22 @@ function encodeLength(len, offset) { * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @param stream Is the input a stream (false by default) * @returns returns buffer of encoded data - **/ -export function decode(input, stream) { + */ +export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { if (stream === void 0) { stream = false } if (!input || input.length === 0) { return Buffer.from([]) } - var inputBuffer = toBuffer(input) - var decoded = _decode(inputBuffer) + const inputBuffer = toBuffer(input) + const decoded = _decode(inputBuffer) if (stream) { return decoded } @@ -92,12 +101,15 @@ export function decode(input, stream) { * @param input * @returns The length of the input or an empty Buffer if no input */ -export function getLength(input) { - if (!input || input.length === 0) { - return Buffer.from([]) +export function getLength( + input: Buffer | Uint8Array | null | undefined | string | number +): number { + const inputBuffer = toBuffer(input) + if (inputBuffer.length === 0) { + return 0 } - var inputBuffer = toBuffer(input) - var firstByte = inputBuffer[0] + + const firstByte = inputBuffer[0] if (firstByte <= 0x7f) { return inputBuffer.length } else if (firstByte <= 0xb7) { @@ -109,17 +121,20 @@ export function getLength(input) { return firstByte - 0xbf } else { // a list over 55 bytes long - var llength = firstByte - 0xf6 - var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16) + const llength = firstByte - 0xf6 + const length = safeParseInt( + inputBuffer.slice(1, llength).toString("hex"), + 16 + ) return llength + length } } /** Decode an input with RLP */ -function _decode(input) { - var length, llength, data, innerRemainder, d - var decoded = [] - var firstByte = input[0] +function _decode(input: Buffer | Uint8Array): any { + let length, llength, data, innerRemainder, d + const decoded = [] + const firstByte = input[0] if (firstByte <= 0x7f) { // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. return { @@ -171,7 +186,7 @@ function _decode(input) { // a list over 55 bytes long llength = firstByte - 0xf6 length = safeParseInt(input.slice(1, llength).toString("hex"), 16) - var totalLength = llength + length + const totalLength = llength + length if (totalLength > input.length) { throw new Error("invalid rlp: total length is larger than the data") } @@ -191,36 +206,38 @@ function _decode(input) { } } /** Check if a string is prefixed by 0x */ -function isHexPrefixed(str) { +function isHexPrefixed(str: string) { return str.slice(0, 2) === "0x" } /** Removes 0x from a given String */ -function stripHexPrefix(str) { +function stripHexPrefix(str: string) { if (typeof str !== "string") { return str } return isHexPrefixed(str) ? str.slice(2) : str } /** Transform an integer into its hexadecimal value */ -function intToHex(integer) { +function intToHex(integer: number) { if (integer < 0) { throw new Error("Invalid integer as argument, must be unsigned!") } - var hex = integer.toString(16) + const hex = integer.toString(16) return hex.length % 2 ? "0" + hex : hex } /** Pad a string to be even */ -function padToEven(a) { +function padToEven(a: string) { return a.length % 2 ? "0" + a : a } /** Transform an integer into a Buffer */ -function intToBuffer(integer) { - var hex = intToHex(integer) +function intToBuffer(integer: number) { + const hex = intToHex(integer) return Buffer.from(hex, "hex") } /** Transform anything into a Buffer */ -export function toBuffer(v) { +export function toBuffer( + v: Buffer | string | number | Uint8Array | null | undefined +) { if (!Buffer.isBuffer(v)) { if (typeof v === "string") { if (isHexPrefixed(v)) { diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/rlp/tsconfig.json +++ b/packages/rlp/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/sdk/.babelrc b/packages/sdk/.babelrc index 779f5464f..1e3225d50 100644 --- a/packages/sdk/.babelrc +++ b/packages/sdk/.babelrc @@ -5,6 +5,7 @@ { "useBuiltIns": false } - ] + ], + "@babel/preset-typescript" ] } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index e6b4eb84e..9f7b388ab 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -34,7 +34,7 @@ "alpha": "npm publish --tag alpha", "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "tsc && npm run lint && fcl-bundle", + "build": "npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 6e0f2adc9..9a4decc99 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -83,7 +83,7 @@ export {resolveVoucherIntercept} from "./resolve/resolve-voucher-intercept.js" export {config} from "@onflow/config" // Deprecated -export const params = params => +export const params = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The params builder has been removed from the Flow JS-SDK/FCL.`, @@ -91,7 +91,7 @@ export const params = params => "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", level: logger.LEVELS.error, }) -export const param = params => +export const param = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The param builder has been removed from the Flow JS-SDK/FCL.`, @@ -103,4 +103,4 @@ export const param = params => import * as TestUtils from "./test-utils" export {TestUtils} -export {VERSION} from "./VERSION" \ No newline at end of file +export {VERSION} from "./VERSION" diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index bad746ff2..e11993fce 100644 --- a/packages/typedefs/package.json +++ b/packages/typedefs/package.json @@ -25,7 +25,7 @@ "main": "dist/typedefs.js", "module": "dist/typedefs.module.js", "unpkg": "dist/typedefs.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/typedefs/src/index.ts b/packages/typedefs/src/index.ts index 40b40b54f..5971369c2 100644 --- a/packages/typedefs/src/index.ts +++ b/packages/typedefs/src/index.ts @@ -1,290 +1,290 @@ export type Account = { - /** - * - The address of the account - */ - address: string; - /** - * - The FLOW balance of the account in 10^8 - */ - balance: number; - /** - * - The code of any Cadence contracts stored in the account - */ - code: number; - /** - * - An object with keys as the contract name deployed and the value as the the cadence string - */ - contracts: object; - /** - * - Any contracts deployed to this account - */ - keys: object; -}; + /** + * - The address of the account + */ + address: string + /** + * - The FLOW balance of the account in 10^8 + */ + balance: number + /** + * - The code of any Cadence contracts stored in the account + */ + code: number + /** + * - An object with keys as the contract name deployed and the value as the the cadence string + */ + contracts: object + /** + * - Any contracts deployed to this account + */ + keys: object +} export type Block = { - /** - * - The id of the block - */ - id: string; - /** - * - The id of the parent block - */ - parentId: string; - /** - * - The height of the block - */ - height: number; - /** - * - Time related fields - */ - timestamp: object; - /** - * - Contains the ids of collections included in the block - */ - collectionGuarantees: CollectionGuarantee; - /** - * - The details of which nodes executed and sealed the blocks - */ - blockSeals: object; - /** - * - The cryptographic signature of the block - */ - signatures: Array; -}; + /** + * - The id of the block + */ + id: string + /** + * - The id of the parent block + */ + parentId: string + /** + * - The height of the block + */ + height: number + /** + * - Time related fields + */ + timestamp: object + /** + * - Contains the ids of collections included in the block + */ + collectionGuarantees: CollectionGuarantee + /** + * - The details of which nodes executed and sealed the blocks + */ + blockSeals: object + /** + * - The cryptographic signature of the block + */ + signatures: Array +} export type CollectionGuarantee = { - /** - * - The id of the block - */ - collectionId: string; - /** - * - All signatures - */ - signatures: Array; -}; + /** + * - The id of the block + */ + collectionId: string + /** + * - All signatures + */ + signatures: Array +} export type CompositeSignature = { - /** - * - A type identifier used internally by FCL - */ - f_type: string; - /** - * - FCL protocol version - */ - f_vsn: string; - /** - * - Flow Address (sans prefix) - */ - addr: string; - /** - * - Key ID - */ - keyId: number; - /** - * - Signature as a hex string - */ - signature: string; -}; + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Flow Address (sans prefix) + */ + addr: string + /** + * - Key ID + */ + keyId: number + /** + * - Signature as a hex string + */ + signature: string +} export type CurrentUser = { - /** - * - The public address of the current user - */ - addr?: string; - /** - * - A wallet specified content identifier for user metadata - */ - cid?: string; - /** - * - A wallet specified time-frame for a valid session - */ - expiresAt?: number; - /** - * - A type identifier used internally by FCL - */ - f_type: string; - /** - * - FCL protocol version - */ - f_vsn: string; - /** - * - Whether or not the current user is logged in - */ - loggedIn?: boolean; - /** - * - A list of trusted services that express ways of interacting with the current user's identity - */ - services: Array; -}; + /** + * - The public address of the current user + */ + addr?: string + /** + * - A wallet specified content identifier for user metadata + */ + cid?: string + /** + * - A wallet specified time-frame for a valid session + */ + expiresAt?: number + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Whether or not the current user is logged in + */ + loggedIn?: boolean + /** + * - A list of trusted services that express ways of interacting with the current user's identity + */ + services: Array +} export type Event = { - /** - * - ID of the block that contains the event. - */ - blockId: string; - /** - * - Height of the block that contains the event. - */ - blockHeight: number; - /** - * - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' - */ - blockTimestamp: string; - /** - * - A string containing the event name. - */ - type: string; - /** - * - Can be used to query transaction information, eg. via a Flow block explorer. - */ - transactionId: string; - /** - * - Used to prevent replay attacks. - */ - transactionIndex: number; - /** - * - Used to prevent replay attacks. - */ - eventIndex: number; - /** - * - The data emitted from the event. - */ - data: any; -}; + /** + * - ID of the block that contains the event. + */ + blockId: string + /** + * - Height of the block that contains the event. + */ + blockHeight: number + /** + * - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' + */ + blockTimestamp: string + /** + * - A string containing the event name. + */ + type: string + /** + * - Can be used to query transaction information, eg. via a Flow block explorer. + */ + transactionId: string + /** + * - Used to prevent replay attacks. + */ + transactionIndex: number + /** + * - Used to prevent replay attacks. + */ + eventIndex: number + /** + * - The data emitted from the event. + */ + data: any +} export type Key = { - /** - * - Sequence number of key used by the proposer of this transaction - */ - sequenceNumber: number; - /** - * - The ID of the key in the account used by the proposer of this transaction - */ - keyId: number; - /** - * - The address of the proposer of this transaction - */ - address: string; -}; + /** + * - Sequence number of key used by the proposer of this transaction + */ + sequenceNumber: number + /** + * - The ID of the key in the account used by the proposer of this transaction + */ + keyId: number + /** + * - The address of the proposer of this transaction + */ + address: string +} export type Service = { - /** - * - A type identifier used internally by FCL - */ - f_type: string; - /** - * - FCL protocol version - */ - f_vsn: string; - /** - * - Service type - */ - type: string; - /** - * - Service method - */ - method: string; - /** - * - Service uid - */ - uid?: string; - /** - * - Service endpoint - */ - endpoint: string; - /** - * - Service provider object - */ - provider: Provider; + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Service type + */ + type: string + /** + * - Service method + */ + method: string + /** + * - Service uid + */ + uid?: string + /** + * - Service endpoint + */ + endpoint: string + /** + * - Service provider object + */ + provider: Provider - params: Record -}; + params: Record +} export type Signature = { - /** - * - Sequence number of the key used to perform this signature. - */ - sequenceNumber: string; - /** - * - ID of the key in the account used to perform this signature. - */ - keyId: number; - /** - * - The signature represented as a hex string. - */ - signature: string; -}; + /** + * - Sequence number of the key used to perform this signature. + */ + sequenceNumber: string + /** + * - ID of the key in the account used to perform this signature. + */ + keyId: number + /** + * - The signature represented as a hex string. + */ + signature: string +} export type Transaction = { - /** - * - The Cadence code used to execute this transaction. - */ - script: string; - /** - * - The JSON-CDC encoded arguments passed in to the transaction. - */ - args: Array; - /** - * - The reference block id for this transaction. - */ - referenceBlockId: string; - /** - * - The gas limit for the transaction. - */ - gasLimit: number; - /** - * - The key used by the proposer of this transaction. - */ - proposalKey: Key; - /** - * - Sequence number of the key used by the proposer of this transaction. - */ - sequenceNumber: string; - /** - * - The ID of the key in the account used by the proposer of this transaction. - */ - keyId: number; - /** - * - The address of the proposer of this transaction. - */ - address: string; - /** - * - Address of the payer of the transaction. - */ - payer: string; - /** - * - Address of the proposer of this transaction. - */ - proposer: string; - /** - * - Array of addresses of authorizers of this transaction. - */ - authorizers: Array; - /** - * - The payload signatures for the transaction. - */ - payloadSignatures: Array; - /** - * - The envelope signatures for the transaction. - */ - envelopeSignatures: Array; -}; + /** + * - The Cadence code used to execute this transaction. + */ + script: string + /** + * - The JSON-CDC encoded arguments passed in to the transaction. + */ + args: Array + /** + * - The reference block id for this transaction. + */ + referenceBlockId: string + /** + * - The gas limit for the transaction. + */ + gasLimit: number + /** + * - The key used by the proposer of this transaction. + */ + proposalKey: Key + /** + * - Sequence number of the key used by the proposer of this transaction. + */ + sequenceNumber: string + /** + * - The ID of the key in the account used by the proposer of this transaction. + */ + keyId: number + /** + * - The address of the proposer of this transaction. + */ + address: string + /** + * - Address of the payer of the transaction. + */ + payer: string + /** + * - Address of the proposer of this transaction. + */ + proposer: string + /** + * - Array of addresses of authorizers of this transaction. + */ + authorizers: Array + /** + * - The payload signatures for the transaction. + */ + payloadSignatures: Array + /** + * - The envelope signatures for the transaction. + */ + envelopeSignatures: Array +} export type TransactionStatus = { - /** - * - The ID of the Block the transaction is included in. - */ - blockId: string; - /** - * - The status code of the transaction. - */ - status: number; - /** - * - The status as as descriptive text (e.g. "FINALIZED"). - */ - statusString: string; - /** - * - The error message of the transaction. - */ - errorMessage: string; - /** - * - The events for this result. - */ - events: Array; -}; + /** + * - The ID of the Block the transaction is included in. + */ + blockId: string + /** + * - The status code of the transaction. + */ + status: number + /** + * - The status as as descriptive text (e.g. "FINALIZED"). + */ + statusString: string + /** + * - The error message of the transaction. + */ + errorMessage: string + /** + * - The events for this result. + */ + events: Array +} export type Provider = { - /** - * - Provider name. - */ - name: string; -}; + /** + * - Provider name. + */ + name: string +} diff --git a/packages/util-actor/package.json b/packages/util-actor/package.json index 8b0bedd6e..784f5a221 100644 --- a/packages/util-actor/package.json +++ b/packages/util-actor/package.json @@ -24,6 +24,7 @@ "main": "dist/actor.js", "module": "dist/actor.module.js", "unpkg": "dist/actor.umd.js", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-actor/src/index.ts b/packages/util-actor/src/index.ts index f89b9b4d2..73f40a08f 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -23,11 +23,15 @@ interface IRoot { FCL_REGISTRY: Record | null } -const root: IRoot = - (typeof self === "object" && self.self === self && (self as unknown) as IRoot) || - (typeof global === "object" && global.global === global && (global as unknown) as IRoot) || - (typeof window === "object" && window.window === window && (window as unknown) as IRoot) || - {FCL_REGISTRY: null} +const root: IRoot = (typeof self === "object" && + self.self === self && + (self as unknown as IRoot)) || + (typeof global === "object" && + global.global === global && + (global as unknown as IRoot)) || + (typeof window === "object" && + window.window === window && + (window as unknown as IRoot)) || {FCL_REGISTRY: null} root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY @@ -37,9 +41,25 @@ var pid = 0b0 const DEFAULT_TIMEOUT = 5000 const DEFAULT_TAG = "---" -type Tag = typeof INIT | typeof SUBSCRIBE | typeof UNSUBSCRIBE | typeof UPDATED | typeof SNAPSHOT | typeof EXIT | typeof TERMINATE | "@EXIT" | typeof DUMP | typeof INC | typeof KEYS; +type Tag = + | typeof INIT + | typeof SUBSCRIBE + | typeof UNSUBSCRIBE + | typeof UPDATED + | typeof SNAPSHOT + | typeof EXIT + | typeof TERMINATE + | "@EXIT" + | typeof DUMP + | typeof INC + | typeof KEYS -export const send = (addr: string, tag: Tag, data?: Record | null, opts: Record = {}) => +export const send = ( + addr: string, + tag: Tag, + data?: Record | null, + opts: Record = {} +) => new Promise((reply, reject) => { const expectReply = opts.expectReply || false const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT @@ -63,8 +83,7 @@ export const send = (addr: string, tag: Tag, data?: Record | null, } try { - FCL_REGISTRY[addr] && - FCL_REGISTRY[addr].mailbox.deliver(payload) + FCL_REGISTRY[addr] && FCL_REGISTRY[addr].mailbox.deliver(payload) if (!expectReply) reply(true) } catch (error) { console.error( @@ -81,7 +100,7 @@ export const kill = addr => { } const fromHandlers = - (handlers = {}) => + (handlers: Record = {}) => async ctx => { if (typeof handlers[INIT] === "function") await handlers[INIT](ctx) __loop: while (1) { @@ -107,7 +126,7 @@ const parseAddr = (addr): string => { return String(++pid) } return String(addr) -} +} export const spawn = (fn, rawAddr: number | null = null) => { const addr = parseAddr(rawAddr) @@ -124,7 +143,12 @@ export const spawn = (fn, rawAddr: number | null = null) => { const ctx = { self: () => addr, receive: () => FCL_REGISTRY[addr].mailbox.receive(), - send: (to: string, tag: Tag, data: Record | null, opts: Record = {}) => { + send: ( + to: string, + tag: Tag, + data: Record | null, + opts: Record = {} + ) => { opts.from = addr return send(to, tag, data, opts) }, diff --git a/packages/util-actor/tsconfig.json b/packages/util-actor/tsconfig.json index 88be905eb..e8262cfd4 100644 --- a/packages/util-actor/tsconfig.json +++ b/packages/util-actor/tsconfig.json @@ -7,5 +7,6 @@ // Removing this would place the .d.ts files // next to the .js files "outDir": "types", + "strict": false } -} \ No newline at end of file +} diff --git a/packages/util-address/.babelrc b/packages/util-address/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-address/.babelrc +++ b/packages/util-address/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-address/.eslintrc.json b/packages/util-address/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-address/.eslintrc.json +++ b/packages/util-address/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-address/package.json b/packages/util-address/package.json index 33454e365..4f930e22e 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -13,11 +13,15 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.7.5", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, @@ -25,7 +29,7 @@ "main": "dist/util-address.js", "module": "dist/util-address.module.js", "unpkg": "dist/util-address.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-address/src/index.test.js b/packages/util-address/src/index.test.ts similarity index 100% rename from packages/util-address/src/index.test.js rename to packages/util-address/src/index.test.ts diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts index 63ea0705a..33e05de1a 100644 --- a/packages/util-address/src/index.ts +++ b/packages/util-address/src/index.ts @@ -1,28 +1,28 @@ /** * @description Removes 0x from address if present - * @param {string} address - Flow address - * @returns {string} - Flow address without 0x prefix + * @param address - Flow address + * @returns Flow address without 0x prefix */ - export function sansPrefix(address: string | null): string { +export function sansPrefix(address: string | null): string | null { if (address == null) return null return address.replace(/^0x/, "").replace(/^Fx/, "") } /** * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix + * @param address - Flow address + * @returns Flow address with 0x prefix */ -export function withPrefix(address: string): string | null { +export function withPrefix(address: string | null): string | null { if (address == null) return null return "0x" + sansPrefix(address) } /** * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix + * @param address - Flow address + * @returns Flow address with 0x prefix */ -export function display(address: string | null): string { +export function display(address: string | null): string | null { return withPrefix(address) } diff --git a/packages/util-encode-key/.babelrc b/packages/util-encode-key/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-encode-key/.babelrc +++ b/packages/util-encode-key/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-encode-key/.eslintrc.json b/packages/util-encode-key/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-encode-key/.eslintrc.json +++ b/packages/util-encode-key/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 81bdc006d..43fcc0cd9 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -13,11 +13,15 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.8.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, @@ -25,14 +29,14 @@ "main": "dist/util-encode-key.js", "module": "dist/util-encode-key.module.js", "unpkg": "dist/util-encode-key.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", - "lint": "eslint src/*.ts" + "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", diff --git a/packages/util-encode-key/src/index.test.ts b/packages/util-encode-key/src/index.test.ts index 1caee139f..220e69b7b 100644 --- a/packages/util-encode-key/src/index.test.ts +++ b/packages/util-encode-key/src/index.test.ts @@ -1,10 +1,4 @@ -import { - encodeKey, - ECDSA_P256, - ECDSA_secp256k1, - SHA2_256, - SHA3_256, -} from "./" +import {encodeKey, ECDSA_P256, ECDSA_secp256k1, SHA2_256, SHA3_256} from "./" const PUBLIC_KEYS = [ "0bfcd8790c3ce88f3fac9d4bd23514f48bf0cdd1f6c3c8bdf87b11489b1bbeca1ef805ec2ee76451e9bdb265284f78febaeacbc8b0827e0a7baafee4e655d0b5", @@ -18,10 +12,10 @@ const HASHINGS = [SHA2_256, SHA3_256] const WEIGHTS = [0, 32, 512, 1000] -for (let [key_index, key] of PUBLIC_KEYS.entries()) { - for (let [curve_index, curve] of CURVES.entries()) { - for (let [hash_index, hash] of HASHINGS.entries()) { - for (let [weight_index, weight] of WEIGHTS.entries()) { +for (const [key_index, key] of PUBLIC_KEYS.entries()) { + for (const [curve_index, curve] of CURVES.entries()) { + for (const [hash_index, hash] of HASHINGS.entries()) { + for (const [weight_index, weight] of WEIGHTS.entries()) { test(`key:${key_index} curve:${curve_index} hash:${hash_index} weight:${weight_index}`, () => { expect(encodeKey(key, curve, hash, weight)).toMatchSnapshot() }) diff --git a/packages/util-encode-key/src/index.ts b/packages/util-encode-key/src/index.ts index 6c6b98b5b..9ba359091 100644 --- a/packages/util-encode-key/src/index.ts +++ b/packages/util-encode-key/src/index.ts @@ -3,48 +3,23 @@ import {encode} from "@onflow/rlp" // Curves -/** - * @type {number} - */ export const ECDSA_P256 = 2 - -/** - * @type {number} - */ export const ECDSA_secp256k1 = 3 - -/** - * @type {Set} - * @private - */ const VALID_CURVES = new Set([ECDSA_P256, ECDSA_secp256k1]) // Hashing -/** - * @type {number} - */ export const SHA2_256 = 1 - -/** - * @type {number} - */ export const SHA3_256 = 3 - -/** - * @type {Set} - * @private - */ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) /** * Encodes a key into a hex string - * - * @param {string} key - The key to encode (DER Hex) - * @param {number} curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] - * @param {number} hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] - * @param {number} weight - The weight you want this key to have [Range: 0..1000] - * @returns {string} - The encoded key + * @param key - The key to encode (DER Hex) + * @param curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] + * @param hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] + * @param weight - The weight you want this key to have [Range: 0..1000] + * @returns The encoded key * @throws {Error} - Throws if the key is not a string * @throws {Error} - Throws if the key is not in the correct format * @throws {Error} - Throws if the curve is not a number @@ -56,7 +31,12 @@ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) * import {encodeKey, ECDSA_P256, SHA3_256} from "@onflow/util-encode-key" * encodeKey("aabbccdd", ECDSA_P256, SHA3_256, 1000) // => "aabbccdd0201000" */ -export function encodeKey(key, curve, hash, weight = 1000) { +export function encodeKey( + key: string, + curve: number, + hash: number, + weight = 1000 +): string { invariant( typeof key === "string", "encodeKey(key, curve, hash, weight) -- invalid key (expecting type of string)" @@ -87,4 +67,4 @@ export function encodeKey(key, curve, hash, weight = 1000) { ) return encode([Buffer.from(key, "hex"), curve, hash, weight]).toString("hex") -} \ No newline at end of file +} diff --git a/packages/util-invariant/.eslintrc.json b/packages/util-invariant/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-invariant/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index 24c1fbfa0..9e3146c08 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -13,15 +13,21 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", "@onflow/types": "^1.1.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "source": "src/index.ts", "main": "dist/util-invariant.js", "module": "dist/util-invariant.module.js", "unpkg": "dist/util-invariant.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-invariant/src/index.test.js b/packages/util-invariant/src/index.test.ts similarity index 100% rename from packages/util-invariant/src/index.test.js rename to packages/util-invariant/src/index.test.ts diff --git a/packages/util-invariant/src/index.ts b/packages/util-invariant/src/index.ts index d453e9406..0fedc85b2 100644 --- a/packages/util-invariant/src/index.ts +++ b/packages/util-invariant/src/index.ts @@ -1,17 +1,16 @@ /** * Asserts fact is true, otherwise throw an error with invariant message - * @param {boolean} fact - * @param {string} msg - * @param {Array} rest - * @returns {void} + * @param fact + * @param msg + * @param rest */ -export function invariant(fact, msg, ...rest) { +export function invariant(fact: boolean, msg: string, ...rest: any[]) { if (!fact) { const error = new Error(`INVARIANT ${msg}`) error.stack = error.stack - .split("\n") - .filter(d => !/at invariant/.test(d)) - .join("\n") + ?.split("\n") + ?.filter(d => !/at invariant/.test(d)) + ?.join("\n") console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n") throw error } diff --git a/packages/util-logger/.babelrc b/packages/util-logger/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-logger/.babelrc +++ b/packages/util-logger/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-logger/.eslintrc.json b/packages/util-logger/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-logger/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index bb5dd02a9..3f8a90d4e 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "source": "src/util-logger.ts", "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", + "types": "dist/util-logger.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts index 489cbd11f..1510590b6 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -6,35 +6,29 @@ export const setConfig = _config => { /** * The levels of the logger - * - * @typedef {Object} LEVELS - * @property {number} debug - The debug level - * @property {number} info - The info level - * @property {number} log - The log level - * @property {number} warn - The warn level - * @property {number} error - The error level - * */ -export const LEVELS = Object.freeze({ - debug: 5, - info: 4, - log: 3, - warn: 2, - error: 1, -}) +export enum LEVELS { + debug = 5, + info = 4, + log = 3, + warn = 2, + error = 1, +} /** * Builds a message formatted for the logger - * - * @param {Object} options - The options for the log - * @param {string} options.title - The title of the log - * @param {string} options.message - The message of the log - * @returns {Array} - The message formatted for the logger - * + * @param options - The options for the log + * @param options.title - The title of the log + * @param options.message - The message of the log + * @returns The message formatted for the logger * @example * buildLoggerMessageArgs({ title: "My Title", message: "My Message" }) */ -const buildLoggerMessageArgs = ({title, message}) => { +const buildLoggerMessageArgs = (options: { + title: string + message: string +}): string[] => { + const {title, message} = options return [ ` %c${title} @@ -46,28 +40,28 @@ const buildLoggerMessageArgs = ({title, message}) => { ` .replace(/\n[^\S\r\n]+/g, "\n") .trim(), - , "font-weight:bold;font-family:monospace;", ] } /** * Logs messages based on the level of the message and the level set in the config - * - * @param {Object} options - The options for the log - * @param {string} options.title - The title of the log - * @param {string} options.message - The message of the log - * @param {number} options.level - The level of the log - * @param {boolean} options.always - Whether to always show the log - * @returns {Promise} - * + * @param options - The options for the log + * @param options.title - The title of the log + * @param options.message - The message of the log + * @param options.level - The level of the log + * @param options.always - Whether to always show the log * @example * log({ title: "My Title", message: "My Message", level: LEVELS.warn, always: false }) - * */ -export const log = async ({title, message, level, always = false}) => { - const configLoggerLevel = - (await config?.()?.get("logger.level")) ?? LEVELS.warn +export const log = async (options: { + title: string + message: string + level: number + always?: boolean +}) => { + const {title, message, level, always} = options + const configLoggerLevel = await config.get("logger.level", LEVELS.warn) // If config level is below message level then don't show it if (!always && configLoggerLevel < level) return @@ -93,31 +87,42 @@ export const log = async ({title, message, level, always = false}) => { } /** - * Logs a deprecation notice - * - * @param {Object} options - The options for the log - * @param {string} options.pkg - The package that is being deprecated - * @param {string} options.subject - The subject of the deprecation - * @param {string} options.transition - The transition path for the deprecation - * @param {number} options.level - The level of the log - * @param {string} options.message - The message of the log - * @param {Function} options.callback - A callback to run after the log - * @returns {Promise} - * + * Logs a deprecation notice. If a callback is provided this function returns a function that will call the callback and log the deprecation notice, otherwise it just logs the deprecation notice. + * @param options - The options for the log + * @param options.pkg - The package that is being deprecated + * @param options.subject - The subject of the deprecation + * @param options.transition - The transition path for the deprecation + * @param options.level - The level of the log + * @param options.message - The message of the log + * @param options.callback - A callback to run after the log + * @returns A function that will call the callback and log the deprecation notice if the callback is provided * @example + * // Logs a deprecation notice * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) - * + * @example + * function someFunction() { ... } + * const deprecatedFunction = log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/foo/bar/TRANSITIONS.md", message: "Descriptive message", level: LEVELS.warn, callback: someFunction }) + * deprecatedFunction() // Calls someFunction and logs the deprecation notice */ -log.deprecate = ({ - pkg, - subject, - transition, - level = LEVELS.warn, - message = "", - callback = null, -}) => { - const capitalizeFirstLetter = string => { - return string.charAt(0).toUpperCase() + string.slice(1) +log.deprecate = (options: { + pkg?: string + subject?: string + transition?: string + level?: number + message?: string + callback?: (...args: T[]) => U +}): ((...args: T[]) => Promise) | Promise => { + const { + pkg, + subject, + transition, + level = LEVELS.warn, + message = "", + callback = null, + } = options + + const capitalizeFirstLetter = (str: string) => { + return str.charAt(0).toUpperCase() + str.slice(1) } const logMessage = () => @@ -142,7 +147,7 @@ log.deprecate = ({ }) if (typeof callback === "function") { - return async (...args) => { + return async (...args: T[]) => { await logMessage() return await callback(...args) } diff --git a/packages/util-template/.babelrc b/packages/util-template/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-template/.babelrc +++ b/packages/util-template/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-template/.eslintrc.json b/packages/util-template/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-template/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 87a72afe9..164129fce 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/template.js", + "source": "src/template.ts", "main": "dist/template.js", "module": "dist/template.module.js", "unpkg": "dist/template.umd.js", + "types": "dist/template.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", @@ -28,6 +35,7 @@ "start": "fcl-bundle --watch" }, "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" } } diff --git a/packages/util-template/src/__snapshots__/template.test.js.snap b/packages/util-template/src/__snapshots__/template.test.ts.snap similarity index 94% rename from packages/util-template/src/__snapshots__/template.test.js.snap rename to packages/util-template/src/__snapshots__/template.test.ts.snap index 5a768939f..614f991a9 100644 --- a/packages/util-template/src/__snapshots__/template.test.js.snap +++ b/packages/util-template/src/__snapshots__/template.test.ts.snap @@ -10,7 +10,7 @@ exports[`template interop function template(template\`\${o=>o.a}\`)(o) -> 'abc' exports[`template interop function template\`\${o=>o.a}\`(o) -> 'abc' 1`] = `"abc"`; -exports[`template interop more template template(template\`x\${template\`y\${o => o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; +exports[`template interop more template template(template\`x\${template\`y\${(_o: typeof o) => _o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; exports[`template interop more template template\`x\${template\`y\${o=>o.a}\`}\`(o) => 'xyabc' 1`] = `"xyabc"`; diff --git a/packages/util-template/src/template.js b/packages/util-template/src/template.js deleted file mode 100644 index e064dab37..000000000 --- a/packages/util-template/src/template.js +++ /dev/null @@ -1,46 +0,0 @@ -import {log} from "@onflow/util-logger" - -export function interleave(a = [], b = [], c = []) { - if (!a.length && !b.length) return c - if (!a.length) return c - if (!b.length) return [...c, a[0]] - - const [aHead, ...aRest] = a - const [bHead, ...bRest] = b - - if (aHead !== undefined) c.push(aHead) - if (bHead !== undefined) c.push(bHead) - - return interleave(aRest, bRest, c) -} - -function recApply(d) { - return function (arg1) { - if (typeof arg1 === "function") { - log.deprecate({ - pkg: "FCL/SDK", - subject: "Interopolation of functions into template literals", - transition: - "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", - }) - return recApply(d)(arg1(d)) - } - return String(arg1) - } -} - -/** - * @param {(string|Array.<*>)} head - * @param {Array.<*>} rest - * @returns {{function(): string}} - */ -export function template(head, ...rest) { - if (typeof head === "string") return () => head - if (Array.isArray(head)) { - return d => - interleave(head, rest.map(recApply(d))) - .join("") - .trim() - } - return head -} diff --git a/packages/util-template/src/template.test.js b/packages/util-template/src/template.test.ts similarity index 72% rename from packages/util-template/src/template.test.js rename to packages/util-template/src/template.test.ts index 6014f676c..dac1be6cb 100644 --- a/packages/util-template/src/template.test.js +++ b/packages/util-template/src/template.test.ts @@ -23,14 +23,14 @@ describe("interleave", () => { }) }) -const _ = (msg, a, b) => { +const _ = (msg: string, a: unknown, b?: unknown) => { if (b == null) { test(msg, () => expect(a).toMatchSnapshot()) } else { test(msg, () => expect(a).toBe(b)) } } -const t = v => typeof v +const t = (v: T) => typeof v describe("template", () => { describe("input type vs output type", () => { @@ -52,10 +52,10 @@ describe("template", () => { describe("interop function", () => { const o = {a: "abc"} - _("template`${o=>o.a}`(o) -> 'abc'", template`${o => o.a}`(o)) + _("template`${o=>o.a}`(o) -> 'abc'", template`${(_o: typeof o) => _o.a}`(o)) _( "template(template`${o=>o.a}`)(o) -> 'abc'", - template(template`${o => o.a}`)(o) + template(template`${(_o: typeof o) => _o.a}`)(o) ) }) @@ -63,20 +63,20 @@ describe("template", () => { const o = {a: "abc"} _( "template`x${template`y${o=>o.a}`}`(o) => 'xyabc'", - template`x${template`y${o => o.a}`}`(o) + template`x${template`y${(_o: typeof o) => _o.a}`}`(o) ) _( "template`x${template`y${template`z${o=>o.a}`}`}`(o) => 'xyabc'", - template`x${template`y${template`z${o => o.a}`}`}`(o) + template`x${template`y${template`z${(_o: typeof o) => _o.a}`}`}`(o) ) _( - "template(template`x${template`y${o => o.a}`}`)(o) -> 'xyabc'", - template(template`x${template`y${o => o.a}`}`)(o) + "template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) -> 'xyabc'", + template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) ) }) describe("interop nested functions", () => { - const fn = a => b => c => d => e => f => f.a + const fn = () => () => () => () => () => (f: typeof o) => f.a const o = {a: "abc"} _("template`${fn}`(o) -> 'abc'", template`${fn}`(o)) }) @@ -88,8 +88,10 @@ describe("template", () => { describe("object can have non string values", () => { const data = {a: 1, b: NaN, c: undefined, d: null, e: false, f: true} - const tx = template`a:${o => o.a}|b:${o => o.b}|c:${o => o.c}|d:${o => - o.d}|e:${o => o.e}|f:${o => o.f}` + const tx = template`a:${(o: typeof data) => o.a}|b:${(o: typeof data) => + o.b}|c:${(o: typeof data) => o.c}|d:${(o: typeof data) => o.d}|e:${( + o: typeof data + ) => o.e}|f:${(o: typeof data) => o.f}` _("template(data)", tx(data), "a:1|b:NaN|c:undefined|d:null|e:false|f:true") }) }) diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts new file mode 100644 index 000000000..e2a68ae2e --- /dev/null +++ b/packages/util-template/src/template.ts @@ -0,0 +1,67 @@ +import {log} from "@onflow/util-logger" + +/** + * Interleaves two arrays + * @param a - The first array + * @param b - The second array + * @param c - The target array + * @returns The interleaved array + */ +export function interleave( + a: A[] = [], + b: B[] = [], + c: (A | B)[] = [] +): (A | B)[] { + if (!a.length && !b.length) return c + if (!a.length) return c + if (!b.length) { + c.push(...a) + return c + } + + const [aHead, ...aRest] = a + const [bHead, ...bRest] = b + + if (aHead !== undefined) c.push(aHead) + if (bHead !== undefined) c.push(bHead) + + return interleave(aRest, bRest, c) +} + +/** + * Recursively apply a value to a function + * @param d - The value to apply + * @returns A function that takes a function and applies the value to it + */ +function recApply(d: T): (x: U) => string { + return function (arg1) { + if (typeof arg1 === "function") { + log.deprecate({ + pkg: "FCL/SDK", + subject: "Interopolation of functions into template literals", + transition: + "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", + }) + return recApply(d)(arg1(d)) + } + return String(arg1) + } +} + +/** + * Creates a template function + * @param head - A string, template string array, or template function + * @param rest - The rest of the arguments + * @returns A template function + */ +export function template( + head: string | TemplateStringsArray | ((x?: unknown) => string), + ...rest: unknown[] +): (x?: unknown) => string { + if (typeof head === "string") return () => head + if (typeof head === "function") return head + return (x: unknown) => + interleave([...head], rest.map(recApply(x))) + .join("") + .trim() +} diff --git a/packages/util-template/tsconfig.json b/packages/util-template/tsconfig.json index 88be905eb..4ec7af1fd 100644 --- a/packages/util-template/tsconfig.json +++ b/packages/util-template/tsconfig.json @@ -6,6 +6,7 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", - } -} \ No newline at end of file + "outDir": "types" + }, + "exclude": ["src/__snapshots__"] +} diff --git a/packages/util-uid/.babelrc b/packages/util-uid/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-uid/.babelrc +++ b/packages/util-uid/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-uid/.eslintrc.json b/packages/util-uid/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-uid/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-uid/package.json b/packages/util-uid/package.json index bd6fb3856..8bafc143e 100644 --- a/packages/util-uid/package.json +++ b/packages/util-uid/package.json @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/util-uid.js", + "source": "src/util-uid.ts", "main": "dist/util-uid.js", "module": "dist/util-uid.module.js", "unpkg": "dist/util-uid.umd.js", + "types": "dist/util-uid.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-uid/src/util-uid.js b/packages/util-uid/src/util-uid.js deleted file mode 100644 index 878d61dd8..000000000 --- a/packages/util-uid/src/util-uid.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generates a unique identifier - * @returns {string} - */ -var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -var T = HEX.length - -export function uid() { - var str = "", - num = 32 - while (num--) str += HEX[(Math.random() * T) | 0] - return str -} diff --git a/packages/util-uid/src/util-uid.test.js b/packages/util-uid/src/util-uid.test.js deleted file mode 100644 index 0fbcb9ae6..000000000 --- a/packages/util-uid/src/util-uid.test.js +++ /dev/null @@ -1,5 +0,0 @@ -import {uid} from "./util-uid.js" - -test("placeholder", () => { - expect(uid()).not.toBe(1) -}) diff --git a/packages/util-uid/src/util-uid.test.ts b/packages/util-uid/src/util-uid.test.ts new file mode 100644 index 000000000..637cbe4f6 --- /dev/null +++ b/packages/util-uid/src/util-uid.test.ts @@ -0,0 +1,12 @@ +import {uid} from "./util-uid" + +test("it should generate a unique 32 character alphanumeric string", () => { + const set = new Set() + for (let i = 0; i < 1000; i++) { + const id = uid() + expect(id).toMatch(/^[a-zA-Z0-9]{32}$/) + expect(set.has(id)).toBe(false) + set.add(id) + } + expect(set.size).toBe(1000) +}) diff --git a/packages/util-uid/src/util-uid.ts b/packages/util-uid/src/util-uid.ts new file mode 100644 index 000000000..651251ef7 --- /dev/null +++ b/packages/util-uid/src/util-uid.ts @@ -0,0 +1,13 @@ +const HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +const T = HEX.length + +/** + * Generates a random unique identifier + * @returns 32 character alphanumeric string + */ +export function uid(): string { + let str = "", + num = 32 + while (num--) str += HEX[(Math.random() * T) | 0] + return str +} diff --git a/tsconfig.json b/tsconfig.json index ca733deed..244c48d2e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,10 @@ { // Change this to match your project - "exclude": [ - "**/*.test.ts", - "**/*.test.js" - ], + "exclude": ["**/*.test.ts", "**/*.test.js"], "compilerOptions": { "moduleResolution": "NodeNext", "target": "ES2015", - "types" : ["node", "jest"], + "types": ["node", "jest"], // Tells TypeScript to read JS files, as // normally they are ignored as source files "allowJs": true, @@ -19,5 +16,6 @@ // go to js file when using IDE functions like // "Go to Definition" in VSCode "declarationMap": false, + "strict": true } -} \ No newline at end of file +} From 81d4b40e5b76ffb85b6185a274ae1cbce5988e7b Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 25 Aug 2023 10:11:54 -0700 Subject: [PATCH 03/45] Convert @onflow/types to TS (#1760) * [WIP] Convert @onflow/types to TS * stash * kind of working * fix package.json * fix dictionary * fix tests * stash * strong type tests * remove any * rename * changeset --- .changeset/fluffy-yaks-allow.md | 5 + package-lock.json | 121 ++++++- packages/types/.babelrc | 6 +- packages/types/.eslintrc.json | 31 ++ packages/types/package.json | 19 +- packages/types/src/types.test.js | 249 -------------- packages/types/src/types.test.ts | 245 ++++++++++++++ packages/types/src/{types.js => types.ts} | 393 ++++++++++++++-------- 8 files changed, 661 insertions(+), 408 deletions(-) create mode 100644 .changeset/fluffy-yaks-allow.md create mode 100644 packages/types/.eslintrc.json delete mode 100644 packages/types/src/types.test.js create mode 100644 packages/types/src/types.test.ts rename packages/types/src/{types.js => types.ts} (58%) diff --git a/.changeset/fluffy-yaks-allow.md b/.changeset/fluffy-yaks-allow.md new file mode 100644 index 000000000..dd6cc2c28 --- /dev/null +++ b/.changeset/fluffy-yaks-allow.md @@ -0,0 +1,5 @@ +--- +"@onflow/types": minor +--- + +Convert @onflow/types to TypeScript diff --git a/package-lock.json b/package-lock.json index bf48f07b6..2be5f75d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20523,13 +20523,130 @@ "version": "1.1.0", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/types/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/types/node_modules/@onflow/util-logger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@onflow/util-logger/-/util-logger-1.3.0.tgz", + "integrity": "sha512-MIDRS0Nv5mNV631S3VGU7d+v/+/Aw/69eN5HOLzJ5O5vG/0ETWwARgOSQVCOjtzztpX/FYrOwe24Mpu3qtXTyg==", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "peerDependencies": { + "@onflow/util-config": ">1.1.1" + }, + "peerDependenciesMeta": { + "@onflow/util-config": { + "optional": true + } + } + }, + "packages/types/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/types/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/types/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "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/types/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/types/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/types/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-actor": { "name": "@onflow/util-actor", "version": "1.2.0", diff --git a/packages/types/.babelrc b/packages/types/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/types/.babelrc +++ b/packages/types/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/types/.eslintrc.json b/packages/types/.eslintrc.json new file mode 100644 index 000000000..712568225 --- /dev/null +++ b/packages/types/.eslintrc.json @@ -0,0 +1,31 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"], + "overrides": [ + { + "files": ["**/*.test.ts"], + "env": { + "jest": true + }, + "rules": { + "jsdoc/require-jsdoc": 0 + } + } + ] +} diff --git a/packages/types/package.json b/packages/types/package.json index 25df43c88..feda5130f 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -13,21 +13,30 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/types.js", + "source": "src/types.ts", "main": "dist/types.js", "module": "dist/types.module.js", "unpkg": "dist/types.umd.js", + "types": "dist/types.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "fcl-bundle", + "build": " npm run lint && fcl-bundle", "test:watch": "jest --watch", - "start": "fcl-bundle --watch" + "start": "fcl-bundle --watch", + "lint": "eslint src" }, "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" } } diff --git a/packages/types/src/types.test.js b/packages/types/src/types.test.js deleted file mode 100644 index 36a57df3b..000000000 --- a/packages/types/src/types.test.js +++ /dev/null @@ -1,249 +0,0 @@ -import * as t from "./types.js" -;[ - [t.Identity, 0, 0, 0], - [t.Identity, "a", "a", "a"], - [t.Identity, null, null, null], - [t.Int, "1", {type: "Int", value: "1"}, "1"], - [t.UInt, "1", {type: "UInt", value: "1"}, "1"], - [t.Int8, "8", {type: "Int8", value: "8"}, "8"], - [t.UInt8, "8", {type: "UInt8", value: "8"}, "8"], - [t.Int16, "16", {type: "Int16", value: "16"}, "16"], - [t.UInt16, "16", {type: "UInt16", value: "16"}, "16"], - [t.Int32, "32", {type: "Int32", value: "32"}, "32"], - [t.UInt32, "32", {type: "UInt32", value: "32"}, "32"], - [t.Int64, "64", {type: "Int64", value: "64"}, "64"], - [t.UInt64, "64", {type: "UInt64", value: "64"}, "64"], - [t.Int128, "128", {type: "Int128", value: "128"}, "128"], - [t.UInt128, "128", {type: "UInt128", value: "128"}, "128"], - [t.Int256, "256", {type: "Int256", value: "256"}, "256"], - [t.UInt256, "256", {type: "UInt256", value: "256"}, "256"], - [t.Word8, "8", {type: "Word8", value: "8"}, "8"], - [t.Word16, "16", {type: "Word16", value: "16"}, "16"], - [t.Word32, "32", {type: "Word32", value: "32"}, "32"], - [t.Word64, "64", {type: "Word64", value: "64"}, "64"], - [t.UFix64, "64", {type: "UFix64", value: "64"}, "64", true], - [t.Fix64, "64", {type: "Fix64", value: "64"}, "64", true], - [ - t.UFix64, - "64.000000001", - {type: "UFix64", value: "64.000000001"}, - "64.000000001", - true, - ], - [ - t.Fix64, - "64.000000001", - {type: "Fix64", value: "64.000000001"}, - "64.000000001", - true, - ], - [t.UFix64, "64.0", {type: "UFix64", value: "64.00000000"}, "64.0", false], - [t.Fix64, "64.0", {type: "Fix64", value: "64.00000000"}, "64.0", false], - [ - t.String, - "Go with the Flow", - {type: "String", value: "Go with the Flow"}, - "Go with the Flow", - ], - [t.Character, "c", {type: "Character", value: "c"}, "c"], - [t.Bool, true, {type: "Bool", value: true}, true], - [t.Address, "0x1", {type: "Address", value: "0x1"}, "0x1"], - [t.Void, null, {type: "Void"}, null], - [t.Optional(t.String), null, {type: "Optional", value: null}, null], - [ - t.Optional(t.String), - "test", - {type: "Optional", value: {type: "String", value: "test"}}, - "test", - ], - [ - t.Reference, - {address: "0x01", type: "0x01.CryptoKitty"}, - {type: "Reference", value: {address: "0x01", type: "0x01.CryptoKitty"}}, - {address: "0x01", type: "0x01.CryptoKitty"}, - ], - [ - t.Array(t.String), - ["test"], - {type: "Array", value: [{type: "String", value: "test"}]}, - ["test"], - ], - [ - t.Array([t.String, t.String]), - ["test1", "test2"], - { - type: "Array", - value: [ - {type: "String", value: "test1"}, - {type: "String", value: "test2"}, - ], - }, - ["test1", "test2"], - ], - [ - t.Dictionary([ - {key: t.Int, value: t.String}, - {key: t.Int, value: t.String}, - ]), - [ - {key: "1", value: "one"}, - {key: "2", value: "two"}, - ], - { - type: "Dictionary", - value: [ - {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, - {key: {type: "Int", value: "2"}, value: {type: "String", value: "two"}}, - ], - }, - [ - {key: "1", value: "one"}, - {key: "2", value: "two"}, - ], - ], - [ - t.Dictionary({key: t.Int, value: t.String}), - {key: "1", value: "one"}, - { - type: "Dictionary", - value: [ - {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, - ], - }, - {key: "1", value: "one"}, - ], - [ - t.Struct("0x01.Jeffysaur", [{value: t.String}]), - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - { - type: "Struct", - value: { - id: "0x01.Jeffysaur", - fields: [ - { - name: "Jeffysaur_Name", - value: {type: "String", value: "Mr Jeff The Dinosaur"}, - }, - ], - }, - }, - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - ], - [ - t.Enum("0x01.SuperEnum", [{value: t.String}]), - { - fields: [{name: "SuperKey1", value: "SuperValue1"}], - }, - { - type: "Enum", - value: { - id: "0x01.SuperEnum", - fields: [ - { - name: "SuperKey1", - value: {type: "String", value: "SuperValue1"}, - }, - ], - }, - }, - { - fields: [{name: "SuperKey1", value: "SuperValue1"}], - }, - ], - [ - t.Event("0x01.JeffWroteSomeJS", [{value: t.String}]), - { - fields: [{name: "wasTheCodeClean?", value: "absolutely"}], - }, - { - type: "Event", - value: { - id: "0x01.JeffWroteSomeJS", - fields: [ - { - name: "wasTheCodeClean?", - value: {type: "String", value: "absolutely"}, - }, - ], - }, - }, - { - fields: [{name: "wasTheCodeClean?", value: "absolutely"}], - }, - ], - [ - t.Resource("0x01.Jeffysaur", [{value: t.String}]), - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - { - type: "Resource", - value: { - id: "0x01.Jeffysaur", - fields: [ - { - name: "Jeffysaur_Name", - value: {type: "String", value: "Mr Jeff The Dinosaur"}, - }, - ], - }, - }, - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - ], - [ - t.Path, - { - domain: "public", - identifier: "flowTokenVault", - }, - { - type: "Path", - value: { - domain: "public", - identifier: "flowTokenVault", - }, - }, - { - domain: "public", - identifier: "flowTokenVault", - }, - ], - [ - t.Path, - { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - { - type: "Path", - value: { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - }, - { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - true, - ], -].forEach(([cast, input, asArgument, asInjection, shouldError = false]) => { - describe(cast.label, () => { - test(`t.${cast.label}.asArgument(${input})`, () => { - if (shouldError) { - expect(() => cast.asArgument(input)).toThrow() - } else { - expect(cast.asArgument(input)).toStrictEqual(asArgument) - } - }) - test(`t.${cast.label}.asInjection(${input})`, () => { - expect(cast.asInjection(input)).toStrictEqual(asInjection) - }) - }) -}) diff --git a/packages/types/src/types.test.ts b/packages/types/src/types.test.ts new file mode 100644 index 000000000..efabee647 --- /dev/null +++ b/packages/types/src/types.test.ts @@ -0,0 +1,245 @@ +import * as t from "./types" + +registerTest([t.Int, "1", {type: "Int", value: "1"}, "1"]) +registerTest([t.UInt, "1", {type: "UInt", value: "1"}, "1"]) +registerTest([t.Int8, "8", {type: "Int8", value: "8"}, "8"]) +registerTest([t.UInt8, "8", {type: "UInt8", value: "8"}, "8"]) +registerTest([t.Int16, "16", {type: "Int16", value: "16"}, "16"]) +registerTest([t.UInt16, "16", {type: "UInt16", value: "16"}, "16"]) +registerTest([t.Int32, "32", {type: "Int32", value: "32"}, "32"]) +registerTest([t.UInt32, "32", {type: "UInt32", value: "32"}, "32"]) +registerTest([t.Int64, "64", {type: "Int64", value: "64"}, "64"]) +registerTest([t.UInt64, "64", {type: "UInt64", value: "64"}, "64"]) +registerTest([t.Int128, "128", {type: "Int128", value: "128"}, "128"]) +registerTest([t.UInt128, "128", {type: "UInt128", value: "128"}, "128"]) +registerTest([t.Int256, "256", {type: "Int256", value: "256"}, "256"]) +registerTest([t.UInt256, "256", {type: "UInt256", value: "256"}, "256"]) +registerTest([t.Word8, "8", {type: "Word8", value: "8"}, "8"]) +registerTest([t.Word16, "16", {type: "Word16", value: "16"}, "16"]) +registerTest([t.Word32, "32", {type: "Word32", value: "32"}, "32"]) +registerTest([t.Word64, "64", {type: "Word64", value: "64"}, "64"]) +registerTest([t.UFix64, "64", {type: "UFix64", value: "64"}, "64", true]) +registerTest([t.Fix64, "64", {type: "Fix64", value: "64"}, "64", true]) +registerTest([ + t.UFix64, + "64.000000001", + {type: "UFix64", value: "64.000000001"}, + "64.000000001", + true, +]) +registerTest([ + t.Fix64, + "64.000000001", + {type: "Fix64", value: "64.000000001"}, + "64.000000001", + true, +]) +registerTest([ + t.UFix64, + "64.0", + {type: "UFix64", value: "64.00000000"}, + "64.0", + false, +]) +registerTest([ + t.Fix64, + "64.0", + {type: "Fix64", value: "64.00000000"}, + "64.0", + false, +]) +registerTest([ + t.String, + "Go with the Flow", + {type: "String", value: "Go with the Flow"}, + "Go with the Flow", +]) +registerTest([t.Character, "c", {type: "Character", value: "c"}, "c"]) +registerTest([t.Bool, true, {type: "Bool", value: true}, true]) +registerTest([t.Address, "0x1", {type: "Address", value: "0x1"}, "0x1"]) +registerTest([t.Void, null, {type: "Void", value: null}, null]) +registerTest([ + t.Optional(t.String), + null, + {type: "Optional", value: null}, + null, +]) +registerTest([ + t.Optional(t.String), + "test", + {type: "Optional", value: {type: "String", value: "test"}}, + "test", +]) +registerTest([ + t.Reference, + {address: "0x01", type: "0x01.CryptoKitty"}, + {type: "Reference", value: {address: "0x01", type: "0x01.CryptoKitty"}}, + {address: "0x01", type: "0x01.CryptoKitty"}, +]) +registerTest([ + t.Array(t.String), + ["test"], + {type: "Array", value: [{type: "String", value: "test"}]}, + ["test"], +]) +registerTest([ + t.Array([t.String, t.String]), + ["test1", "test2"], + { + type: "Array", + value: [ + {type: "String", value: "test1"}, + {type: "String", value: "test2"}, + ], + }, + ["test1", "test2"], +]) +registerTest([ + t.Dictionary([ + {key: t.Int, value: t.String}, + {key: t.Int, value: t.String}, + ]), + [ + {key: "1", value: "one"}, + {key: "2", value: "two"}, + ], + { + type: "Dictionary", + value: [ + {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, + {key: {type: "Int", value: "2"}, value: {type: "String", value: "two"}}, + ], + }, + [ + {key: "1", value: "one"}, + {key: "2", value: "two"}, + ], +]) +registerTest([ + t.Dictionary({key: t.Int, value: t.String}), + {key: "1", value: "one"}, + { + type: "Dictionary", + value: [ + {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, + ], + }, + {key: "1", value: "one"}, +]) +registerTest([ + t.Struct("0x01.Jeffysaur", [{value: t.String}]), + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, + { + type: "Struct", + value: { + id: "0x01.Jeffysaur", + fields: [ + { + name: "Jeffysaur_Name", + value: {type: "String", value: "Mr Jeff The Dinosaur"}, + }, + ], + }, + }, + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, +]) +registerTest([ + t.Enum("0x01.SuperEnum", [{value: t.String}]), + {fields: [{name: "SuperKey1", value: "SuperValue1"}]}, + { + type: "Enum", + value: { + id: "0x01.SuperEnum", + fields: [ + {name: "SuperKey1", value: {type: "String", value: "SuperValue1"}}, + ], + }, + }, + {fields: [{name: "SuperKey1", value: "SuperValue1"}]}, +]) +registerTest([ + t.Event("0x01.JeffWroteSomeJS", [{value: t.String}]), + {fields: [{name: "wasTheCodeClean?", value: "absolutely"}]}, + { + type: "Event", + value: { + id: "0x01.JeffWroteSomeJS", + fields: [ + { + name: "wasTheCodeClean?", + value: {type: "String", value: "absolutely"}, + }, + ], + }, + }, + {fields: [{name: "wasTheCodeClean?", value: "absolutely"}]}, +]) +registerTest([ + t.Resource("0x01.Jeffysaur", [{value: t.String}]), + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, + { + type: "Resource", + value: { + id: "0x01.Jeffysaur", + fields: [ + { + name: "Jeffysaur_Name", + value: {type: "String", value: "Mr Jeff The Dinosaur"}, + }, + ], + }, + }, + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, +]) +registerTest([ + t.Path, + { + domain: "public" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + {type: "Path", value: {domain: "public", identifier: "flowTokenVault"}}, + { + domain: "public" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, +]) +registerTest([ + t.Path, + { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + { + type: "Path", + value: { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + }, + { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + true, +]) + +function registerTest([ + cast, + input, + asArgument, + asInjection, + shouldError = false, +]: readonly [t.TypeDescriptor, X, t.JsonCdc, X, boolean?]) { + describe(cast.label, () => { + test(`t.${cast.label}.asArgument(${input})`, () => { + if (shouldError) { + expect(() => cast.asArgument(input)).toThrow() + } else { + expect(cast.asArgument(input)).toStrictEqual(asArgument) + } + }) + test(`t.${cast.label}.asInjection(${input})`, () => { + expect(cast.asInjection(input)).toStrictEqual(asInjection) + }) + }) +} diff --git a/packages/types/src/types.js b/packages/types/src/types.ts similarity index 58% rename from packages/types/src/types.js rename to packages/types/src/types.ts index 543887322..17cbf4b92 100644 --- a/packages/types/src/types.js +++ b/packages/types/src/types.ts @@ -1,24 +1,64 @@ -import {log, LEVELS} from "@onflow/util-logger" +import {log} from "@onflow/util-logger" -const type = (label, asArgument, asInjection) => ({ +export type JsonCdc = { + type: L + value: T +} + +export interface PathValue { + domain: "storage" | "private" | "public" + identifier: string +} + +export interface ReferenceValue { + type: string + address: string +} + +export interface TypeDescriptor { + label: L + asArgument: (x: T) => JsonCdc + asInjection: (x: T) => T +} + +/** + * Creates a type descriptor for a given type + * @param label - The label for the type + * @param asArgument - A function that converts the type to a JsonCdcType + * @param asInjection - A function which returns the argument as is + * @returns A type descriptor + * @internal + */ +const typedef = ( + label: L, + asArgument: (x: T) => JsonCdc, + asInjection: (x: T) => T +): TypeDescriptor => ({ label, asArgument, - asInjection, + asInjection: (x: T) => { + log.deprecate({ + pkg: "@onflow/types", + subject: `Passing in ${label} as value for ${label}`, + message: `Going forward, use ${label} as value for ${label}.`, + }) + return asInjection(x) + }, }) -const isArray = d => Array.isArray(d) -const isObj = d => typeof d === "object" -const isNull = d => d == null -const isBoolean = d => typeof d === "boolean" -const isNumber = d => typeof d === "number" -const isInteger = d => Number.isInteger(d) -const isString = d => typeof d === "string" +const isArray = (d: unknown): d is T[] => Array.isArray(d) +const isObj = (d: unknown): d is object => typeof d === "object" +const isNull = (d: unknown): d is null | undefined => d == null +const isBoolean = (d: unknown): d is boolean => typeof d === "boolean" +const isNumber = (d: unknown): d is number => typeof d === "number" +const isInteger = (d: unknown): d is number => Number.isInteger(d) +const isString = (d: unknown): d is string => typeof d === "string" -const throwTypeError = msg => { +const throwTypeError = (msg: unknown): never => { throw new Error("Type Error: " + msg) } -const numberValuesDeprecationNotice = type => { +const numberValuesDeprecationNotice = (type: string) => { log.deprecate({ pkg: "@onflow/types", subject: `Passing in Number as value for ${type}`, @@ -28,15 +68,30 @@ const numberValuesDeprecationNotice = type => { }) } -export const Identity = type( - "Identity", - v => v, - v => v -) +let identityDeprecationShown = false +/** + * @deprecated will be removed in v2.0.0 + */ +export const Identity = { + label: "Identity", + asArgument: (v: T) => { + if (!identityDeprecationShown) { + log.deprecate({ + pkg: "@onflow/types", + subject: "Identity", + message: + "Identity type is deprecated and will be removed in v2.0.0. Please remove it from your code.", + }) + identityDeprecationShown = true + } + return v + }, + asInjection: (v: T) => v, +} -export const UInt = type( +export const UInt = typedef( "UInt", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt") return { @@ -50,14 +105,14 @@ export const UInt = type( value: v, } } - throwTypeError("Expected Positive Integer for type Unsigned Int") + return throwTypeError("Expected Positive Integer for type Unsigned Int") }, v => v ) -export const Int = type( +export const Int = typedef( "Int", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int") return { @@ -71,14 +126,14 @@ export const Int = type( value: v, } } - throwTypeError("Expected Integer for type Int") + return throwTypeError("Expected Integer for type Int") }, v => v ) -export const UInt8 = type( +export const UInt8 = typedef( "UInt8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt8") return { @@ -92,14 +147,14 @@ export const UInt8 = type( value: v, } } - throwTypeError("Expected integer for UInt8") + return throwTypeError("Expected integer for UInt8") }, v => v ) -export const Int8 = type( +export const Int8 = typedef( "Int8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int8") return { @@ -113,14 +168,14 @@ export const Int8 = type( value: v, } } - throwTypeError("Expected positive integer for Int8") + return throwTypeError("Expected positive integer for Int8") }, v => v ) -export const UInt16 = type( +export const UInt16 = typedef( "UInt16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt16") return { @@ -134,14 +189,14 @@ export const UInt16 = type( value: v, } } - throwTypeError("Expected integer for UInt16") + return throwTypeError("Expected integer for UInt16") }, v => v ) -export const Int16 = type( +export const Int16 = typedef( "Int16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int16") return { @@ -155,14 +210,14 @@ export const Int16 = type( value: v, } } - throwTypeError("Expected positive integer for Int16") + return throwTypeError("Expected positive integer for Int16") }, v => v ) -export const UInt32 = type( +export const UInt32 = typedef( "UInt32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt32") return { @@ -176,14 +231,14 @@ export const UInt32 = type( value: v, } } - throwTypeError("Expected integer for UInt32") + return throwTypeError("Expected integer for UInt32") }, v => v ) -export const Int32 = type( +export const Int32 = typedef( "Int32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int32") return { @@ -197,14 +252,14 @@ export const Int32 = type( value: v, } } - throwTypeError("Expected positive integer for Int32") + return throwTypeError("Expected positive integer for Int32") }, v => v ) -export const UInt64 = type( +export const UInt64 = typedef( "UInt64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt64") return { @@ -218,14 +273,14 @@ export const UInt64 = type( value: v, } } - throwTypeError("Expected integer for UInt64") + return throwTypeError("Expected integer for UInt64") }, v => v ) -export const Int64 = type( +export const Int64 = typedef( "Int64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int64") return { @@ -239,14 +294,14 @@ export const Int64 = type( value: v, } } - throwTypeError("Expected positive integer for Int64") + return throwTypeError("Expected positive integer for Int64") }, v => v ) -export const UInt128 = type( +export const UInt128 = typedef( "UInt128", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt128") return { @@ -260,14 +315,14 @@ export const UInt128 = type( value: v, } } - throwTypeError("Expected integer for UInt128") + return throwTypeError("Expected integer for UInt128") }, v => v ) -export const Int128 = type( +export const Int128 = typedef( "Int128", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int128") return { @@ -281,14 +336,14 @@ export const Int128 = type( value: v, } } - throwTypeError("Expected positive integer for Int128") + return throwTypeError("Expected positive integer for Int128") }, v => v ) -export const UInt256 = type( +export const UInt256 = typedef( "UInt256", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt256") return { @@ -302,14 +357,14 @@ export const UInt256 = type( value: v, } } - throwTypeError("Expected integer for UInt256") + return throwTypeError("Expected integer for UInt256") }, v => v ) -export const Int256 = type( +export const Int256 = typedef( "Int256", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int256") return { @@ -323,14 +378,14 @@ export const Int256 = type( value: v, } } - throwTypeError("Expected integer for Int256") + return throwTypeError("Expected integer for Int256") }, v => v ) -export const Word8 = type( +export const Word8 = typedef( "Word8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word8") return { @@ -344,14 +399,14 @@ export const Word8 = type( value: v, } } - throwTypeError("Expected positive number for Word8") + return throwTypeError("Expected positive number for Word8") }, v => v ) -export const Word16 = type( +export const Word16 = typedef( "Word16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word16") return { @@ -365,14 +420,14 @@ export const Word16 = type( value: v, } } - throwTypeError("Expected positive number for Word16") + return throwTypeError("Expected positive number for Word16") }, v => v ) -export const Word32 = type( +export const Word32 = typedef( "Word32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word32") return { @@ -386,14 +441,14 @@ export const Word32 = type( value: v, } } - throwTypeError("Expected positive number for Word32") + return throwTypeError("Expected positive number for Word32") }, v => v ) -export const Word64 = type( +export const Word64 = typedef( "Word64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word64") return { @@ -407,7 +462,7 @@ export const Word64 = type( value: v, } } - throwTypeError("Expected positive number for Word64") + return throwTypeError("Expected positive number for Word64") }, v => v ) @@ -421,18 +476,18 @@ const UFix64AndFix64NumberDeprecationNotice = () => { }) } -export const UFix64 = type( +export const UFix64 = typedef( "UFix64", - v => { + (v: number | string) => { if (isString(v)) { const vParts = v.split(".") if (vParts.length !== 2) { - throwTypeError( + return throwTypeError( `Expected one decimal but found ${vParts.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } if (vParts[1].length == 0 || vParts[1].length > 8) { - throwTypeError( + return throwTypeError( `Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${vParts[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } @@ -452,23 +507,23 @@ export const UFix64 = type( value: v.toString(), } } - throwTypeError("Expected String for UFix64") + return throwTypeError("Expected String for UFix64") }, v => v ) -export const Fix64 = type( +export const Fix64 = typedef( "Fix64", - v => { + (v: number | string) => { if (isString(v)) { const vParts = v.split(".") if (vParts.length !== 2) { - throwTypeError( + return throwTypeError( `Expected one decimal but found ${vParts.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } if (vParts[1].length == 0 || vParts[1].length > 8) { - throwTypeError( + return throwTypeError( `Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${vParts[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } @@ -488,102 +543,107 @@ export const Fix64 = type( value: v.toString(), } } - throwTypeError("Expected String for Fix64") + return throwTypeError("Expected String for Fix64") }, v => v ) -export const String = type( +export const String = typedef( "String", - v => { + (v: string) => { if (isString(v)) return { type: "String", value: v, } - throwTypeError("Expected String for type String") + return throwTypeError("Expected String for type String") }, v => v ) -export const Character = type( +export const Character = typedef( "Character", - v => { + (v: string) => { if (isString(v)) return { type: "Character", value: v, } - throwTypeError("Expected Character for type Character") + return throwTypeError("Expected Character for type Character") }, v => v ) -export const Bool = type( +export const Bool = typedef( "Bool", - v => { + (v: boolean) => { if (isBoolean(v)) return { type: "Bool", value: v, } - throwTypeError("Expected Boolean for type Bool") + return throwTypeError("Expected Boolean for type Bool") }, v => v ) -export const Address = type( +export const Address = typedef( "Address", - v => { + (v: string) => { if (isString(v)) return { type: "Address", value: v, } - throwTypeError("Expected Address for type Address") + return throwTypeError("Expected Address for type Address") }, v => v ) -export const Void = type( +export const Void = typedef( "Void", - v => { + (v?: null) => { if (!v || isNull(v)) return { type: "Void", + value: null, // so that it confroms to JsonCdcType interface } - throwTypeError("Expected Void for type Void") + return throwTypeError("Expected Void for type Void") }, v => v ) -export const Optional = children => - type( +export const Optional = ( + children: TypeDescriptor +) => + typedef( "Optional", - v => ({ + (v?: T | null) => ({ type: "Optional", value: isNull(v) ? null : children.asArgument(v), }), v => v ) -export const Reference = type( +export const Reference = typedef( "Reference", - v => { + (v: ReferenceValue) => { if (isObj(v)) return { type: "Reference", value: v, } - throwTypeError("Expected Object for type Reference") + return throwTypeError("Expected Object for type Reference") }, v => v ) -export const _Array = (children = []) => - type( +export const _Array = ( + children: TypeDescriptor[] | TypeDescriptor = [] +) => + typedef( "Array", - v => { + (v: T[]) => { return { type: "Array", value: isArray(children) @@ -596,39 +656,63 @@ export const _Array = (children = []) => export {_Array as Array} -export const Dictionary = (children = []) => - type( +// TODO : Fix types. Think about cases... dont think children should ever be array... not sure +export const Dictionary = ( + children: + | { + key: TypeDescriptor + value: TypeDescriptor + }[] + | { + key: TypeDescriptor + value: TypeDescriptor + } = [] +) => + typedef( "Dictionary", - v => { + (v: {key: A; value: D}[] | {key: A; value: D}) => { + const vIsArray = isArray(v) + const childrenIsArray = isArray(children) + if (isObj(v)) return { type: "Dictionary", - value: isArray(children) - ? children.map((c, i) => ({ - key: c.key.asArgument(v[i].key), - value: c.value.asArgument(v[i].value), - })) - : isArray(v) - ? v.map(x => ({ - key: children.key.asArgument(x.key), - value: children.value.asArgument(x.value), - })) - : [ - { - key: children.key.asArgument(v.key), - value: children.value.asArgument(v.value), - }, - ], + value: + childrenIsArray && vIsArray + ? children.map((c, i) => ({ + key: c.key.asArgument(v[i].key), + value: c.value.asArgument(v[i].value), + })) + : vIsArray && !childrenIsArray + ? v.map(x => ({ + key: children.key.asArgument(x.key), + value: children.value.asArgument(x.value), + })) + : !vIsArray && !childrenIsArray + ? [ + { + key: children.key.asArgument(v.key), + value: children.value.asArgument(v.value), + }, + ] + : throwTypeError( + "Invalid arguments for Dictionary. Expected an of array of key/value pairs" + ), } - throwTypeError("Expected Object for type Dictionary") + return throwTypeError("Expected Object for type Dictionary") }, v => v ) -export const Event = (id, fields = []) => - type( +export const Event = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Event", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Event", @@ -645,15 +729,20 @@ export const Event = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Event") + return throwTypeError("Expected Object for type Event") }, v => v ) -export const Resource = (id, fields = []) => - type( +export const Resource = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Resource", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Resource", @@ -670,15 +759,20 @@ export const Resource = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Resource") + return throwTypeError("Expected Object for type Resource") }, v => v ) -export const Struct = (id, fields = []) => - type( +export const Struct = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Struct", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Struct", @@ -695,15 +789,20 @@ export const Struct = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Struct") + return throwTypeError("Expected Object for type Struct") }, v => v ) -export const Enum = (id, fields = []) => - type( +export const Enum = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Enum", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Enum", @@ -720,17 +819,17 @@ export const Enum = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Enum") + return throwTypeError("Expected Object for type Enum") }, v => v ) -export const Path = type( +export const Path = typedef( "Path", - v => { + (v: PathValue) => { if (isObj(v)) { if (!isString(v.domain)) { - throwTypeError( + return throwTypeError( `Expected a string for the Path domain but found ${v.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } @@ -742,13 +841,13 @@ export const Path = type( v.domain === "public" ) ) { - throwTypeError( + return throwTypeError( `Expected either "storage", "private" or "public" as the Path domain but found ${v.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } if (!isString(v.identifier)) { - throwTypeError( + return throwTypeError( `Expected a string for the Path identifier but found ${v.identifier}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } @@ -761,7 +860,7 @@ export const Path = type( }, } } - throwTypeError("Expected Object for type Path") + return throwTypeError("Expected Object for type Path") }, v => v ) From 0960cdce6808b265ef92791da06a6772e9353537 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 1 Sep 2023 14:05:27 -0700 Subject: [PATCH 04/45] PKG -- [util-actor] Enhance TS support (#1761) * PKG -- [util-actor] Enhance TS support * rename handlerfnmap --- .changeset/wise-apples-leave.md | 5 + package-lock.json | 102 ++++++- packages/util-actor/.eslintrc.json | 23 ++ packages/util-actor/package.json | 11 +- packages/util-actor/src/index.test.ts | 15 +- packages/util-actor/src/index.ts | 248 +++++++++++------- packages/util-actor/src/mailbox/index.test.ts | 20 +- packages/util-actor/src/mailbox/index.ts | 20 +- packages/util-actor/tsconfig.json | 3 +- 9 files changed, 319 insertions(+), 128 deletions(-) create mode 100644 .changeset/wise-apples-leave.md create mode 100644 packages/util-actor/.eslintrc.json diff --git a/.changeset/wise-apples-leave.md b/.changeset/wise-apples-leave.md new file mode 100644 index 000000000..efbbef93e --- /dev/null +++ b/.changeset/wise-apples-leave.md @@ -0,0 +1,5 @@ +--- +"@onflow/util-actor": minor +--- + +Enhance TS support for @onflow/util-actor diff --git a/package-lock.json b/package-lock.json index 2be5f75d9..c15779aef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20656,10 +20656,110 @@ "queue-microtask": "1.2.3" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/util-actor/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-actor/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-actor/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-actor/node_modules/eslint-plugin-jsdoc": { + "version": "46.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.5.1.tgz", + "integrity": "sha512-CPbvKprmEuJYoxMj5g8gXfPqUGgcqMM6jpH06Kp4pn5Uy5MrPkFKzoD7UFp2E4RBzfXbJz1+TeuEivwFVMkXBg==", + "dev": true, + "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-actor/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-actor/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-actor/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-address": { "name": "@onflow/util-address", "version": "1.1.0", diff --git a/packages/util-actor/.eslintrc.json b/packages/util-actor/.eslintrc.json new file mode 100644 index 000000000..e26aed124 --- /dev/null +++ b/packages/util-actor/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "@typescript-eslint/no-explicit-any": "off" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-actor/package.json b/packages/util-actor/package.json index 784f5a221..5f424136d 100644 --- a/packages/util-actor/package.json +++ b/packages/util-actor/package.json @@ -13,7 +13,13 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.3.1", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "dependencies": { @@ -30,6 +36,7 @@ "test": "jest", "build": "fcl-bundle", "test:watch": "jest --watch", - "start": "fcl-bundle --watch" + "start": "fcl-bundle --watch", + "lint": "eslint src --ext .ts" } } diff --git a/packages/util-actor/src/index.test.ts b/packages/util-actor/src/index.test.ts index da4441b8c..7bc79608c 100644 --- a/packages/util-actor/src/index.test.ts +++ b/packages/util-actor/src/index.test.ts @@ -1,4 +1,4 @@ -import {spawn, send, kill} from "./" +import {spawn, send, kill, ActorContext} from "./" const COUNT = "COUNT" const DUMP = "DUMP" @@ -8,7 +8,7 @@ const UPDATED = "UPDATED" const SUBSCRIBE = "SUBSCRIBE" const UNSUBSCRIBE = "UNSUBSCRIBE" -const counterLogic = async ctx => { +const counterLogic = async (ctx: ActorContext) => { ctx.put(COUNT, 0) __loop: while (1) { @@ -18,7 +18,7 @@ const counterLogic = async ctx => { switch (letter.tag) { case SUBSCRIBE: ctx.subscribe(letter.from) - ctx.send(letter.from, UPDATED, ctx.get(COUNT, 0)) + ctx.send(letter.from!, UPDATED, ctx.get(COUNT, 0)) continue __loop case UNSUBSCRIBE: @@ -44,11 +44,12 @@ const counterLogic = async ctx => { } } -const counter = name => spawn(counterLogic, name) -const dump = addr => send(addr, DUMP, null, {expectReply: true, timeout: 100}) -const inc = (addr, delta = 1) => send(addr, INC, {delta}) +const counter = (name: string) => spawn(counterLogic, name) +const dump = (addr: string) => + send(addr, DUMP, null, {expectReply: true, timeout: 100}) +const inc = (addr: string, delta = 1) => send(addr, INC, {delta}) -const subscribe = (addr, callback) => { +const subscribe = (addr: string, callback: (data: any) => void) => { const EXIT = "@EXIT" const self = spawn(async ctx => { ctx.send(addr, SUBSCRIBE) diff --git a/packages/util-actor/src/index.ts b/packages/util-actor/src/index.ts index 73f40a08f..b315f4da8 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -1,4 +1,6 @@ import {mailbox as createMailbox, type IMailbox} from "./mailbox" + +// eslint-disable-next-line @typescript-eslint/no-var-requires const queueMicrotask = require("queue-microtask") export const INIT = "INIT" @@ -14,7 +16,7 @@ const KEYS = "KEYS" interface IRegistryRecord { addr: string - mailbox: IMailbox + mailbox: IMailbox subs: Set kvs: Record error: any @@ -23,6 +25,37 @@ interface IRoot { FCL_REGISTRY: Record | null } +export type ActorContext = ReturnType + +export type Letter = { + to: string + from?: string + tag: string + data: any + timeout: number + reply: (data: any) => void + reject: (error: any) => void +} +export type HandlerFn = ( + ctx: ActorContext, + letter: Letter, + data: any +) => Promise | void +export type SpawnFn = (address?: string) => void +export interface ActorHandlers { + [INIT]?: (ctx: ActorContext) => Promise | void + [SUBSCRIBE]?: HandlerFn + [UNSUBSCRIBE]?: HandlerFn + [UPDATED]?: HandlerFn + [SNAPSHOT]?: HandlerFn + [EXIT]?: HandlerFn + [TERMINATE]?: HandlerFn + [DUMP]?: HandlerFn + [INC]?: HandlerFn + [KEYS]?: HandlerFn + [key: string]: HandlerFn | undefined +} + const root: IRoot = (typeof self === "object" && self.self === self && (self as unknown as IRoot)) || @@ -36,31 +69,31 @@ const root: IRoot = (typeof self === "object" && root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY const FCL_REGISTRY = root.FCL_REGISTRY -var pid = 0b0 +let pid = 0b0 const DEFAULT_TIMEOUT = 5000 -const DEFAULT_TAG = "---" -type Tag = - | typeof INIT - | typeof SUBSCRIBE - | typeof UNSUBSCRIBE - | typeof UPDATED - | typeof SNAPSHOT - | typeof EXIT - | typeof TERMINATE - | "@EXIT" - | typeof DUMP - | typeof INC - | typeof KEYS - -export const send = ( +export function send( + addr: string, + tag: keyof Handlers & string, + data?: Record | null, + opts?: {expectReply?: true; timeout?: number; from?: string} +): Promise +export function send( + addr: string, + tag: keyof Handlers & string, + data?: Record | null, + opts?: {expectReply?: false; timeout?: number; from?: string} +): Promise +export function send( addr: string, - tag: Tag, + tag: keyof Handlers & string, data?: Record | null, - opts: Record = {} -) => - new Promise((reply, reject) => { + opts: {expectReply?: boolean; timeout?: number; from?: string} = { + expectReply: false, + } +): Promise { + return new Promise((resolve, reject) => { const expectReply = opts.expectReply || false const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT @@ -78,13 +111,17 @@ export const send = ( tag, data, timeout, - reply, + reply: resolve, reject, } try { - FCL_REGISTRY[addr] && FCL_REGISTRY[addr].mailbox.deliver(payload) - if (!expectReply) reply(true) + if (FCL_REGISTRY[addr]) { + FCL_REGISTRY[addr].mailbox.deliver(payload) + } + if (!expectReply) { + resolve(true) + } } catch (error) { console.error( "FCL.Actor -- Could Not Deliver Message", @@ -92,16 +129,18 @@ export const send = ( FCL_REGISTRY[addr], error ) + reject(error) } }) +} -export const kill = addr => { +export const kill = (addr: string) => { delete FCL_REGISTRY[addr] } const fromHandlers = - (handlers: Record = {}) => - async ctx => { + (handlers: Handlers) => + async (ctx: ActorContext) => { if (typeof handlers[INIT] === "function") await handlers[INIT](ctx) __loop: while (1) { const letter = await ctx.receive() @@ -112,7 +151,7 @@ const fromHandlers = } break __loop } - await handlers[letter.tag](ctx, letter, letter.data || {}) + await handlers[letter.tag as any]?.(ctx, letter, letter.data || {}) } catch (error) { console.error(`${ctx.self()} Error`, letter, error) } finally { @@ -121,14 +160,17 @@ const fromHandlers = } } -const parseAddr = (addr): string => { +const parseAddr = (addr: string | number | null): string => { if (addr == null) { return String(++pid) } return String(addr) } -export const spawn = (fn, rawAddr: number | null = null) => { +export const spawn = ( + fnOrHandlers: ((ctx: ActorContext) => Promise) | Handlers, + rawAddr: string | number | null = null +) => { const addr = parseAddr(rawAddr) if (FCL_REGISTRY[addr] != null) return addr @@ -140,68 +182,12 @@ export const spawn = (fn, rawAddr: number | null = null) => { error: null, } - const ctx = { - self: () => addr, - receive: () => FCL_REGISTRY[addr].mailbox.receive(), - send: ( - to: string, - tag: Tag, - data: Record | null, - opts: Record = {} - ) => { - opts.from = addr - return send(to, tag, data, opts) - }, - sendSelf: (tag, data, opts) => { - if (FCL_REGISTRY[addr]) send(addr, tag, data, opts) - }, - broadcast: (tag, data, opts: Record = {}) => { - opts.from = addr - for (let to of FCL_REGISTRY[addr].subs) send(to, tag, data, opts) - }, - subscribe: sub => sub != null && FCL_REGISTRY[addr].subs.add(sub), - unsubscribe: sub => sub != null && FCL_REGISTRY[addr].subs.delete(sub), - subscriberCount: () => FCL_REGISTRY[addr].subs.size, - hasSubs: () => !!FCL_REGISTRY[addr].subs.size, - put: (key, value) => { - if (key != null) FCL_REGISTRY[addr].kvs[key] = value - }, - get: (key, fallback) => { - const value = FCL_REGISTRY[addr].kvs[key] - return value == null ? fallback : value - }, - delete: key => { - delete FCL_REGISTRY[addr].kvs[key] - }, - update: (key, fn) => { - if (key != null) - FCL_REGISTRY[addr].kvs[key] = fn(FCL_REGISTRY[addr].kvs[key]) - }, - keys: () => { - return Object.keys(FCL_REGISTRY[addr].kvs) - }, - all: () => { - return FCL_REGISTRY[addr].kvs - }, - where: pattern => { - return Object.keys(FCL_REGISTRY[addr].kvs).reduce((acc, key) => { - return pattern.test(key) - ? {...acc, [key]: FCL_REGISTRY[addr].kvs[key]} - : acc - }, {}) - }, - merge: (data = {}) => { - Object.keys(data).forEach( - key => (FCL_REGISTRY[addr].kvs[key] = data[key]) - ) - }, - fatalError: error => { - FCL_REGISTRY[addr].error = error - for (let to of FCL_REGISTRY[addr].subs) send(to, UPDATED) - }, - } + const ctx = createCtx(addr) - if (typeof fn === "object") fn = fromHandlers(fn) + let fn: (ctx: ActorContext) => Promise + if (typeof fnOrHandlers === "object") + fn = fromHandlers(fnOrHandlers) + else fn = fnOrHandlers queueMicrotask(async () => { await fn(ctx) @@ -211,6 +197,67 @@ export const spawn = (fn, rawAddr: number | null = null) => { return addr } +const createCtx = (addr: string) => ({ + self: () => addr, + receive: () => FCL_REGISTRY[addr].mailbox.receive(), + send: ( + to: string, + tag: string, + data?: any, + opts: Record = {} + ) => { + opts.from = addr + return send(to, tag, data, opts) + }, + sendSelf: (tag: string, data?: any, opts: Record = {}) => { + if (FCL_REGISTRY[addr]) send(addr, tag, data, opts) + }, + broadcast: (tag: string, data: any, opts: Record = {}) => { + opts.from = addr + for (const to of FCL_REGISTRY[addr].subs) send(to, tag, data, opts) + }, + subscribe: (sub?: string | null) => + sub != null && FCL_REGISTRY[addr].subs.add(sub), + unsubscribe: (sub?: string | null) => + sub != null && FCL_REGISTRY[addr].subs.delete(sub), + subscriberCount: () => FCL_REGISTRY[addr].subs.size, + hasSubs: () => !!FCL_REGISTRY[addr].subs.size, + put: (key: string, value: T) => { + if (key != null) FCL_REGISTRY[addr].kvs[key] = value + }, + get: (key: string, fallback: T | undefined = undefined) => { + const value = FCL_REGISTRY[addr].kvs[key] + return value == null ? fallback : value + }, + delete: (key: string) => { + delete FCL_REGISTRY[addr].kvs[key] + }, + update: (key: string, fn: (x: T) => U) => { + if (key != null) + FCL_REGISTRY[addr].kvs[key] = fn(FCL_REGISTRY[addr].kvs[key]) + }, + keys: () => { + return Object.keys(FCL_REGISTRY[addr].kvs) + }, + all: () => { + return FCL_REGISTRY[addr].kvs + }, + where: (pattern: RegExp) => { + return Object.keys(FCL_REGISTRY[addr].kvs).reduce((acc, key) => { + return pattern.test(key) + ? {...acc, [key]: FCL_REGISTRY[addr].kvs[key]} + : acc + }, {}) + }, + merge: (data: Record = {}) => { + Object.keys(data).forEach(key => (FCL_REGISTRY[addr].kvs[key] = data[key])) + }, + fatalError: (error: Error) => { + FCL_REGISTRY[addr].error = error + for (const to of FCL_REGISTRY[addr].subs) send(to, UPDATED) + }, +}) + // Returns an unsubscribe function // A SUBSCRIBE handler will need to be created to handle the subscription event // @@ -219,10 +266,13 @@ export const spawn = (fn, rawAddr: number | null = null) => { // ctx.send(letter.from, UPDATED, ctx.all()) // } // -export function subscriber(address, spawnFn, callback) { +export function subscriber( + address: string, + spawnFn: SpawnFn, + callback: (data: T | null, error: Error | null) => void +) { spawnFn(address) - const EXIT = "@EXIT" - const self = spawn(async ctx => { + const self = spawn(async (ctx: ActorContext) => { ctx.send(address, SUBSCRIBE) while (1) { const letter = await ctx.receive() @@ -250,7 +300,13 @@ export function subscriber(address, spawnFn, callback) { // letter.reply(ctx.all()) // } // -export function snapshoter(address, spawnFn) { +export function snapshoter( + address: string, + spawnFn: SpawnFn +) { spawnFn(address) - return send(address, SNAPSHOT, null, {expectReply: true, timeout: 0}) + return send(address, SNAPSHOT, null, { + expectReply: true, + timeout: 0, + }) } diff --git a/packages/util-actor/src/mailbox/index.test.ts b/packages/util-actor/src/mailbox/index.test.ts index 4d5a84c6a..cc85aa2dd 100644 --- a/packages/util-actor/src/mailbox/index.test.ts +++ b/packages/util-actor/src/mailbox/index.test.ts @@ -9,8 +9,8 @@ test("send and receive", async () => { test("first in -- first out", async () => { const m = genMailbox() const msgx = ["A", "B", "C", "D", "E", "F"] - for (let msg of msgx) m.deliver(msg) - for (let msg of msgx) expect(await m.receive()).toBe(msg) + for (const msg of msgx) m.deliver(msg) + for (const msg of msgx) expect(await m.receive()).toBe(msg) }) test("many mailboxes", async () => { @@ -24,13 +24,13 @@ test("many mailboxes", async () => { const m3x = ["X", "Y", "Z"] const m4x = ["7", "8", "9"] - for (let msg of m1x) m1.deliver(msg) - for (let msg of m2x) m2.deliver(msg) - for (let msg of m3x) m3.deliver(msg) - for (let msg of m4x) m4.deliver(msg) + for (const msg of m1x) m1.deliver(msg) + for (const msg of m2x) m2.deliver(msg) + for (const msg of m3x) m3.deliver(msg) + for (const msg of m4x) m4.deliver(msg) - for (let msg of m1x) expect(await m1.receive()).toBe(msg) - for (let msg of m2x) expect(await m2.receive()).toBe(msg) - for (let msg of m3x) expect(await m3.receive()).toBe(msg) - for (let msg of m4x) expect(await m4.receive()).toBe(msg) + for (const msg of m1x) expect(await m1.receive()).toBe(msg) + for (const msg of m2x) expect(await m2.receive()).toBe(msg) + for (const msg of m3x) expect(await m3.receive()).toBe(msg) + for (const msg of m4x) expect(await m4.receive()).toBe(msg) }) diff --git a/packages/util-actor/src/mailbox/index.ts b/packages/util-actor/src/mailbox/index.ts index 83714d3ea..4d9d4b715 100644 --- a/packages/util-actor/src/mailbox/index.ts +++ b/packages/util-actor/src/mailbox/index.ts @@ -1,22 +1,22 @@ -export interface IMailbox { - deliver(msg: any): Promise; - receive(): Promise; +export interface IMailbox { + deliver(msg: T): Promise + receive(): Promise } -export const mailbox = () => { - const queue: any[] = [] - var next +export const mailbox = (): IMailbox => { + const queue: T[] = [] + let next: ((msg: T) => void) | undefined return { - async deliver(msg) { + async deliver(msg: T) { queue.push(msg) if (next) { - next(queue.shift()) + next(queue.shift() as T) next = undefined } }, - receive() { - return new Promise(function innerReceive(resolve) { + receive(): Promise { + return new Promise(function innerReceive(resolve) { const msg = queue.shift() if (msg) return resolve(msg) next = resolve diff --git a/packages/util-actor/tsconfig.json b/packages/util-actor/tsconfig.json index e8262cfd4..ac6917898 100644 --- a/packages/util-actor/tsconfig.json +++ b/packages/util-actor/tsconfig.json @@ -6,7 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", - "strict": false + "outDir": "types" } } From 9554e0bea5329c1223e2a1640d2e788087a3282d Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 8 Sep 2023 09:52:26 -0700 Subject: [PATCH 05/45] PKG -- [types] Simplify generics for @onflow/types (#1772) * PKG -- [types] Simplify generics * Fix array * Fix Array --- packages/types/.eslintrc.json | 5 +- packages/types/src/types.test.ts | 8 ++- packages/types/src/types.ts | 105 +++++++++++++++++-------------- 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/packages/types/.eslintrc.json b/packages/types/.eslintrc.json index 712568225..c9e88a7fc 100644 --- a/packages/types/.eslintrc.json +++ b/packages/types/.eslintrc.json @@ -27,5 +27,8 @@ "jsdoc/require-jsdoc": 0 } } - ] + ], + "rules": { + "@typescript-eslint/no-explicit-any": 0 + } } diff --git a/packages/types/src/types.test.ts b/packages/types/src/types.test.ts index efabee647..3e725adb6 100644 --- a/packages/types/src/types.test.ts +++ b/packages/types/src/types.test.ts @@ -229,7 +229,13 @@ function registerTest([ asArgument, asInjection, shouldError = false, -]: readonly [t.TypeDescriptor, X, t.JsonCdc, X, boolean?]) { +]: readonly [ + t.TypeDescriptor>, + X, + t.JsonCdc, + X, + boolean? +]) { describe(cast.label, () => { test(`t.${cast.label}.asArgument(${input})`, () => { if (shouldError) { diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index 17cbf4b92..cc392f607 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -5,6 +5,23 @@ export type JsonCdc = { value: T } +type JsonCdcLabel> = X extends JsonCdc< + infer L, + unknown +> + ? L + : never + +export interface TypeDescriptor> { + label: JsonCdcLabel + asArgument: (x: T) => V + asInjection: (x: T) => T +} + +type TypeDescriptorInput< + X extends TypeDescriptor> +> = X extends TypeDescriptor> ? T : never + export interface PathValue { domain: "storage" | "private" | "public" identifier: string @@ -15,12 +32,6 @@ export interface ReferenceValue { address: string } -export interface TypeDescriptor { - label: L - asArgument: (x: T) => JsonCdc - asInjection: (x: T) => T -} - /** * Creates a type descriptor for a given type * @param label - The label for the type @@ -29,11 +40,11 @@ export interface TypeDescriptor { * @returns A type descriptor * @internal */ -const typedef = ( - label: L, - asArgument: (x: T) => JsonCdc, +const typedef = >( + label: JsonCdcLabel, + asArgument: (x: T) => V, asInjection: (x: T) => T -): TypeDescriptor => ({ +): TypeDescriptor => ({ label, asArgument, asInjection: (x: T) => { @@ -606,19 +617,21 @@ export const Void = typedef( if (!v || isNull(v)) return { type: "Void", - value: null, // so that it confroms to JsonCdcType interface + value: null, } return throwTypeError("Expected Void for type Void") }, v => v ) -export const Optional = ( - children: TypeDescriptor +export const Optional = < + T extends TypeDescriptor> +>( + children: T ) => typedef( "Optional", - (v?: T | null) => ({ + (v?: TypeDescriptorInput | null) => ({ type: "Optional", value: isNull(v) ? null : children.asArgument(v), }), @@ -638,12 +651,12 @@ export const Reference = typedef( v => v ) -export const _Array = ( - children: TypeDescriptor[] | TypeDescriptor = [] +export const _Array = >>( + children: T[] | T = [] ) => typedef( "Array", - (v: T[]) => { + (v: TypeDescriptorInput[]) => { return { type: "Array", value: isArray(children) @@ -656,21 +669,27 @@ export const _Array = ( export {_Array as Array} -// TODO : Fix types. Think about cases... dont think children should ever be array... not sure -export const Dictionary = ( +export const Dictionary = < + K extends TypeDescriptor>, + V extends TypeDescriptor> +>( children: | { - key: TypeDescriptor - value: TypeDescriptor + key: K + value: V }[] | { - key: TypeDescriptor - value: TypeDescriptor + key: K + value: V } = [] ) => typedef( "Dictionary", - (v: {key: A; value: D}[] | {key: A; value: D}) => { + ( + v: + | {key: TypeDescriptorInput; value: TypeDescriptorInput}[] + | {key: TypeDescriptorInput; value: TypeDescriptorInput} + ) => { const vIsArray = isArray(v) const childrenIsArray = isArray(children) @@ -695,24 +714,20 @@ export const Dictionary = ( value: children.value.asArgument(v.value), }, ] - : throwTypeError( - "Invalid arguments for Dictionary. Expected an of array of key/value pairs" - ), + : throwTypeError("Invalid arguments for Dictionary."), } return throwTypeError("Expected Object for type Dictionary") }, v => v ) -export const Event = ( +export const Event = >>( id: string, - fields: - | {value: TypeDescriptor}[] - | {value: TypeDescriptor} = [] + fields: {value: V}[] | {value: V} = [] ) => typedef( "Event", - (v: {fields: {name: string; value: T}[]}) => { + (v: {fields: {name: string; value: TypeDescriptorInput}[]}) => { if (isObj(v)) return { type: "Event", @@ -734,15 +749,15 @@ export const Event = ( v => v ) -export const Resource = ( +export const Resource = < + V extends TypeDescriptor> +>( id: string, - fields: - | {value: TypeDescriptor}[] - | {value: TypeDescriptor} = [] + fields: {value: V}[] | {value: V} = [] ) => typedef( "Resource", - (v: {fields: {name: string; value: T}[]}) => { + (v: {fields: {name: string; value: TypeDescriptorInput}[]}) => { if (isObj(v)) return { type: "Resource", @@ -764,15 +779,13 @@ export const Resource = ( v => v ) -export const Struct = ( +export const Struct = >>( id: string, - fields: - | {value: TypeDescriptor}[] - | {value: TypeDescriptor} = [] + fields: {value: V}[] | {value: V} = [] ) => typedef( "Struct", - (v: {fields: {name: string; value: T}[]}) => { + (v: {fields: {name: string; value: TypeDescriptorInput}[]}) => { if (isObj(v)) return { type: "Struct", @@ -794,15 +807,13 @@ export const Struct = ( v => v ) -export const Enum = ( +export const Enum = >>( id: string, - fields: - | {value: TypeDescriptor}[] - | {value: TypeDescriptor} = [] + fields: {value: V}[] | {value: V} = [] ) => typedef( "Enum", - (v: {fields: {name: string; value: T}[]}) => { + (v: {fields: {name: string; value: TypeDescriptorInput}[]}) => { if (isObj(v)) return { type: "Enum", From 6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 12 Sep 2023 11:57:41 -0700 Subject: [PATCH 06/45] PKG -- [config] Convert @onflow/config to TS (#1731) * PKG -- [config] Add TypeScript * Changeset * fixup * Remove unnecessary generic from util-actor * remove non null assertions --------- Co-authored-by: Alex <12097569+nialexsan@users.noreply.github.com> --- .changeset/tough-fishes-live.md | 5 + package-lock.json | 506 ++++++++++-------- packages/config/.babelrc | 6 +- packages/config/.eslintrc.json | 18 +- packages/config/package.json | 16 +- .../src/{config.test.js => config.test.ts} | 16 +- packages/config/src/{config.js => config.ts} | 137 ++--- .../utils.test.js => src/utils/utils.test.ts} | 10 +- packages/config/src/utils/utils.ts | 222 ++++++++ packages/config/utils/utils.js | 171 ------ packages/util-actor/src/index.ts | 22 +- 11 files changed, 641 insertions(+), 488 deletions(-) create mode 100644 .changeset/tough-fishes-live.md rename packages/config/src/{config.test.js => config.test.ts} (95%) rename packages/config/src/{config.js => config.ts} (67%) rename packages/config/{utils/utils.test.js => src/utils/utils.test.ts} (96%) create mode 100644 packages/config/src/utils/utils.ts delete mode 100644 packages/config/utils/utils.js diff --git a/.changeset/tough-fishes-live.md b/.changeset/tough-fishes-live.md new file mode 100644 index 000000000..02a1a5d22 --- /dev/null +++ b/.changeset/tough-fishes-live.md @@ -0,0 +1,5 @@ +--- +"@onflow/config": minor +--- + +Add Typescript to @onflow/config diff --git a/package-lock.json b/package-lock.json index c15779aef..4084e6826 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -173,13 +174,14 @@ "license": "ISC" }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.22.9", - "license": "MIT", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.15.tgz", + "integrity": "sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg==", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-function-name": "^7.22.5", - "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.15", "@babel/helper-optimise-call-expression": "^7.22.5", "@babel/helper-replace-supers": "^7.22.9", "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", @@ -237,8 +239,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "license": "MIT", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "engines": { "node": ">=6.9.0" } @@ -275,40 +278,43 @@ } }, "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.22.5", - "license": "MIT", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz", + "integrity": "sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA==", "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-imports": { - "version": "7.22.5", - "license": "MIT", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz", + "integrity": "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==", "dependencies": { - "@babel/types": "^7.22.5" + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.5", - "license": "MIT", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.23.0.tgz", + "integrity": "sha512-WhDWw1tdrlT0gMgUJSlX0IQvoO1eN279zrAUbVB+KpV2c3Tylz8+GnKOLllCS6Z/iZQEyVYxhZVUdPTqs2YYPw==", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-module-imports": "^7.22.15", "@babel/helper-simple-access": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.20" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-optimise-call-expression": { @@ -397,15 +403,17 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "license": "MIT", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.22.5", - "license": "MIT", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz", + "integrity": "sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==", "engines": { "node": ">=6.9.0" } @@ -1133,10 +1141,11 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.22.5", - "license": "MIT", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.0.tgz", + "integrity": "sha512-32Xzss14/UVc7k9g775yMIvkVK8xwKE0DPdP5JTapr3+Z9w4tzeOuLNY6BXDQR6BdnzIlXnCGAzsk/ICHBLVWQ==", "dependencies": { - "@babel/helper-module-transforms": "^7.22.5", + "@babel/helper-module-transforms": "^7.23.0", "@babel/helper-plugin-utils": "^7.22.5", "@babel/helper-simple-access": "^7.22.5" }, @@ -1363,11 +1372,12 @@ } }, "node_modules/@babel/plugin-transform-typescript": { - "version": "7.22.9", - "license": "MIT", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.15.tgz", + "integrity": "sha512-1uirS0TnijxvQLnlv5wQBwOX3E1wCFX7ITv+9pBV2wKEk4K+M5tqDaoNXnTH8tjEIYHLO98MwiTWO04Ggz4XuA==", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", - "@babel/helper-create-class-features-plugin": "^7.22.9", + "@babel/helper-create-class-features-plugin": "^7.22.15", "@babel/helper-plugin-utils": "^7.22.5", "@babel/plugin-syntax-typescript": "^7.22.5" }, @@ -1514,14 +1524,15 @@ } }, "node_modules/@babel/preset-typescript": { - "version": "7.22.5", - "license": "MIT", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.23.2.tgz", + "integrity": "sha512-u4UJc1XsS1GhIGteM8rnGiIvf9rJpiVgMEeCnwlLA7WJPC+jcXWJAGxYmeqs5hOZD8BbAfnV5ezBOxQbb4OUxA==", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5", - "@babel/helper-validator-option": "^7.22.5", + "@babel/helper-validator-option": "^7.22.15", "@babel/plugin-syntax-jsx": "^7.22.5", - "@babel/plugin-transform-modules-commonjs": "^7.22.5", - "@babel/plugin-transform-typescript": "^7.22.5" + "@babel/plugin-transform-modules-commonjs": "^7.23.0", + "@babel/plugin-transform-typescript": "^7.22.15" }, "engines": { "node": ">=6.9.0" @@ -1583,11 +1594,12 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", - "license": "MIT", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -1964,6 +1976,7 @@ }, "node_modules/@es-joy/jsdoccomment": { "version": "0.36.1", + "dev": true, "license": "MIT", "dependencies": { "comment-parser": "1.3.1", @@ -1976,6 +1989,7 @@ }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", + "dev": true, "license": "MIT", "dependencies": { "eslint-visitor-keys": "^3.3.0" @@ -1989,6 +2003,7 @@ }, "node_modules/@eslint-community/regexpp": { "version": "4.6.2", + "dev": true, "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -1996,6 +2011,7 @@ }, "node_modules/@eslint/eslintrc": { "version": "2.1.2", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.12.4", @@ -2017,10 +2033,12 @@ }, "node_modules/@eslint/eslintrc/node_modules/argparse": { "version": "2.0.1", + "dev": true, "license": "Python-2.0" }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -2030,8 +2048,10 @@ } }, "node_modules/@eslint/js": { - "version": "8.47.0", - "license": "MIT", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", + "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -2042,10 +2062,12 @@ "license": "MIT" }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.10", - "license": "Apache-2.0", + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", + "@humanwhocodes/object-schema": "^2.0.1", "debug": "^4.1.1", "minimatch": "^3.0.5" }, @@ -2055,6 +2077,7 @@ }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=12.22" @@ -2065,8 +2088,10 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "license": "BSD-3-Clause" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "dev": true }, "node_modules/@hutson/parse-repository-url": { "version": "3.0.2", @@ -3713,6 +3738,7 @@ }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", @@ -3724,6 +3750,7 @@ }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -3731,6 +3758,7 @@ }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", @@ -5194,9 +5222,10 @@ } }, "node_modules/@types/jest": { - "version": "29.5.3", + "version": "29.5.7", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", + "integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", "dev": true, - "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" @@ -5285,9 +5314,8 @@ }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", - "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.5.1", "@typescript-eslint/scope-manager": "6.9.1", @@ -5320,9 +5348,8 @@ }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -5332,9 +5359,8 @@ }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5347,9 +5373,8 @@ }, "node_modules/@typescript-eslint/parser": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", - "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "@typescript-eslint/scope-manager": "6.9.1", "@typescript-eslint/types": "6.9.1", @@ -5375,9 +5400,8 @@ }, "node_modules/@typescript-eslint/scope-manager": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", - "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/types": "6.9.1", "@typescript-eslint/visitor-keys": "6.9.1" @@ -5392,9 +5416,8 @@ }, "node_modules/@typescript-eslint/type-utils": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", - "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/typescript-estree": "6.9.1", "@typescript-eslint/utils": "6.9.1", @@ -5419,9 +5442,8 @@ }, "node_modules/@typescript-eslint/types": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", - "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true, + "license": "MIT", "engines": { "node": "^16.0.0 || >=18.0.0" }, @@ -5432,9 +5454,8 @@ }, "node_modules/@typescript-eslint/typescript-estree": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", - "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "@typescript-eslint/types": "6.9.1", "@typescript-eslint/visitor-keys": "6.9.1", @@ -5459,9 +5480,8 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -5471,9 +5491,8 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5486,9 +5505,8 @@ }, "node_modules/@typescript-eslint/utils": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", - "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", @@ -5511,9 +5529,8 @@ }, "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -5523,9 +5540,8 @@ }, "node_modules/@typescript-eslint/utils/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5538,9 +5554,8 @@ }, "node_modules/@typescript-eslint/visitor-keys": { "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", - "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, + "license": "MIT", "dependencies": { "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" @@ -5553,6 +5568,12 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@walletconnect/core": { "version": "2.8.1", "license": "Apache-2.0", @@ -6092,6 +6113,7 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", + "dev": true, "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" @@ -6148,6 +6170,7 @@ }, "node_modules/ajv": { "version": "6.12.6", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -6700,6 +6723,7 @@ }, "node_modules/brace-expansion": { "version": "1.1.11", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -6902,6 +6926,7 @@ }, "node_modules/callsites": { "version": "3.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -7162,6 +7187,7 @@ }, "node_modules/comment-parser": { "version": "1.3.1", + "dev": true, "license": "MIT", "engines": { "node": ">= 12.0.0" @@ -7198,6 +7224,7 @@ }, "node_modules/concat-map": { "version": "0.0.1", + "dev": true, "license": "MIT" }, "node_modules/concat-stream": { @@ -7919,6 +7946,7 @@ }, "node_modules/cross-spawn": { "version": "7.0.3", + "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -8118,6 +8146,7 @@ }, "node_modules/deep-is": { "version": "0.1.4", + "dev": true, "license": "MIT" }, "node_modules/deepmerge": { @@ -8257,6 +8286,7 @@ }, "node_modules/doctrine": { "version": "3.0.0", + "dev": true, "license": "Apache-2.0", "dependencies": { "esutils": "^2.0.2" @@ -8618,16 +8648,19 @@ } }, "node_modules/eslint": { - "version": "8.47.0", - "license": "MIT", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", + "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "dev": true, "dependencies": { "@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", + "@eslint/js": "8.52.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -8727,6 +8760,7 @@ }, "node_modules/eslint-scope": { "version": "7.2.2", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", @@ -8741,6 +8775,7 @@ }, "node_modules/eslint-visitor-keys": { "version": "3.4.3", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -8751,6 +8786,7 @@ }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -8764,10 +8800,12 @@ }, "node_modules/eslint/node_modules/argparse": { "version": "2.0.1", + "dev": true, "license": "Python-2.0" }, "node_modules/eslint/node_modules/chalk": { "version": "4.1.2", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", @@ -8782,6 +8820,7 @@ }, "node_modules/eslint/node_modules/color-convert": { "version": "2.0.1", + "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -8792,10 +8831,12 @@ }, "node_modules/eslint/node_modules/color-name": { "version": "1.1.4", + "dev": true, "license": "MIT" }, "node_modules/eslint/node_modules/escape-string-regexp": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -8806,6 +8847,7 @@ }, "node_modules/eslint/node_modules/find-up": { "version": "5.0.0", + "dev": true, "license": "MIT", "dependencies": { "locate-path": "^6.0.0", @@ -8820,6 +8862,7 @@ }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.3" @@ -8830,6 +8873,7 @@ }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -8837,6 +8881,7 @@ }, "node_modules/eslint/node_modules/js-yaml": { "version": "4.1.0", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -8847,6 +8892,7 @@ }, "node_modules/eslint/node_modules/locate-path": { "version": "6.0.0", + "dev": true, "license": "MIT", "dependencies": { "p-locate": "^5.0.0" @@ -8860,6 +8906,7 @@ }, "node_modules/eslint/node_modules/p-limit": { "version": "3.1.0", + "dev": true, "license": "MIT", "dependencies": { "yocto-queue": "^0.1.0" @@ -8873,6 +8920,7 @@ }, "node_modules/eslint/node_modules/p-locate": { "version": "5.0.0", + "dev": true, "license": "MIT", "dependencies": { "p-limit": "^3.0.2" @@ -8886,6 +8934,7 @@ }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -8896,6 +8945,7 @@ }, "node_modules/espree": { "version": "9.6.1", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "acorn": "^8.9.0", @@ -8923,6 +8973,7 @@ }, "node_modules/esquery": { "version": "1.5.0", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "estraverse": "^5.1.0" @@ -8933,6 +8984,7 @@ }, "node_modules/esrecurse": { "version": "4.3.0", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "estraverse": "^5.2.0" @@ -8943,6 +8995,7 @@ }, "node_modules/estraverse": { "version": "5.3.0", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=4.0" @@ -9055,6 +9108,7 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", + "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -9074,10 +9128,12 @@ }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", + "dev": true, "license": "MIT" }, "node_modules/fast-redact": { @@ -9097,6 +9153,7 @@ }, "node_modules/fastq": { "version": "1.15.0", + "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -9126,6 +9183,7 @@ }, "node_modules/file-entry-cache": { "version": "6.0.1", + "dev": true, "license": "MIT", "dependencies": { "flat-cache": "^3.0.4" @@ -9194,8 +9252,7 @@ }, "node_modules/find-cache-dir": { "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "license": "MIT", "dependencies": { "commondir": "^1.0.1", "make-dir": "^3.0.2", @@ -9238,6 +9295,7 @@ }, "node_modules/flat-cache": { "version": "3.0.4", + "dev": true, "license": "MIT", "dependencies": { "flatted": "^3.1.0", @@ -9249,6 +9307,7 @@ }, "node_modules/flatted": { "version": "3.2.7", + "dev": true, "license": "ISC" }, "node_modules/follow-redirects": { @@ -10017,6 +10076,7 @@ }, "node_modules/globals": { "version": "13.21.0", + "dev": true, "license": "MIT", "dependencies": { "type-fest": "^0.20.2" @@ -10087,6 +10147,7 @@ }, "node_modules/graphemer": { "version": "1.4.0", + "dev": true, "license": "MIT" }, "node_modules/growly": { @@ -10331,6 +10392,7 @@ }, "node_modules/ignore": { "version": "5.2.4", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -10368,6 +10430,7 @@ }, "node_modules/import-fresh": { "version": "3.3.0", + "dev": true, "license": "MIT", "dependencies": { "parent-module": "^1.0.0", @@ -10382,6 +10445,7 @@ }, "node_modules/import-fresh/node_modules/resolve-from": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -10407,6 +10471,7 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.19" @@ -10743,6 +10808,7 @@ }, "node_modules/is-extglob": { "version": "2.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -10765,6 +10831,7 @@ }, "node_modules/is-glob": { "version": "4.0.3", + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -10841,6 +10908,7 @@ }, "node_modules/is-path-inside": { "version": "3.0.3", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -11035,6 +11103,7 @@ }, "node_modules/isexe": { "version": "2.0.0", + "dev": true, "license": "ISC" }, "node_modules/isobject": { @@ -12806,6 +12875,7 @@ }, "node_modules/jsdoc-type-pratt-parser": { "version": "3.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=12.0.0" @@ -12897,10 +12967,12 @@ }, "node_modules/json-schema-traverse": { "version": "0.4.1", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", + "dev": true, "license": "MIT" }, "node_modules/json-stringify-nice": { @@ -13423,6 +13495,7 @@ }, "node_modules/levn": { "version": "0.4.1", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1", @@ -13882,6 +13955,7 @@ }, "node_modules/lodash.merge": { "version": "4.6.2", + "dev": true, "license": "MIT" }, "node_modules/lodash.startcase": { @@ -14267,6 +14341,7 @@ }, "node_modules/minimatch": { "version": "3.1.2", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -14554,6 +14629,7 @@ }, "node_modules/natural-compare": { "version": "1.4.0", + "dev": true, "license": "MIT" }, "node_modules/negotiator": { @@ -15581,6 +15657,7 @@ }, "node_modules/optionator": { "version": "0.9.3", + "dev": true, "license": "MIT", "dependencies": { "@aashutoshrathi/word-wrap": "^1.2.3", @@ -16036,6 +16113,7 @@ }, "node_modules/parent-module": { "version": "1.0.1", + "dev": true, "license": "MIT", "dependencies": { "callsites": "^3.0.0" @@ -16132,6 +16210,7 @@ }, "node_modules/path-is-absolute": { "version": "1.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -16139,6 +16218,7 @@ }, "node_modules/path-key": { "version": "3.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -16371,6 +16451,7 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8.0" @@ -16532,6 +16613,7 @@ }, "node_modules/punycode": { "version": "2.3.0", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -17181,6 +17263,7 @@ }, "node_modules/reusify": { "version": "1.0.4", + "dev": true, "license": "MIT", "engines": { "iojs": ">=1.0.0", @@ -17189,6 +17272,7 @@ }, "node_modules/rimraf": { "version": "3.0.2", + "dev": true, "license": "ISC", "dependencies": { "glob": "^7.1.3" @@ -17202,6 +17286,7 @@ }, "node_modules/rimraf/node_modules/glob": { "version": "7.2.3", + "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", @@ -17233,8 +17318,7 @@ }, "node_modules/rollup-plugin-typescript2": { "version": "0.35.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.35.0.tgz", - "integrity": "sha512-szcIO9hPUx3PhQl91u4pfNAH2EKbtrXaES+m163xQVE5O1CC0ea6YZV/5woiDDW3CR9jF2CszPrKN+AFiND0bg==", + "license": "MIT", "dependencies": { "@rollup/pluginutils": "^4.1.2", "find-cache-dir": "^3.3.2", @@ -17249,8 +17333,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", - "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "license": "MIT", "dependencies": { "estree-walker": "^2.0.1", "picomatch": "^2.2.2" @@ -17261,8 +17344,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/fs-extra": { "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -17274,8 +17356,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/jsonfile": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "license": "MIT", "dependencies": { "universalify": "^2.0.0" }, @@ -17285,8 +17366,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -17296,8 +17376,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -17310,8 +17389,7 @@ }, "node_modules/rollup-plugin-typescript2/node_modules/universalify": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "license": "MIT", "engines": { "node": ">= 10.0.0" } @@ -17326,6 +17404,7 @@ }, "node_modules/run-parallel": { "version": "1.2.0", + "dev": true, "funding": [ { "type": "github", @@ -17450,6 +17529,7 @@ }, "node_modules/shebang-command": { "version": "2.0.0", + "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -17460,6 +17540,7 @@ }, "node_modules/shebang-regex": { "version": "3.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -17818,10 +17899,12 @@ }, "node_modules/spdx-exceptions": { "version": "2.3.0", + "dev": true, "license": "CC-BY-3.0" }, "node_modules/spdx-expression-parse": { "version": "3.0.1", + "dev": true, "license": "MIT", "dependencies": { "spdx-exceptions": "^2.1.0", @@ -17830,6 +17913,7 @@ }, "node_modules/spdx-license-ids": { "version": "3.0.12", + "dev": true, "license": "CC0-1.0" }, "node_modules/split": { @@ -18045,6 +18129,7 @@ }, "node_modules/strip-json-comments": { "version": "3.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -18261,6 +18346,7 @@ }, "node_modules/text-table": { "version": "0.2.0", + "dev": true, "license": "MIT" }, "node_modules/thread-stream": { @@ -18368,9 +18454,8 @@ }, "node_modules/ts-api-utils": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", - "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", "dev": true, + "license": "MIT", "engines": { "node": ">=16.13.0" }, @@ -18699,6 +18784,7 @@ }, "node_modules/type-check": { "version": "0.4.0", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1" @@ -18717,6 +18803,7 @@ }, "node_modules/type-fest": { "version": "0.20.2", + "dev": true, "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" @@ -18901,6 +18988,7 @@ }, "node_modules/uri-js": { "version": "4.4.1", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" @@ -19107,6 +19195,7 @@ }, "node_modules/which": { "version": "2.0.2", + "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -19475,6 +19564,7 @@ }, "node_modules/yocto-queue": { "version": "0.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -19490,18 +19580,50 @@ "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/util-actor": "^1.2.0", + "@onflow/util-invariant": "^1.1.0", + "@onflow/util-logger": "^1.2.2", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.11", "@onflow/fcl-bundle": "^1.3.1", "@types/estree": "^1.0.1", + "@types/jest": "^29.5.4", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "eslint-plugin-jsdoc": "^46.5.1", "jest": "^29.5.0", "typescript": "^4.9.5" } }, + "packages/config/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/config/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, "packages/config/node_modules/escape-string-regexp": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -19511,27 +19633,42 @@ } }, "packages/config/node_modules/eslint-plugin-jsdoc": { - "version": "40.0.1", - "license": "BSD-3-Clause", + "version": "46.8.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", + "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", + "dev": true, "dependencies": { - "@es-joy/jsdoccomment": "~0.36.1", - "comment-parser": "1.3.1", + "@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.4.0", - "semver": "^7.3.8", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", "spdx-expression-parse": "^3.0.1" }, "engines": { - "node": "^14 || ^16 || ^17 || ^18 || ^19" + "node": ">=16" }, "peerDependencies": { "eslint": "^7.0.0 || ^8.0.0" } }, + "packages/config/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "packages/config/node_modules/lru-cache": { "version": "6.0.0", - "license": "ISC", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -19540,8 +19677,10 @@ } }, "packages/config/node_modules/semver": { - "version": "7.3.8", - "license": "ISC", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -20228,9 +20367,8 @@ }, "packages/rlp/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -20242,18 +20380,16 @@ }, "packages/rlp/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/rlp/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -20263,9 +20399,8 @@ }, "packages/rlp/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -20286,18 +20421,16 @@ }, "packages/rlp/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/rlp/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -20307,9 +20440,8 @@ }, "packages/rlp/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -20539,9 +20671,8 @@ }, "packages/types/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -20553,8 +20684,7 @@ }, "packages/types/node_modules/@onflow/util-logger": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@onflow/util-logger/-/util-logger-1.3.0.tgz", - "integrity": "sha512-MIDRS0Nv5mNV631S3VGU7d+v/+/Aw/69eN5HOLzJ5O5vG/0ETWwARgOSQVCOjtzztpX/FYrOwe24Mpu3qtXTyg==", + "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, @@ -20569,18 +20699,16 @@ }, "packages/types/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/types/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -20590,9 +20718,8 @@ }, "packages/types/node_modules/eslint-plugin-jsdoc": { "version": "46.4.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", - "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -20613,18 +20740,16 @@ }, "packages/types/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/types/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -20634,9 +20759,8 @@ }, "packages/types/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -20668,9 +20792,8 @@ }, "packages/util-actor/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -20682,18 +20805,16 @@ }, "packages/util-actor/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/util-actor/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -20703,9 +20824,8 @@ }, "packages/util-actor/node_modules/eslint-plugin-jsdoc": { "version": "46.5.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.5.1.tgz", - "integrity": "sha512-CPbvKprmEuJYoxMj5g8gXfPqUGgcqMM6jpH06Kp4pn5Uy5MrPkFKzoD7UFp2E4RBzfXbJz1+TeuEivwFVMkXBg==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -20726,18 +20846,16 @@ }, "packages/util-actor/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/util-actor/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -20747,9 +20865,8 @@ }, "packages/util-actor/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -21023,9 +21140,8 @@ }, "packages/util-invariant/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -21037,18 +21153,16 @@ }, "packages/util-invariant/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/util-invariant/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -21058,9 +21172,8 @@ }, "packages/util-invariant/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -21081,18 +21194,16 @@ }, "packages/util-invariant/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/util-invariant/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -21102,9 +21213,8 @@ }, "packages/util-invariant/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -21143,9 +21253,8 @@ }, "packages/util-logger/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -21157,18 +21266,16 @@ }, "packages/util-logger/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/util-logger/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -21178,9 +21285,8 @@ }, "packages/util-logger/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -21201,18 +21307,16 @@ }, "packages/util-logger/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/util-logger/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -21222,9 +21326,8 @@ }, "packages/util-logger/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -21268,9 +21371,8 @@ }, "packages/util-template/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -21282,8 +21384,7 @@ }, "packages/util-template/node_modules/@onflow/util-logger": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@onflow/util-logger/-/util-logger-1.3.0.tgz", - "integrity": "sha512-MIDRS0Nv5mNV631S3VGU7d+v/+/Aw/69eN5HOLzJ5O5vG/0ETWwARgOSQVCOjtzztpX/FYrOwe24Mpu3qtXTyg==", + "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, @@ -21298,18 +21399,16 @@ }, "packages/util-template/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/util-template/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -21319,9 +21418,8 @@ }, "packages/util-template/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -21342,18 +21440,16 @@ }, "packages/util-template/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/util-template/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -21363,9 +21459,8 @@ }, "packages/util-template/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -21396,9 +21491,8 @@ }, "packages/util-uid/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -21410,18 +21504,16 @@ }, "packages/util-uid/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } }, "packages/util-uid/node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -21431,9 +21523,8 @@ }, "packages/util-uid/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -21454,18 +21545,16 @@ }, "packages/util-uid/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/util-uid/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -21475,9 +21564,8 @@ }, "packages/util-uid/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, diff --git a/packages/config/.babelrc b/packages/config/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/config/.babelrc +++ b/packages/config/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/config/.eslintrc.json b/packages/config/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/config/.eslintrc.json +++ b/packages/config/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/config/package.json b/packages/config/package.json index 521b0838f..2f9cf9426 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -13,27 +13,35 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.11", "@onflow/fcl-bundle": "^1.3.1", "@types/estree": "^1.0.1", + "@types/jest": "^29.5.4", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "eslint-plugin-jsdoc": "^46.5.1", "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/config.js", + "source": "src/config.ts", "main": "dist/config.js", "module": "dist/config.module.js", "unpkg": "dist/config.umd.js", - "types": "types/src/config.d.ts", + "types": "dist/config.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "tsc && npm run lint && fcl-bundle", + "build": "npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", - "lint": "eslint ." + "lint": "eslint src" }, "dependencies": { "@babel/runtime": "^7.18.6", "@onflow/util-actor": "^1.2.0", + "@onflow/util-invariant": "^1.1.0", + "@onflow/util-logger": "^1.2.2", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" } diff --git a/packages/config/src/config.test.js b/packages/config/src/config.test.ts similarity index 95% rename from packages/config/src/config.test.js rename to packages/config/src/config.test.ts index f385ccfa0..417686cc9 100644 --- a/packages/config/src/config.test.js +++ b/packages/config/src/config.test.ts @@ -1,6 +1,6 @@ import {config, clearConfig} from "./config" -const idle = () => new Promise(resolve => setTimeout(resolve), 0) +const idle = () => new Promise(resolve => setTimeout(resolve, 0)) describe("config()", () => { beforeEach(async () => { @@ -33,7 +33,7 @@ describe("config()", () => { }) test("update", async () => { - config().update("config.test.t", v => v + v) + config().update("config.test.t", (v: number) => v + v) expect(await config().get("config.test.t")).toBe("tt") }) @@ -60,7 +60,7 @@ describe("config()", () => { unsub() await idle() - config().update("config.test.y", v => v + v) + config().update("config.test.y", (v: number) => v + v) await idle() @@ -138,7 +138,7 @@ describe("config()", () => { beforeEach(() => config({A: A, B: B, C: C, D: D})) afterEach(clearConfig) - const examples = [ + const examples: ([any, string[]] | [any])[] = [ [FALLBACK], [A, ["A"]], [FALLBACK, ["B"]], @@ -148,7 +148,7 @@ describe("config()", () => { [FALLBACK, ["MISSING", "B"]], ] - for (let [i, [want, from]] of examples.entries()) { + for (const [i, [want, from]] of examples.entries()) { test(`Example ${i}: ${from} -> ${want}`, async () => { expect(await config.first(from, FALLBACK)).toBe(want) }) @@ -157,9 +157,9 @@ describe("config()", () => { describe("load method", () => { describe("with a set network", () => { - beforeEach(async () => { + beforeEach(() => { // Just picked a random network. Behavior might differ based on network selection at a future date. - await config().put("flow.network", "emulator") + config().put("flow.network", "emulator") }) describe("flow.json v1", () => { @@ -225,7 +225,7 @@ describe("config()", () => { describe("with an array of configs loaded", () => { beforeEach(async () => { - let secondFlowJSON = { + const secondFlowJSON = { accounts: {}, contracts: { ThirdContract: { diff --git a/packages/config/src/config.js b/packages/config/src/config.ts similarity index 67% rename from packages/config/src/config.js rename to packages/config/src/config.ts index f294a6a8a..1711c0b6d 100644 --- a/packages/config/src/config.js +++ b/packages/config/src/config.ts @@ -4,10 +4,11 @@ import { subscriber, SUBSCRIBE, UNSUBSCRIBE, + ActorHandlers, } from "@onflow/util-actor" import * as logger from "@onflow/util-logger" import {invariant} from "@onflow/util-invariant" -import {getContracts, cleanNetwork, anyHasPrivateKeys} from "../utils/utils" +import {getContracts, cleanNetwork, anyHasPrivateKeys} from "./utils/utils" // Inject config into logger to break circular dependency logger.setConfig(config) @@ -22,9 +23,9 @@ const CLEAR = "CLEAR_CONFIG" const WHERE = "WHERE_CONFIG" const UPDATED = "CONFIG/UPDATED" -const identity = v => v +const identity = (v: T) => v -const HANDLERS = { +const HANDLERS: ActorHandlers = { [PUT]: (ctx, _letter, {key, value}) => { if (key == null) throw new Error("Missing 'key' for config/put.") ctx.put(key, value) @@ -47,9 +48,9 @@ const HANDLERS = { ctx.delete(key) ctx.broadcast(UPDATED, {...ctx.all()}) }, - [CLEAR]: (ctx, letter) => { - let keys = Object.keys(ctx.all()) - for (let key of keys) ctx.delete(key) + [CLEAR]: ctx => { + const keys = Object.keys(ctx.all()) + for (const key of keys) ctx.delete(key) ctx.broadcast(UPDATED, {...ctx.all()}) }, [WHERE]: (ctx, letter, {pattern}) => { @@ -69,117 +70,123 @@ spawn(HANDLERS, NAME) /** * @description Adds a key-value pair to the config - * @param {string} key - The key to add - * @param {*} value - The value to add - * @returns {Promise} - The current config + * @param key - The key to add + * @param value - The value to add + * @returns The config object */ -function put(key, value) { +function put(key: string, value: T) { send(NAME, PUT, {key, value}) return config() } /** * @description Gets a key-value pair with a fallback from the config - * @param {string} key - The key to add - * @param {*} [fallback] - The fallback value to return if key is not found - * @returns {Promise<*>} - The value found at key or fallback + * @param key - The key to add + * @param fallback - The fallback value to return if key is not found + * @returns The value found at key or fallback */ -function get(key, fallback) { +function get(key: string, fallback?: T): Promise { return send(NAME, GET, {key, fallback}, {expectReply: true, timeout: 10}) } /** * @description Returns the first non null config value or the fallback - * @param {string[]} wants - The keys to search for - * @param {*} fallback - The fallback value to return if key is not found - * @returns {Promise<*>} - The value found at key or fallback + * @param wants - The keys to search for + * @param fallback - The fallback value to return if key is not found + * @returns The value found at key or fallback */ -async function first(wants = [], fallback) { +async function first(wants: string[] = [], fallback: T): Promise { if (!wants.length) return fallback const [head, ...rest] = wants - const ret = await get(head) + const ret = await get(head) if (ret == null) return first(rest, fallback) return ret } /** * @description Returns the current config - * @returns {Promise} - The current config + * @returns The config object */ -function all() { +function all(): Promise> { return send(NAME, GET_ALL, null, {expectReply: true, timeout: 10}) } /** * @description Updates a key-value pair in the config - * @param {string} key - The key to update - * @param {Function} fn - The function to update the value with - * @returns {Promise} - The current config + * @param key - The key to update + * @param fn - The function to update the value with + * @returns The config object */ -function update(key, fn = identity) { +function update(key: string, fn: (x: T) => T = identity) { send(NAME, UPDATE, {key, fn}) return config() } /** * @description Deletes a key-value pair from the config - * @param {string} key - The key to delete - * @returns {Promise} - The current config + * @param key - The key to delete + * @returns The config object */ -function _delete(key) { +function _delete(key: string) { send(NAME, DELETE, {key}) return config() } /** * @description Returns a subset of the config based on a pattern - * @param {string} pattern - The pattern to match keys against - * @returns {Promise} - The subset of the config + * @param pattern - The pattern to match keys against + * @returns The subset of the config */ -function where(pattern) { +function where(pattern: RegExp): Promise> { return send(NAME, WHERE, {pattern}, {expectReply: true, timeout: 10}) } /** * @description Subscribes to config updates - * @param {Function} callback - The callback to call when config is updated - * @returns {Function} - The unsubscribe function + * @param callback - The callback to call when config is updated + * @returns The unsubscribe function */ -function subscribe(callback) { +function subscribe( + callback: ( + config: Record | null, + error: Error | null + ) => void +): () => void { return subscriber(NAME, () => spawn(HANDLERS, NAME), callback) } /** * @description Clears the config - * @returns {void} */ -export function clearConfig() { - return send(NAME, CLEAR) +export async function clearConfig(): Promise { + await send(NAME, CLEAR) } /** * @description Resets the config to a previous state - * @param {object} oldConfig - The previous config state - * @returns {Promise} - The current config + * @param oldConfig - The previous config state + * @returns The config object */ -function resetConfig(oldConfig) { - return clearConfig().then(config(oldConfig)) +async function resetConfig(oldConfig: Record) { + return clearConfig().then(() => config(oldConfig)) } /** * @description Takes in flow.json or array of flow.json files and creates contract placeholders - * @param {object|object[]} data - The flow.json or array of flow.json files - * @returns {void} + * @param data - The data to load + * @param data.flowJSON - The flow.json or array of flow.json files */ -async function load(data) { - const network = await get("flow.network") +async function load(data: { + flowJSON: Record | Record[] +}) { + const network: string = await get("flow.network") const cleanedNetwork = cleanNetwork(network) const {flowJSON} = data invariant(Boolean(flowJSON), "config.load -- 'flowJSON' must be defined") invariant( - cleanedNetwork, + !!cleanedNetwork, `Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl` ) @@ -232,12 +239,12 @@ async function load(data) { } } -// eslint-disable-next-line jsdoc/require-returns /** * @description Sets the config - * @param {object} [values] - The values to set + * @param values - The values to set + * @returns The config object */ -function config(values) { +function config(values?: Record) { if (values != null && typeof values === "object") { Object.keys(values).map(d => put(d, values[d])) } @@ -269,18 +276,22 @@ config.load = load export {config} -const noop = v => v -function overload(opts = {}, callback = noop) { - return new Promise(async (resolve, reject) => { - const oldConfig = await all() - try { - config(opts) - var result = await callback(await all()) - await resetConfig(oldConfig) - resolve(result) - } catch (error) { - await resetConfig(oldConfig) - reject(error) - } - }) +/** + * @description Temporarily overloads the config with the given values and calls the callback + * @param values - The values to overload the config with + * @param callback - The callback to call with the overloaded config + * @returns The result of the callback + */ +async function overload( + values: Record, + callback: (oldConfig: Record) => T +) { + const oldConfig = await all() + try { + config(values) + const result = await callback(await all()) + return result + } finally { + await resetConfig(oldConfig) + } } diff --git a/packages/config/utils/utils.test.js b/packages/config/src/utils/utils.test.ts similarity index 96% rename from packages/config/utils/utils.test.js rename to packages/config/src/utils/utils.test.ts index 74f2e59c7..8c056b6c0 100644 --- a/packages/config/utils/utils.test.js +++ b/packages/config/src/utils/utils.test.ts @@ -1,8 +1,8 @@ -import {getContracts, anyHasPrivateKeys} from "./utils" +import {getContracts, anyHasPrivateKeys, FlowJson} from "./utils" describe("getContracts", () => { test("it should gather contract aliases for flow.json", () => { - const flowJSON = { + const flowJSON: FlowJson = { networks: { emulator: "127.0.0.1:3569", mainnet: "access.mainnet.nodes.onflow.org:9000", @@ -139,8 +139,8 @@ describe("anyHasPrivateKeys", () => { address: "f8d6e0586b0a20c7", key: { type: "file", - location: "./emulator.key" - } + location: "./emulator.key", + }, }, }, } @@ -157,7 +157,7 @@ describe("anyHasPrivateKeys", () => { accounts: { "emulator-account": { address: "f8d6e0586b0a20c7", - key: "ba68d45a5acaa52f3cacf4ad3a64d9523e0ce0ae3addb1ee6805385b380b7646" + key: "ba68d45a5acaa52f3cacf4ad3a64d9523e0ce0ae3addb1ee6805385b380b7646", }, }, } diff --git a/packages/config/src/utils/utils.ts b/packages/config/src/utils/utils.ts new file mode 100644 index 000000000..b9509525a --- /dev/null +++ b/packages/config/src/utils/utils.ts @@ -0,0 +1,222 @@ +type FlowNetwork = "emulator" | "testnet" | "mainnet" +export interface FlowJson { + networks?: { + [key in FlowNetwork]?: string + } + accounts?: { + [key: string]: { + address: string + key?: string | object + } + } + contracts?: { + [key: string]: { + source: string + aliases: { + [key in FlowNetwork]?: string + } + } + } + deployments?: { + [key in FlowNetwork]?: { + [contract: string]: string[] + } + } +} + +const pipe = + (...funcs: ((v: any) => any)[]) => + (v: any) => { + return funcs.reduce((res, func) => { + return func(res) + }, v) + } + +/*** + * Merge multiple functions returning objects into one object. + * @param funcs - Functions to merge + * @return Merged object + */ +const mergePipe = + (...funcs: ((v: any) => any)[]) => + (v: any) => { + return funcs.reduce((res, func) => { + return {...res, ...func(v)} + }, {}) + } + +/** + * @description Object check + * @param value - Value to check + * @returns Is object status + */ +const isObject = (value: T): boolean => + value && typeof value === "object" && !Array.isArray(value) + +/** + * @description Deep merge multiple objects. + * @param target - Target object + * @param sources - Source objects + * @returns Merged object + */ +const mergeDeep = (target: any, ...sources: any[]): any => { + if (!sources.length) return target + const source = sources.shift() + + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!target[key]) Object.assign(target, {[key]: {}}) + mergeDeep(target[key], source[key]) + } else { + Object.assign(target, {[key]: source[key]}) + } + } + } + + return mergeDeep(target, ...sources) +} + +/** + * @description Support if/then/else behavior in a function way. + * @param testFn - Function to test + * @param posCond - Function to run if testFn is true + * @param negCond - Function to run it testFn is false + * @returns Function that returns the result of posCond or negCond + */ +export const ifElse = + (testFn: (v: T) => U, posCond: (v: T) => U, negCond: (v: T) => U) => + (v: T) => + testFn(v) ? posCond(v) : negCond(v) + +/** + * @description Deep merge multiple Flow JSON. + * @param value - Flow JSON or array of Flow JSONs + * @returns Merged Flow JSON + */ +const mergeFlowJSONs = (value: FlowJson | FlowJson[]) => + Array.isArray(value) ? mergeDeep({}, ...value) : value + +/** + * @description Filter out contracts section of flow.json. + * @param obj - Flow JSON + * @returns Contracts section of Flow JSON + */ +const filterContracts = (obj: FlowJson) => (obj.contracts ? obj.contracts : {}) + +/** + * @description Gathers contract addresses by network + * @param network - Network to gather addresses for + * @returns Contract names by addresses mapping e.g { "HelloWorld": "0x123" } + */ +const mapContractAliasesToNetworkAddress = + (network: string) => (contracts: Record) => { + return Object.entries(contracts).reduce((c, [key, value]) => { + const networkContractAlias = value?.aliases?.[network] + if (networkContractAlias) { + c[key] = networkContractAlias + } + + return c + }, {} as Record) + } + +const mapDeploymentsToNetworkAddress = + (network: FlowNetwork) => + ({ + deployments = {}, + accounts = {}, + }: Pick) => { + const networkDeployment = deployments?.[network] + if (!networkDeployment) return {} + + return Object.entries(networkDeployment).reduce((c, [key, value]) => { + // Resolve account address + const accountAddress = accounts[key]?.address + if (!accountAddress) return c + + // Create an object assigning the address to the contract name. + return value.reduce((c, contract) => { + return {...c, [contract]: accountAddress} + }, {}) + }, {}) + } + +/** + * @description Take in flow.json files and return contract to address mapping by network + * @param jsons - Flow JSON or array of Flow JSONs + * @param network - Network to gather addresses for + * @returns Contract names by addresses mapping e.g { "HelloWorld": "0x123" } + */ +export const getContracts = ( + jsons: FlowJson | FlowJson[], + network: FlowNetwork +) => { + return pipe( + mergeFlowJSONs, + mergePipe( + mapDeploymentsToNetworkAddress(network), + pipe(filterContracts, mapContractAliasesToNetworkAddress(network)) + ) + )(jsons) +} + +/** + * @description Checks if string is hexidecimal + * @param str - String to check + * @returns Is hexidecimal status + */ +const isHexidecimal = (str: unknown) => { + // Check that it is a string + if (typeof str !== "string") return false + return /^[0-9A-Fa-f]+$/.test(str) +} + +/** + * @description Checks flow.json file for private keys + * @param flowJSON - Flow JSON + * @returns Has private keys status + */ +const hasPrivateKeys = (flowJSON: FlowJson) => { + return Object.entries(flowJSON?.accounts ?? []).reduce( + (hasPrivateKey, [, value]) => { + if (hasPrivateKey) return true + return ( + value && + Object.prototype.hasOwnProperty.call(value, "key") && + isHexidecimal(value?.key) + ) + }, + false + ) +} + +/** + * @description Take in flow.json or array of flow.json files and checks for private keys + * @param value - Flow JSON or array of Flow JSONs + * @returns Has private keys status + */ +export const anyHasPrivateKeys = (value: FlowJson | FlowJson[]) => { + if (Array.isArray(value)) return value.some(hasPrivateKeys) + return hasPrivateKeys(value) +} + +/** + * @description Format network to always be 'emulator', 'testnet', or 'mainnet' + * @param network - Network to format + * @returns Formatted network name (either 'emulator', 'testnet', or 'mainnet') + */ +export const cleanNetwork = (network: string): FlowNetwork => { + const cleanedNetwork = + network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase() + if ( + cleanedNetwork === "emulator" || + cleanedNetwork === "testnet" || + cleanedNetwork === "mainnet" + ) + return cleanedNetwork + + throw new Error( + `Invalid network "${network}". Must be one of "emulator", "local", "testnet", or "mainnet"` + ) +} diff --git a/packages/config/utils/utils.js b/packages/config/utils/utils.js deleted file mode 100644 index 23ac51ed4..000000000 --- a/packages/config/utils/utils.js +++ /dev/null @@ -1,171 +0,0 @@ -const pipe = - (...funcs) => - v => { - return funcs.reduce((res, func) => { - return func(res) - }, v) - } - -/*** - * Merge multiple functions returning objects into one object. - * @param {...function(*): object} funcs - Functions to merge - * @return {object} - Merged object - */ -const mergePipe = - (...funcs) => - v => { - return funcs.reduce((res, func) => { - return {...res, ...func(v)} - }, {}) - } - -/** - * @description Object check - * @param {*} value - Value to check - * @returns {boolean} - Is object status - */ -const isObject = value => - value && typeof value === "object" && !Array.isArray(value) - -/** - * @description Deep merge multiple objects. - * @param {object} target - Target object - * @param {...object[]} sources - Source objects - * @returns {object} - Merged object - */ -const mergeDeep = (target, ...sources) => { - if (!sources.length) return target - const source = sources.shift() - - if (isObject(target) && isObject(source)) { - for (const key in source) { - if (isObject(source[key])) { - if (!target[key]) Object.assign(target, {[key]: {}}) - mergeDeep(target[key], source[key]) - } else { - Object.assign(target, {[key]: source[key]}) - } - } - } - - return mergeDeep(target, ...sources) -} - -/** - * @description Support if/then/else behavior in a function way. - * @param {function(object): boolean} testFn - Function to test - * @param {function(object): *} posCond - Function to run if testFn is true - * @param {function(object): *} negCond - Function to run it testFn is false - * @returns {function(*): *} - Function that returns the result of posCond or negCond - */ -export const ifElse = (testFn, posCond, negCond) => obj => - testFn(obj) ? posCond(obj) : negCond(obj) - -/** - * @description Deep merge multiple Flow JSON. - * @param {object|object[]} value - Flow JSON or array of Flow JSONs - * @returns {object} - Merged Flow JSON - */ -const mergeFlowJSONs = value => - Array.isArray(value) ? mergeDeep({}, ...value) : value - -/** - * @description Filter out contracts section of flow.json. - * @param {object|object[]} obj - Flow JSON or array of Flow JSONs - * @returns {object} - Contracts section of Flow JSON - */ -const filterContracts = obj => (obj.contracts ? obj.contracts : {}) - -/** - * @description Gathers contract addresses by network - * @param {string} network - Network to gather addresses for - * @returns {object} - Contract names by addresses mapping e.g { "HelloWorld": "0x123" } - */ -const mapContractAliasesToNetworkAddress = network => contracts => { - return Object.entries(contracts).reduce((c, [key, value]) => { - const networkContractAlias = value?.aliases?.[network] - if (networkContractAlias) { - c[key] = networkContractAlias - } - - return c - }, {}) -} - -const mapDeploymentsToNetworkAddress = - network => - ({deployments = {}, accounts = {}}) => { - const networkDeployment = deployments?.[network] - if (!networkDeployment) return {} - - return Object.entries(networkDeployment).reduce((c, [key, value]) => { - // Resolve account address - const accountAddress = accounts[key]?.address - if (!accountAddress) return c - - // Create an object assigning the address to the contract name. - return value.reduce((c, contract) => { - return {...c, [contract]: accountAddress} - }, {}) - }, {}) - } - -/** - * @description Take in flow.json files and return contract to address mapping by network - * @param {object|object[]} jsons - Flow JSON or array of Flow JSONs - * @param {string} network - Network to gather addresses for - * @returns {object} - Contract names by addresses mapping e.g { "HelloWorld": "0x123" } - */ -export const getContracts = (jsons, network) => { - return pipe( - mergeFlowJSONs, - mergePipe( - mapDeploymentsToNetworkAddress(network), - pipe(filterContracts, mapContractAliasesToNetworkAddress(network)) - ) - )(jsons) -} - -/** - * @description Checks if string is hexidecimal - * @param {string} str - String to check - * @returns {boolean} - Is hexidecimal status - */ -const isHexidecimal = str => { - // Check that it is a string - if (typeof str !== "string") return false - return /^[0-9A-Fa-f]+$/.test(str) -} - -/** - * @description Checks flow.json file for private keys - * @param {object} flowJSON - Flow JSON - * @returns {boolean} - Has private keys status - */ -const hasPrivateKeys = flowJSON => { - return Object.entries(flowJSON?.accounts).reduce( - (hasPrivateKey, [key, value]) => { - if (hasPrivateKey) return true - return value?.hasOwnProperty("key") && isHexidecimal(value?.key) - }, - false - ) -} - -/** - * @description Take in flow.json or array of flow.json files and checks for private keys - * @param {object|object[]} value - Flow JSON or array of Flow JSONs - * @returns {boolean} - Has private keys status - */ -export const anyHasPrivateKeys = value => { - if (isObject(value)) return hasPrivateKeys(value) - return value.some(hasPrivateKeys) -} - -/** - * @description Format network to always be 'emulator', 'testnet', or 'mainnet' - * @param {string} network - Network to format - * @returns {string} - Formatted network name (either 'emulator', 'testnet', or 'mainnet') - */ -export const cleanNetwork = network => - network?.toLowerCase() === "local" ? "emulator" : network?.toLowerCase() diff --git a/packages/util-actor/src/index.ts b/packages/util-actor/src/index.ts index b315f4da8..dd9f8ad2f 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -73,21 +73,21 @@ let pid = 0b0 const DEFAULT_TIMEOUT = 5000 -export function send( +export function send( addr: string, - tag: keyof Handlers & string, + tag: string, data?: Record | null, opts?: {expectReply?: true; timeout?: number; from?: string} ): Promise -export function send( +export function send( addr: string, - tag: keyof Handlers & string, + tag: string, data?: Record | null, opts?: {expectReply?: false; timeout?: number; from?: string} ): Promise -export function send( +export function send( addr: string, - tag: keyof Handlers & string, + tag: string, data?: Record | null, opts: {expectReply?: boolean; timeout?: number; from?: string} = { expectReply: false, @@ -201,11 +201,12 @@ const createCtx = (addr: string) => ({ self: () => addr, receive: () => FCL_REGISTRY[addr].mailbox.receive(), send: ( - to: string, + to: string | null | undefined, tag: string, data?: any, opts: Record = {} ) => { + if (to == null) return opts.from = addr return send(to, tag, data, opts) }, @@ -300,12 +301,9 @@ export function subscriber( // letter.reply(ctx.all()) // } // -export function snapshoter( - address: string, - spawnFn: SpawnFn -) { +export function snapshoter(address: string, spawnFn: SpawnFn) { spawnFn(address) - return send(address, SNAPSHOT, null, { + return send(address, SNAPSHOT, null, { expectReply: true, timeout: 0, }) From 60d4b352868165bb9bc654f9c1493137f90cee01 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 14 Sep 2023 08:12:35 -0700 Subject: [PATCH 07/45] Fix JSDoc type generation (#1780) --- packages/fcl-bundle/src/build/get-input-options.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index b84ffe284..0f01d0f21 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -73,6 +73,16 @@ module.exports = function getInputOptions(package, build) { isTypeScript && typescript({ clean: true, + include: [ + "*.ts+(|x)", + "**/*.ts+(|x)", + "**/*.cts", + "**/*.mts", + "*.js+(|x)", + "**/*.js+(|x)", + "**/*.cjs", + "**/*.mjs", + ], }), replace({ preventAssignment: true, From 86ce9f75b5542a6bce76012e36a7a3d4fb6867f2 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:21:10 -0400 Subject: [PATCH 08/45] restore changeset --- .changeset/hip-radios-behave.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .changeset/hip-radios-behave.md diff --git a/.changeset/hip-radios-behave.md b/.changeset/hip-radios-behave.md new file mode 100644 index 000000000..96891888c --- /dev/null +++ b/.changeset/hip-radios-behave.md @@ -0,0 +1,21 @@ +--- +"@onflow/util-encode-key": minor +"@onflow/transport-grpc": minor +"@onflow/transport-http": minor +"@onflow/util-invariant": minor +"@onflow/util-template": minor +"@onflow/util-address": minor +"@onflow/util-logger": minor +"@onflow/fcl-bundle": minor +"@onflow/util-actor": minor +"@onflow/typedefs": minor +"@onflow/util-uid": minor +"@onflow/config": minor +"@onflow/fcl-wc": minor +"@onflow/types": minor +"@onflow/fcl": minor +"@onflow/rlp": minor +"@onflow/sdk": minor +--- + +TS build From a3818147b4926f9295f88eb0ca7a135e7695c0c8 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:23:49 -0400 Subject: [PATCH 09/45] align packages --- package-lock.json | 8 ++++---- packages/sdk/package.json | 2 +- packages/transport-http/package.json | 2 +- packages/types/package.json | 2 +- packages/util-template/package.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4084e6826..c2360b2ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20464,7 +20464,7 @@ "@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-logger": "^1.2.2", "@onflow/util-template": "^1.1.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4", @@ -20608,7 +20608,7 @@ "@babel/runtime": "^7.18.6", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", + "@onflow/util-logger": "^1.2.2", "@onflow/util-template": "^1.1.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" @@ -20656,7 +20656,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.3.0-alpha.0" + "@onflow/util-logger": "^1.2.2" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", @@ -21356,7 +21356,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.3.0-alpha.0" + "@onflow/util-logger": "^1.2.2" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 9f7b388ab..dc45fe16e 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -47,7 +47,7 @@ "@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-logger": "^1.2.2", "@onflow/util-template": "^1.1.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4", diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index 222dc0345..f3196d2d7 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -35,7 +35,7 @@ "@babel/runtime": "^7.18.6", "@onflow/util-address": "^1.1.0", "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", + "@onflow/util-logger": "^1.2.2", "@onflow/util-template": "^1.1.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" diff --git a/packages/types/package.json b/packages/types/package.json index feda5130f..9c2831923 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -37,6 +37,6 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.3.0-alpha.0" + "@onflow/util-logger": "^1.2.2" } } diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 164129fce..11e7c04be 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -36,6 +36,6 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.3.0-alpha.0" + "@onflow/util-logger": "^1.2.2" } } From ac4e161b0589a3cc2fbe949105988f715fd925c8 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:36:39 -0400 Subject: [PATCH 10/45] pre typescript --- .changeset/pre.json | 33 +++++++++++++++++++++++++++ packages/config/CHANGELOG.md | 15 ++++++++++++ packages/config/package.json | 10 ++++---- packages/fcl-bundle/CHANGELOG.md | 8 +++++++ packages/fcl-bundle/package.json | 2 +- packages/fcl-wc/CHANGELOG.md | 14 ++++++++++++ packages/fcl-wc/package.json | 12 +++++----- packages/fcl/CHANGELOG.md | 20 ++++++++++++++++ packages/fcl/package.json | 26 ++++++++++----------- packages/rlp/CHANGELOG.md | 8 +++++++ packages/rlp/package.json | 4 ++-- packages/sdk/CHANGELOG.md | 18 +++++++++++++++ packages/sdk/package.json | 22 +++++++++--------- packages/transport-grpc/CHANGELOG.md | 14 ++++++++++++ packages/transport-grpc/package.json | 14 ++++++------ packages/transport-http/CHANGELOG.md | 14 ++++++++++++ packages/transport-http/package.json | 18 +++++++-------- packages/typedefs/CHANGELOG.md | 6 +++++ packages/typedefs/package.json | 4 ++-- packages/types/CHANGELOG.md | 13 +++++++++++ packages/types/package.json | 6 ++--- packages/util-actor/CHANGELOG.md | 8 +++++++ packages/util-actor/package.json | 4 ++-- packages/util-address/CHANGELOG.md | 8 +++++++ packages/util-address/package.json | 6 ++--- packages/util-encode-key/CHANGELOG.md | 14 ++++++++++++ packages/util-encode-key/package.json | 10 ++++---- packages/util-invariant/CHANGELOG.md | 8 +++++++ packages/util-invariant/package.json | 6 ++--- packages/util-logger/CHANGELOG.md | 8 +++++++ packages/util-logger/package.json | 4 ++-- packages/util-semver/package.json | 2 +- packages/util-template/CHANGELOG.md | 13 +++++++++++ packages/util-template/package.json | 6 ++--- packages/util-uid/CHANGELOG.md | 8 +++++++ packages/util-uid/package.json | 4 ++-- 36 files changed, 310 insertions(+), 80 deletions(-) create mode 100644 .changeset/pre.json diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..92a4e328c --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,33 @@ +{ + "mode": "pre", + "tag": "typescript", + "initialVersions": { + "@onflow/config": "1.1.2", + "@onflow/fcl": "1.7.0", + "@onflow/fcl-bundle": "1.3.1", + "@onflow/fcl-wc": "4.0.0", + "@onflow/protobuf": "1.2.1", + "@onflow/rlp": "1.1.0", + "@onflow/sdk": "1.2.3", + "@onflow/transport-grpc": "1.2.2", + "@onflow/transport-http": "1.7.2", + "@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.2", + "@onflow/util-semver": "1.0.0", + "@onflow/util-template": "1.1.0", + "@onflow/util-uid": "1.1.0" + }, + "changesets": [ + "fifty-buttons-serve", + "fluffy-yaks-allow", + "giant-ducks-tickle", + "hip-radios-behave", + "tough-fishes-live", + "wise-apples-leave" + ] +} diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index b15da29f7..ad8d825cc 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,20 @@ # @onflow/config +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5) Thanks [@nialexsan](https://github.com/nialexsan)! - Add Typescript to @onflow/config + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-logger@1.3.0-typescript.0 + - @onflow/util-actor@1.3.0-typescript.0 + ## 1.1.2 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index 2f9cf9426..90d81b597 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/config", - "version": "1.1.2", + "version": "1.2.0-typescript.0", "description": "Config for FCL-JS", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.11", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/estree": "^1.0.1", "@types/jest": "^29.5.4", "@typescript-eslint/eslint-plugin": "^6.5.0", @@ -39,9 +39,9 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" } diff --git a/packages/fcl-bundle/CHANGELOG.md b/packages/fcl-bundle/CHANGELOG.md index b182bc8e7..301c92ac5 100644 --- a/packages/fcl-bundle/CHANGELOG.md +++ b/packages/fcl-bundle/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/fcl-bundle +## 1.4.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Switched to rollup-plugin-typescript2 + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.3.1 ### Patch Changes diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index db64a9c83..ac6580793 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/fcl-bundle", - "version": "1.3.1", + "version": "1.4.0-typescript.0", "description": "FCL Bundler Tool", "license": "Apache-2.0", "author": "Dapper Labs ", diff --git a/packages/fcl-wc/CHANGELOG.md b/packages/fcl-wc/CHANGELOG.md index 612d3c282..5c7527319 100644 --- a/packages/fcl-wc/CHANGELOG.md +++ b/packages/fcl-wc/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/fcl-wc +## 5.0.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-logger@1.3.0-typescript.0 + - @onflow/config@1.2.0-typescript.0 + - @onflow/fcl@1.8.0-typescript.0 + ## 4.0.0 ### Patch Changes diff --git a/packages/fcl-wc/package.json b/packages/fcl-wc/package.json index 6cd00fbd5..8e0dbfffc 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": "5.0.0-typescript.0", "description": "WalletConnect adapter for FCL", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -25,21 +25,21 @@ "start": "fcl-bundle --watch" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.2", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", + "@onflow/config": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "@walletconnect/modal": "^2.4.7", "@walletconnect/sign-client": "^2.8.1", "@walletconnect/types": "^2.8.1", "@walletconnect/utils": "^2.8.1" }, "peerDependencies": { - "@onflow/fcl": "^1.6.0" + "@onflow/fcl": "^1.8.0-typescript.0" } } diff --git a/packages/fcl/CHANGELOG.md b/packages/fcl/CHANGELOG.md index 503389d36..1f080e91c 100644 --- a/packages/fcl/CHANGELOG.md +++ b/packages/fcl/CHANGELOG.md @@ -1,5 +1,25 @@ # @onflow/fcl +## 1.8.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`81d4b40e`](https://github.com/onflow/fcl-js/commit/81d4b40e5b76ffb85b6185a274ae1cbce5988e7b), [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: + - @onflow/types@1.2.0-typescript.0 + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-template@1.2.0-typescript.0 + - @onflow/util-address@1.2.0-typescript.0 + - @onflow/util-logger@1.3.0-typescript.0 + - @onflow/util-uid@1.2.0-typescript.0 + - @onflow/rlp@1.2.0-typescript.0 + - @onflow/util-actor@1.3.0-typescript.0 + - @onflow/config@1.2.0-typescript.0 + - @onflow/sdk@1.3.0-typescript.0 + ## 1.7.0 ### Minor Changes diff --git a/packages/fcl/package.json b/packages/fcl/package.json index 74635d5e9..6b65e8343 100644 --- a/packages/fcl/package.json +++ b/packages/fcl/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/fcl", - "version": "1.7.0", + "version": "1.8.0-typescript.0", "description": "Flow Client Library", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -19,8 +19,8 @@ } }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/typedefs": "^1.2.0-typescript.0", "@types/estree": "^1.0.1", "@types/node": "^18.13.0", "eslint": "^8.35.0", @@ -58,18 +58,18 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.2", + "@onflow/config": "^1.2.0-typescript.0", "@onflow/interaction": "0.0.11", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.3", - "@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.2", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "@onflow/util-semver": "^1.0.0", - "@onflow/util-template": "^1.1.0", - "@onflow/util-uid": "^1.1.0", + "@onflow/util-template": "^1.2.0-typescript.0", + "@onflow/util-uid": "^1.2.0-typescript.0", "cross-fetch": "^3.1.6" }, "peerDependencies": { diff --git a/packages/rlp/CHANGELOG.md b/packages/rlp/CHANGELOG.md index 7b291c04e..99b31e860 100644 --- a/packages/rlp/CHANGELOG.md +++ b/packages/rlp/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/rlp +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 9e84502ee..3b26b4158 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/rlp", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Port of ethereumjs/rlp", "license": "MPL-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 0a81749b7..f9aecf820 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,23 @@ # @onflow/sdk +## 1.3.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-template@1.2.0-typescript.0 + - @onflow/util-address@1.2.0-typescript.0 + - @onflow/util-logger@1.3.0-typescript.0 + - @onflow/rlp@1.2.0-typescript.0 + - @onflow/transport-http@1.8.0-typescript.0 + - @onflow/util-actor@1.3.0-typescript.0 + - @onflow/config@1.2.0-typescript.0 + ## 1.2.3 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index dc45fe16e..ec29f38c2 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/sdk", - "version": "1.2.3", + "version": "1.3.0-typescript.0", "description": "Flow SDK", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -18,8 +18,8 @@ } }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/typedefs": "^1.2.0-typescript.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", @@ -41,14 +41,14 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1", - "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.2", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", - "@onflow/util-template": "^1.1.0", + "@onflow/config": "^1.2.0-typescript.0", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/transport-http": "^1.8.0-typescript.0", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4", "uuid": "^9.0.1" diff --git a/packages/transport-grpc/CHANGELOG.md b/packages/transport-grpc/CHANGELOG.md index b9aedc552..60b4edf4b 100644 --- a/packages/transport-grpc/CHANGELOG.md +++ b/packages/transport-grpc/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/transport-grpc +## 1.3.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-template@1.2.0-typescript.0 + - @onflow/util-address@1.2.0-typescript.0 + - @onflow/rlp@1.2.0-typescript.0 + ## 1.2.2 ### Patch Changes diff --git a/packages/transport-grpc/package.json b/packages/transport-grpc/package.json index 5689cc493..1711a0b76 100644 --- a/packages/transport-grpc/package.json +++ b/packages/transport-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-grpc", - "version": "1.2.2", + "version": "1.3.0-typescript.0", "description": "Flow SDK GRPC Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,8 +13,8 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.3", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", "jest": "^29.5.0" }, "source": "src/sdk-send-grpc.js", @@ -34,9 +34,9 @@ "@improbable-eng/grpc-web": "^0.14.0", "@improbable-eng/grpc-web-node-http-transport": "^0.14.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" + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0" } } diff --git a/packages/transport-http/CHANGELOG.md b/packages/transport-http/CHANGELOG.md index d21ec051f..df89ead5e 100644 --- a/packages/transport-http/CHANGELOG.md +++ b/packages/transport-http/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/transport-http +## 1.8.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/util-template@1.2.0-typescript.0 + - @onflow/util-address@1.2.0-typescript.0 + - @onflow/util-logger@1.3.0-typescript.0 + ## 1.7.2 ### Patch Changes diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index f3196d2d7..1940fde3b 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-http", - "version": "1.7.2", + "version": "1.8.0-typescript.0", "description": "Flow SDK HTTP Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,10 +13,10 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.3", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "jest": "^29.5.0" }, "source": "src/sdk-send-http.js", @@ -33,10 +33,10 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", - "@onflow/util-template": "^1.1.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" } diff --git a/packages/typedefs/CHANGELOG.md b/packages/typedefs/CHANGELOG.md index 2180a078a..69aa86833 100644 --- a/packages/typedefs/CHANGELOG.md +++ b/packages/typedefs/CHANGELOG.md @@ -1,5 +1,11 @@ # @onflow/typedefs +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.1.1 ### Patch Changes diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index e11993fce..ffb6d1f5c 100644 --- a/packages/typedefs/package.json +++ b/packages/typedefs/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/typedefs", - "version": "1.1.1", + "version": "1.2.0-typescript.0", "description": "Flow JS Type Defs", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,7 +13,7 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d346f1c99..cdc39904d 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,5 +1,18 @@ # @onflow/types +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`81d4b40e`](https://github.com/onflow/fcl-js/commit/81d4b40e5b76ffb85b6185a274ae1cbce5988e7b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert @onflow/types to TypeScript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: + - @onflow/util-logger@1.3.0-typescript.0 + ## 1.1.0 ### Minor Changes diff --git a/packages/types/package.json b/packages/types/package.json index 9c2831923..5ac0b5228 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/types", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Utilities to transform javascript values into Cadence understandable values", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -37,6 +37,6 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.2.2" + "@onflow/util-logger": "^1.3.0-typescript.0" } } diff --git a/packages/util-actor/CHANGELOG.md b/packages/util-actor/CHANGELOG.md index c01689dd0..572bd2299 100644 --- a/packages/util-actor/CHANGELOG.md +++ b/packages/util-actor/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/util-actor +## 1.3.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537) Thanks [@nialexsan](https://github.com/nialexsan)! - Enhance TS support for @onflow/util-actor + ## 1.2.0 ### Minor Changes diff --git a/packages/util-actor/package.json b/packages/util-actor/package.json index 5f424136d..0f00374a8 100644 --- a/packages/util-actor/package.json +++ b/packages/util-actor/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-actor", - "version": "1.2.0", + "version": "1.3.0-typescript.0", "description": "A mechanism for forcing order/transitions of scoped async state", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", diff --git a/packages/util-address/CHANGELOG.md b/packages/util-address/CHANGELOG.md index c014ddafa..fb931d5d4 100644 --- a/packages/util-address/CHANGELOG.md +++ b/packages/util-address/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/util-address +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-address/package.json b/packages/util-address/package.json index 4f930e22e..622f4b940 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-address", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Flow JS SDK Util -- Address", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,8 +14,8 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^6.4.0", diff --git a/packages/util-encode-key/CHANGELOG.md b/packages/util-encode-key/CHANGELOG.md index a2a08e51f..7a2ec43da 100644 --- a/packages/util-encode-key/CHANGELOG.md +++ b/packages/util-encode-key/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/util-encode-key +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: + - @onflow/util-invariant@1.2.0-typescript.0 + - @onflow/rlp@1.2.0-typescript.0 + ## 1.1.0 ### Minor Changes diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 43fcc0cd9..14d6f2f4d 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-encode-key", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Flow JS SDK Util -- Encode Key", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,8 +14,8 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^6.4.0", @@ -40,7 +40,7 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/rlp": "^1.1.0", - "@onflow/util-invariant": "^1.1.0" + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0" } } diff --git a/packages/util-invariant/CHANGELOG.md b/packages/util-invariant/CHANGELOG.md index 826b3b5d4..e2aa26bbf 100644 --- a/packages/util-invariant/CHANGELOG.md +++ b/packages/util-invariant/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/util-invariant +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index 9e3146c08..efd0890dc 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-invariant", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Flow JS SDK Util -- Invariant", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,8 +14,8 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", diff --git a/packages/util-logger/CHANGELOG.md b/packages/util-logger/CHANGELOG.md index 7d532bf11..89d086a5c 100644 --- a/packages/util-logger/CHANGELOG.md +++ b/packages/util-logger/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/util-logger +## 1.3.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.2.2 ### Patch Changes diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index 3f8a90d4e..b5e36d800 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-logger", - "version": "1.2.2", + "version": "1.3.0-typescript.0", "description": "Logger for FCL-JS", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", diff --git a/packages/util-semver/package.json b/packages/util-semver/package.json index 47dfe67f7..b24246f31 100644 --- a/packages/util-semver/package.json +++ b/packages/util-semver/package.json @@ -13,7 +13,7 @@ "start": "fcl-bundle --watch" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "jest": "^29.5.0" }, "dependencies": { diff --git a/packages/util-template/CHANGELOG.md b/packages/util-template/CHANGELOG.md index 1d6b910bd..ed98b7483 100644 --- a/packages/util-template/CHANGELOG.md +++ b/packages/util-template/CHANGELOG.md @@ -1,5 +1,18 @@ # @onflow/util-template +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: + - @onflow/util-logger@1.3.0-typescript.0 + ## 1.1.0 ### Minor Changes diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 11e7c04be..8f51aeeee 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-template", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Template Literal used for Cadence Interop", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -36,6 +36,6 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.2.2" + "@onflow/util-logger": "^1.3.0-typescript.0" } } diff --git a/packages/util-uid/CHANGELOG.md b/packages/util-uid/CHANGELOG.md index 841eb6100..49e19395e 100644 --- a/packages/util-uid/CHANGELOG.md +++ b/packages/util-uid/CHANGELOG.md @@ -1,5 +1,13 @@ # @onflow/util-uid +## 1.2.0-typescript.0 + +### Minor Changes + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript + +- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-uid/package.json b/packages/util-uid/package.json index 8bafc143e..8d637b79e 100644 --- a/packages/util-uid/package.json +++ b/packages/util-uid/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-uid", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "description": "Utilities to generate Unique Identifiers", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -14,7 +14,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", From 04bd73ea13551d704683c6050e177657ce28bc41 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:38:58 -0400 Subject: [PATCH 11/45] any type for config --- packages/util-logger/src/util-logger.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts index 1510590b6..b69a58f14 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -1,6 +1,6 @@ // Config dependency injected into logger to break circular dependency -let config = null -export const setConfig = _config => { +let config: any = null +export const setConfig = (_config: any) => { config = _config } From da3bc15a9811b9e71160a9c06a9e29dd23bf5d0f Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:39:30 -0400 Subject: [PATCH 12/45] update package lock --- package-lock.json | 160 +++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2360b2ec..a99a790d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19575,19 +19575,19 @@ }, "packages/config": { "name": "@onflow/config", - "version": "1.1.2", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" }, "devDependencies": { "@babel/preset-typescript": "^7.22.11", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/estree": "^1.0.1", "@types/jest": "^29.5.4", "@typescript-eslint/eslint-plugin": "^6.5.0", @@ -19705,27 +19705,27 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.7.0", + "version": "1.8.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.2", + "@onflow/config": "^1.2.0-typescript.0", "@onflow/interaction": "0.0.11", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.3", - "@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.2", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "@onflow/util-semver": "^1.0.0", - "@onflow/util-template": "^1.1.0", - "@onflow/util-uid": "^1.1.0", + "@onflow/util-template": "^1.2.0-typescript.0", + "@onflow/util-uid": "^1.2.0-typescript.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/typedefs": "^1.2.0-typescript.0", "@types/estree": "^1.0.1", "@types/node": "^18.13.0", "eslint": "^8.35.0", @@ -19761,7 +19761,7 @@ }, "packages/fcl-bundle": { "name": "@onflow/fcl-bundle", - "version": "1.3.1", + "version": "1.4.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", @@ -19791,25 +19791,25 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "4.0.0", + "version": "5.0.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.2", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", + "@onflow/config": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", "@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", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl": "^1.6.0" + "@onflow/fcl": "^1.8.0-typescript.0" } }, "packages/fcl/node_modules/eslint-plugin-jsdoc": { @@ -20348,7 +20348,7 @@ }, "packages/rlp": { "name": "@onflow/rlp", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "MPL-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -20356,7 +20356,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -20454,25 +20454,25 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.2.3", + "version": "1.3.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1", - "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.2", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", - "@onflow/util-template": "^1.1.0", + "@onflow/config": "^1.2.0-typescript.0", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/transport-http": "^1.8.0-typescript.0", + "@onflow/util-actor": "^1.3.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4", "uuid": "^9.0.1" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/typedefs": "^1.2.0-typescript.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", @@ -20560,21 +20560,21 @@ }, "packages/transport-grpc": { "name": "@onflow/transport-grpc", - "version": "1.2.2", + "version": "1.3.0-typescript.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", - "@onflow/rlp": "^1.1.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-template": "^1.1.0" + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.3", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", "jest": "^29.5.0" } }, @@ -20602,34 +20602,34 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.7.2", + "version": "1.8.0-typescript.0", "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.2", - "@onflow/util-template": "^1.1.0", + "@onflow/util-address": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0", + "@onflow/util-logger": "^1.3.0-typescript.0", + "@onflow/util-template": "^1.2.0-typescript.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.3", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/sdk": "^1.3.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "jest": "^29.5.0" } }, "packages/typedefs": { "name": "@onflow/typedefs", - "version": "1.1.1", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", @@ -20652,15 +20652,15 @@ }, "packages/types": { "name": "@onflow/types", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.2.2" + "@onflow/util-logger": "^1.3.0-typescript.0" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -20773,7 +20773,7 @@ }, "packages/util-actor": { "name": "@onflow/util-actor", - "version": "1.2.0", + "version": "1.3.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -20781,7 +20781,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -20879,15 +20879,15 @@ }, "packages/util-address": { "name": "@onflow/util-address", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^6.4.0", @@ -20999,17 +20999,17 @@ }, "packages/util-encode-key": { "name": "@onflow/util-encode-key", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/rlp": "^1.1.0", - "@onflow/util-invariant": "^1.1.0" + "@onflow/rlp": "^1.2.0-typescript.0", + "@onflow/util-invariant": "^1.2.0-typescript.0" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^6.4.0", @@ -21121,15 +21121,15 @@ }, "packages/util-invariant": { "name": "@onflow/util-invariant", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", + "@onflow/types": "^1.2.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -21227,14 +21227,14 @@ }, "packages/util-logger": { "name": "@onflow/util-logger", - "version": "1.2.2", + "version": "1.3.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -21346,21 +21346,21 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "jest": "^29.5.0" } }, "packages/util-template": { "name": "@onflow/util-template", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-logger": "^1.2.2" + "@onflow/util-logger": "^1.3.0-typescript.0" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", @@ -21473,14 +21473,14 @@ }, "packages/util-uid": { "name": "@onflow/util-uid", - "version": "1.1.0", + "version": "1.2.0-typescript.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { "@babel/preset-typescript": "^7.22.5", - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@types/jest": "^29.5.3", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", From df3dbac10afc00be0b2ce799838b6c1ae590173c Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:12:48 -0400 Subject: [PATCH 13/45] PKG -- [util-encode-key] eslint ts config --- package-lock.json | 80 ++++++++++----------------- package.json | 6 +- packages/util-encode-key/src/index.ts | 1 + 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index a99a790d8..f7ffbcfc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,11 +14,15 @@ "@changesets/cli": "^2.21.1", "@types/jest": "^29.5.3", "@types/node": "^18.11.18", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", "prettier": "^2.6.2", - "ts-jest": "^29.1.1" + "ts-jest": "^29.1.1", + "typescript": "^5.1.6" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -175,8 +179,7 @@ }, "node_modules/@babel/helper-create-class-features-plugin": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.15.tgz", - "integrity": "sha512-jKkwA59IXcvSaiK2UN45kKwSC9o+KuoXsBDvHvU/7BecYIp8GQ2UwrVvFgJASUT+hBnwJx6MhvMCuMzwZZ7jlg==", + "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", "@babel/helper-environment-visitor": "^7.22.5", @@ -240,8 +243,7 @@ }, "node_modules/@babel/helper-environment-visitor": { "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", - "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -279,8 +281,7 @@ }, "node_modules/@babel/helper-member-expression-to-functions": { "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz", - "integrity": "sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA==", + "license": "MIT", "dependencies": { "@babel/types": "^7.23.0" }, @@ -290,8 +291,7 @@ }, "node_modules/@babel/helper-module-imports": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz", - "integrity": "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==", + "license": "MIT", "dependencies": { "@babel/types": "^7.22.15" }, @@ -301,8 +301,7 @@ }, "node_modules/@babel/helper-module-transforms": { "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.23.0.tgz", - "integrity": "sha512-WhDWw1tdrlT0gMgUJSlX0IQvoO1eN279zrAUbVB+KpV2c3Tylz8+GnKOLllCS6Z/iZQEyVYxhZVUdPTqs2YYPw==", + "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-module-imports": "^7.22.15", @@ -404,16 +403,14 @@ }, "node_modules/@babel/helper-validator-identifier": { "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz", - "integrity": "sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -1142,8 +1139,7 @@ }, "node_modules/@babel/plugin-transform-modules-commonjs": { "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.0.tgz", - "integrity": "sha512-32Xzss14/UVc7k9g775yMIvkVK8xwKE0DPdP5JTapr3+Z9w4tzeOuLNY6BXDQR6BdnzIlXnCGAzsk/ICHBLVWQ==", + "license": "MIT", "dependencies": { "@babel/helper-module-transforms": "^7.23.0", "@babel/helper-plugin-utils": "^7.22.5", @@ -1373,8 +1369,7 @@ }, "node_modules/@babel/plugin-transform-typescript": { "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.15.tgz", - "integrity": "sha512-1uirS0TnijxvQLnlv5wQBwOX3E1wCFX7ITv+9pBV2wKEk4K+M5tqDaoNXnTH8tjEIYHLO98MwiTWO04Ggz4XuA==", + "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", "@babel/helper-create-class-features-plugin": "^7.22.15", @@ -1525,8 +1520,7 @@ }, "node_modules/@babel/preset-typescript": { "version": "7.23.2", - "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.23.2.tgz", - "integrity": "sha512-u4UJc1XsS1GhIGteM8rnGiIvf9rJpiVgMEeCnwlLA7WJPC+jcXWJAGxYmeqs5hOZD8BbAfnV5ezBOxQbb4OUxA==", + "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5", "@babel/helper-validator-option": "^7.22.15", @@ -1595,8 +1589,7 @@ }, "node_modules/@babel/types": { "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.22.5", "@babel/helper-validator-identifier": "^7.22.20", @@ -2049,9 +2042,8 @@ }, "node_modules/@eslint/js": { "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", "dev": true, + "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -2063,9 +2055,8 @@ }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^2.0.1", "debug": "^4.1.1", @@ -2089,9 +2080,8 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", - "dev": true + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/@hutson/parse-repository-url": { "version": "3.0.2", @@ -5223,9 +5213,8 @@ }, "node_modules/@types/jest": { "version": "29.5.7", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", - "integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", "dev": true, + "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" @@ -5570,9 +5559,8 @@ }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/@walletconnect/core": { "version": "2.8.1", @@ -8649,9 +8637,8 @@ }, "node_modules/eslint": { "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -18833,7 +18820,6 @@ "node_modules/typescript": { "version": "5.1.6", "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -19600,9 +19586,8 @@ }, "packages/config/node_modules/@es-joy/jsdoccomment": { "version": "0.40.1", - "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", - "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.0", "esquery": "^1.5.0", @@ -19614,9 +19599,8 @@ }, "packages/config/node_modules/comment-parser": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", - "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } @@ -19634,9 +19618,8 @@ }, "packages/config/node_modules/eslint-plugin-jsdoc": { "version": "46.8.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz", - "integrity": "sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.40.1", "are-docs-informative": "^0.0.2", @@ -19657,18 +19640,16 @@ }, "packages/config/node_modules/jsdoc-type-pratt-parser": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", - "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } }, "packages/config/node_modules/lru-cache": { "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, + "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -19678,9 +19659,8 @@ }, "packages/config/node_modules/semver": { "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, diff --git a/package.json b/package.json index 1e457e04c..20d3acdcd 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,14 @@ "@changesets/cli": "^2.21.1", "@types/jest": "^29.5.3", "@types/node": "^18.11.18", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", "prettier": "^2.6.2", - "ts-jest": "^29.1.1" + "ts-jest": "^29.1.1", + "typescript": "^5.1.6" } } diff --git a/packages/util-encode-key/src/index.ts b/packages/util-encode-key/src/index.ts index 9ba359091..897727d31 100644 --- a/packages/util-encode-key/src/index.ts +++ b/packages/util-encode-key/src/index.ts @@ -15,6 +15,7 @@ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) /** * Encodes a key into a hex string + * * @param key - The key to encode (DER Hex) * @param curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] * @param hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] From e04367c2cc32eca73c862a574097abb0287f77fb Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:35:37 -0400 Subject: [PATCH 14/45] more ts --- ...{build-arguments.js => build-arguments.ts} | 0 packages/sdk/src/build/build.js | 4 +- ...nteraction.test.js => interaction.test.ts} | 15 ++- .../{interaction.js => interaction.ts} | 120 ++++++++++++++---- .../resolve-proposer-sequence-number.js | 4 +- .../sdk/src/resolve/resolve-ref-block-id.js | 8 +- .../{response.test.js => response.test.ts} | 2 +- .../src/response/{response.js => response.ts} | 6 +- packages/sdk/src/sdk.ts | 3 +- packages/sdk/src/send/send.js | 4 +- .../test-utils/{authz-fn.js => authz-fn.ts} | 0 packages/transport-http/package.json | 3 +- .../{sdk-send-http.js => sdk-send-http.ts} | 0 .../src/{send-http.js => send-http.ts} | 38 +++++- .../{send-ping.test.js => send-ping.test.ts} | 0 .../src/{send-ping.js => send-ping.ts} | 17 ++- 16 files changed, 171 insertions(+), 53 deletions(-) rename packages/sdk/src/build/{build-arguments.js => build-arguments.ts} (100%) rename packages/sdk/src/interaction/{interaction.test.js => interaction.test.ts} (76%) rename packages/sdk/src/interaction/{interaction.js => interaction.ts} (71%) rename packages/sdk/src/response/{response.test.js => response.test.ts} (73%) rename packages/sdk/src/response/{response.js => response.ts} (75%) rename packages/sdk/src/test-utils/{authz-fn.js => authz-fn.ts} (100%) rename packages/transport-http/src/{sdk-send-http.js => sdk-send-http.ts} (100%) rename packages/transport-http/src/{send-http.js => send-http.ts} (68%) rename packages/transport-http/src/{send-ping.test.js => send-ping.test.ts} (100%) rename packages/transport-http/src/{send-ping.js => send-ping.ts} (59%) diff --git a/packages/sdk/src/build/build-arguments.js b/packages/sdk/src/build/build-arguments.ts similarity index 100% rename from packages/sdk/src/build/build-arguments.js rename to packages/sdk/src/build/build-arguments.ts diff --git a/packages/sdk/src/build/build.js b/packages/sdk/src/build/build.js index e0e63050a..ada6bb030 100644 --- a/packages/sdk/src/build/build.js +++ b/packages/sdk/src/build/build.js @@ -1,5 +1,5 @@ -import {pipe, interaction} from "../interaction/interaction.js" +import {pipe, initInteraction} from "../interaction/interaction.js" export function build(fns = []) { - return pipe(interaction(), fns) + return pipe(initInteraction(), fns) } diff --git a/packages/sdk/src/interaction/interaction.test.js b/packages/sdk/src/interaction/interaction.test.ts similarity index 76% rename from packages/sdk/src/interaction/interaction.test.js rename to packages/sdk/src/interaction/interaction.test.ts index 7449555da..72baea36a 100644 --- a/packages/sdk/src/interaction/interaction.test.js +++ b/packages/sdk/src/interaction/interaction.test.ts @@ -1,10 +1,11 @@ import {resolveAccounts} from "../sdk" -import {prepAccount} from "./interaction" +import {IAcct, prepAccount, initAccount, initInteraction} from "./interaction" describe("prepAccount", () => { test("prepAccount converts account object keyId to integer", async () => { const keyId = "1" - const acct = { + const acct: IAcct = { + ...initAccount(), addr: "f8d6e0586b0a20c7", keyId, signingFunction: () => ({ @@ -13,13 +14,13 @@ describe("prepAccount", () => { }), } - const ix = prepAccount(acct, {role: "proposer"})({accounts: {}}) - expect(ix.accounts[ix.proposer].keyId).toBe(parseInt(keyId)) + const ix = prepAccount(acct, {role: "proposer"})({...initInteraction(), accounts: {}}) + expect(ix.accounts[ix.proposer||""].keyId).toBe(parseInt(keyId)) }) test("prepAccount converts authorization function keyId to integer", async () => { const keyId = "1" - const authz = acct => { + const authz = (acct: IAcct): IAcct => { return { ...acct, addr: "f8d6e0586b0a20c7", @@ -33,6 +34,7 @@ describe("prepAccount", () => { const ix = await resolveAccounts( prepAccount(authz, {role: "proposer"})({ + ...initInteraction(), accounts: {}, }) ) @@ -41,7 +43,7 @@ describe("prepAccount", () => { }) test("prepAccount does not affect keyId if undefined/does not exist", async () => { - const authz = acct => { + const authz = (acct: IAcct): IAcct => { return { ...acct, addr: "f8d6e0586b0a20c7", @@ -54,6 +56,7 @@ describe("prepAccount", () => { const ix = await resolveAccounts( prepAccount(authz, {role: "proposer"})({ + ...initInteraction(), accounts: {}, }) ) diff --git a/packages/sdk/src/interaction/interaction.js b/packages/sdk/src/interaction/interaction.ts similarity index 71% rename from packages/sdk/src/interaction/interaction.js rename to packages/sdk/src/interaction/interaction.ts index 703ba18f6..c578f2226 100644 --- a/packages/sdk/src/interaction/interaction.js +++ b/packages/sdk/src/interaction/interaction.ts @@ -25,6 +25,26 @@ export const AUTHORIZER /* */ = "authorizer" export const PAYER /* */ = "payer" export const PROPOSER /* */ = "proposer" +export interface IAcct { + "kind": typeof ACCOUNT, + "tempId": string | null, + "addr": string | null, + "keyId": number | string | null, + "sequenceNum": number | null, + "signature": any | null, + "signingFunction": any | null, + "resolve": any | null, + "role": { + "proposer": boolean, + "authorizer": boolean, + "payer": boolean, + "param": boolean, + }, + authorization: any, +} +type AcctFn = (IAcct) => IAcct; +type IAcctFn = AcctFn & Partial; + const ACCT = `{ "kind":"${ACCOUNT}", "tempId":null, @@ -62,6 +82,49 @@ const ARG = `{ "resolveArgument": null }` +interface IIx { + "tag": string, + "assigns": Record, + "status": string, + "reason": string | null, + "accounts": Record, + "params": Record, + "arguments": Record, + "message": { + "cadence": string | null, + "refBlock": string | null, + "computeLimit": string | null, + "proposer": string | null, + "payer": string | null, + "authorizations": string[], + "params": Record[], + "arguments": Record[] + }, + "proposer": string | null, + "authorizations": string[], + "payer": string[], + "events": { + "eventType": string | null, + "start": string | null, + "end": string | null, + "blockIds": string[] + }, + "transaction": { + "id": string | null + }, + "block": { + "id": string | null, + "height": string | null, + "isSealed": boolean | null + }, + "account": { + "addr": string | null + }, + "collection": { + "id": string | null + } +} + const IX = `{ "tag":"${UNKNOWN}", "assigns":{}, @@ -105,9 +168,9 @@ const IX = `{ } }` -const KEYS = new Set(Object.keys(JSON.parse(IX))) +const KEYS = new Set(Object.keys(JSON.parse(IX) as IIx)) -export const interaction = () => JSON.parse(IX) +export const initInteraction = (): IIx => JSON.parse(IX) export const isNumber = d => typeof d === "number" export const isArray = d => Array.isArray(d) @@ -115,52 +178,59 @@ export const isObj = d => d !== null && typeof d === "object" export const isNull = d => d == null export const isFn = d => typeof d === "function" -export const isInteraction = ix => { +export const isInteraction = (ix: IIx) => { if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false for (let key of KEYS) if (!ix.hasOwnProperty(key)) return false return true } -export const Ok = ix => { +export const Ok = (ix: IIx) => { ix.status = OK return ix } -export const Bad = (ix, reason) => { +export const Bad = (ix: IIx, reason) => { ix.status = BAD ix.reason = reason return ix } -const makeIx = wat => ix => { +const makeIx = (wat: string) => (ix: IIx) => { ix.tag = wat return Ok(ix) } -const prepAccountKeyId = acct => { +const prepAccountKeyId = (acct: IAcct | IAcctFn): IAcct | IAcctFn => { if (acct.keyId == null) return acct - invariant(!isNaN(parseInt(acct.keyId)), "account.keyId must be an integer") + invariant(!isNaN(parseInt(acct.keyId.toString())), "account.keyId must be an integer") + return { ...acct, - keyId: parseInt(acct.keyId), - } + keyId: parseInt(acct.keyId.toString()), + } as IAcct | IAcctFn } -export const prepAccount = (acct, opts = {}) => ix => { +interface IPrepAccountOpts { + role: string | null +} + +export const initAccount = (): IAcct => JSON.parse(ACCT) + +export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {role: null}) => (ix: IIx) => { invariant( typeof acct === "function" || typeof acct === "object", "prepAccount must be passed an authorization function or an account object" ) invariant(opts.role != null, "Account must have a role") - const ACCOUNT = JSON.parse(ACCT) + const ACCOUNT = initAccount() const role = opts.role const tempId = uuidv4() if (acct.authorization && isFn(acct.authorization)) - acct = {resolve: acct.authorization} - if (!acct.authorization && isFn(acct)) acct = {resolve: acct} + acct = {...ACCOUNT, resolve: acct.authorization} + if (!acct.authorization && isFn(acct)) acct = {...ACCOUNT, resolve: acct} const resolve = acct.resolve if (resolve) @@ -223,7 +293,7 @@ export const makeGetBlockHeader /* */ = makeIx(GET_BLOCK_HEADER) export const makeGetCollection /* */ = makeIx(GET_COLLECTION) export const makeGetNetworkParameters /* */ = makeIx(GET_NETWORK_PARAMETERS) -const is = wat => ix => ix.tag === wat +const is = wat => (ix: IIx) => ix.tag === wat export const isUnknown /* */ = is(UNKNOWN) export const isScript /* */ = is(SCRIPT) @@ -238,15 +308,15 @@ export const isGetBlockHeader /* */ = is(GET_BLOCK_HEADER) export const isGetCollection /* */ = is(GET_COLLECTION) export const isGetNetworkParameters /* */ = is(GET_NETWORK_PARAMETERS) -export const isOk /* */ = ix => ix.status === OK -export const isBad /* */ = ix => ix.status === BAD -export const why /* */ = ix => ix.reason +export const isOk /* */ = (ix: IIx) => ix.status === OK +export const isBad /* */ = (ix: IIx) => ix.status === BAD +export const why /* */ = (ix: IIx) => ix.reason export const isAccount /* */ = account => account.kind === ACCOUNT export const isParam /* */ = param => param.kind === PARAM export const isArgument /* */ = argument => argument.kind === ARGUMENT -const hardMode = ix => { +const hardMode = (ix: IIx) => { for (let key of Object.keys(ix)) { if (!KEYS.has(key)) throw new Error(`"${key}" is an invalid root level Interaction property.`) @@ -254,7 +324,7 @@ const hardMode = ix => { return ix } -const recPipe = async (ix, fns = []) => { +const recPipe = async (ix: IIx, fns = []) => { try { ix = hardMode(await ix) if (isBad(ix)) throw new Error(`Interaction Error: ${ix.reason}`) @@ -276,23 +346,23 @@ export const pipe = (...args) => { return recPipe(arg1, arg2) } -const identity = v => v +const identity = (v, ..._) => v -export const get = (ix, key, fallback) => { +export const get = (ix: IIx, key: string, fallback) => { return ix.assigns[key] == null ? fallback : ix.assigns[key] } -export const put = (key, value) => ix => { +export const put = (key: string, value) => (ix: IIx) => { ix.assigns[key] = value return Ok(ix) } -export const update = (key, fn = identity) => ix => { +export const update = (key: string, fn = identity) => (ix: IIx) => { ix.assigns[key] = fn(ix.assigns[key], ix) return Ok(ix) } -export const destroy = key => ix => { +export const destroy = (key: string) => (ix: IIx) => { delete ix.assigns[key] return Ok(ix) } diff --git a/packages/sdk/src/resolve/resolve-proposer-sequence-number.js b/packages/sdk/src/resolve/resolve-proposer-sequence-number.js index f66bc0adb..92148d188 100644 --- a/packages/sdk/src/resolve/resolve-proposer-sequence-number.js +++ b/packages/sdk/src/resolve/resolve-proposer-sequence-number.js @@ -1,5 +1,5 @@ -import {isTransaction, Ok} from "../interaction/interaction.js" -import * as ixModule from "../interaction/interaction.js" +import {isTransaction, Ok} from "../interaction/interaction" +import * as ixModule from "../interaction/interaction" import {response as responseModule} from "../response/response.js" import {config} from "@onflow/config" import {decodeResponse} from "../decode/decode.js" diff --git a/packages/sdk/src/resolve/resolve-ref-block-id.js b/packages/sdk/src/resolve/resolve-ref-block-id.js index 5e7af37c8..26dd7e706 100644 --- a/packages/sdk/src/resolve/resolve-ref-block-id.js +++ b/packages/sdk/src/resolve/resolve-ref-block-id.js @@ -1,10 +1,10 @@ import { isTransaction, Ok, - interaction, + initInteraction, pipe, -} from "../interaction/interaction.js" -import * as ixModule from "../interaction/interaction.js" +} from "../interaction/interaction" +import * as ixModule from "../interaction/interaction" import {response} from "../response/response.js" import {config} from "@onflow/config" import {decodeResponse} from "../decode/decode.js" @@ -23,7 +23,7 @@ async function getRefId(opts) { ) var ix - ix = await pipe(interaction(), [getBlock()]) + ix = await pipe(initInteraction(), [getBlock()]) ix = await sendFn(ix, {config, response, Buffer, ix: ixModule}, {node}) ix = await decodeResponse(ix) return ix.id diff --git a/packages/sdk/src/response/response.test.js b/packages/sdk/src/response/response.test.ts similarity index 73% rename from packages/sdk/src/response/response.test.js rename to packages/sdk/src/response/response.test.ts index 226ca304c..48b843431 100644 --- a/packages/sdk/src/response/response.test.js +++ b/packages/sdk/src/response/response.test.ts @@ -1,4 +1,4 @@ -import {response} from "./response.js" +import {response} from "./response" test("Response - Snapshot", async () => { const resp = response() diff --git a/packages/sdk/src/response/response.js b/packages/sdk/src/response/response.ts similarity index 75% rename from packages/sdk/src/response/response.js rename to packages/sdk/src/response/response.ts index e5e19e385..9c9adf121 100644 --- a/packages/sdk/src/response/response.js +++ b/packages/sdk/src/response/response.ts @@ -1,4 +1,4 @@ -const DEFAULT_RESPONSE = `{ +const DEFAULT_RESPONSE = { "tag":null, "transaction":null, "transactionStatus":null, @@ -11,6 +11,6 @@ const DEFAULT_RESPONSE = `{ "latestBlock":null, "collection":null, "networkParameters":null -}` +} -export const response = () => JSON.parse(DEFAULT_RESPONSE) +export const response = () => ({...DEFAULT_RESPONSE}) diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 9a4decc99..54b679dbf 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -11,7 +11,8 @@ export { } from "./encode/encode" // Utils export { - interaction, + initInteraction as interaction, // deprecated + initInteraction, isOk, isBad, why, diff --git a/packages/sdk/src/send/send.js b/packages/sdk/src/send/send.js index 31254e5a3..904105f27 100644 --- a/packages/sdk/src/send/send.js +++ b/packages/sdk/src/send/send.js @@ -1,6 +1,6 @@ import {Buffer} from "@onflow/rlp" import {send as defaultSend} from "@onflow/transport-http" -import {interaction, pipe} from "../interaction/interaction.js" +import {initInteraction, pipe} from "../interaction/interaction.js" import * as ixModule from "../interaction/interaction.js" import {invariant} from "../build/build-invariant.js" import {response} from "../response/response.js" @@ -31,7 +31,7 @@ export const send = async (args = [], opts = {}) => { opts.node = opts.node || (await config().get("accessNode.api")) - if (Array.isArray(args)) args = pipe(interaction(), args) + if (Array.isArray(args)) args = pipe(initInteraction(), args) return sendFn( await resolveFn(args), {config, response, ix: ixModule, Buffer}, diff --git a/packages/sdk/src/test-utils/authz-fn.js b/packages/sdk/src/test-utils/authz-fn.ts similarity index 100% rename from packages/sdk/src/test-utils/authz-fn.js rename to packages/sdk/src/test-utils/authz-fn.ts diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index 1940fde3b..5e7c915c0 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -19,10 +19,11 @@ "@onflow/types": "^1.2.0-typescript.0", "jest": "^29.5.0" }, - "source": "src/sdk-send-http.js", + "source": "src/sdk-send-http.ts", "main": "dist/sdk-send-http.js", "module": "dist/sdk-send-http.module.js", "unpkg": "dist/sdk-send-http.umd.js", + "types": "dist/types/sdk-send-http.d.ts", "scripts": { "alpha": "npm publish --tag alpha", "prepublishOnly": "npm test && npm run build", diff --git a/packages/transport-http/src/sdk-send-http.js b/packages/transport-http/src/sdk-send-http.ts similarity index 100% rename from packages/transport-http/src/sdk-send-http.js rename to packages/transport-http/src/sdk-send-http.ts diff --git a/packages/transport-http/src/send-http.js b/packages/transport-http/src/send-http.ts similarity index 68% rename from packages/transport-http/src/send-http.js rename to packages/transport-http/src/send-http.ts index ce26a5acf..5d27855c0 100644 --- a/packages/transport-http/src/send-http.js +++ b/packages/transport-http/src/send-http.ts @@ -11,12 +11,44 @@ import {sendGetCollection} from "./send-get-collection.js" import {sendPing} from "./send-ping.js" import {sendGetNetworkParameters} from "./send-get-network-parameters.js" -export const send = async (ix, context = {}, opts = {}) => { +interface IIxModule { + isTransaction: (any) => boolean; + isGetTransactionStatus: (any) => boolean; + isGetTransaction: (any) => boolean; + isScript: (any) => boolean; + isGetAccount: (any) => boolean; + isGetEvents: (any) => boolean; + isGetBlock: (any) => boolean; + isGetBlockHeader: (any) => boolean; + isGetCollection: (any) => boolean; + isPing: (any) => boolean; + isGetNetworkParameters: (any) => boolean; +} +interface IContext { + ix?: IIxModule; +} + +interface IOpts { + node?: string + sendTransaction?: (ix, context, opts) => void + sendGetTransactionStatus?: (ix, context, opts) => void + sendGetTransaction?: (ix, context, opts) => void + sendExecuteScript?: (ix, context, opts) => void + sendGetAccount?: (ix, context, opts) => void + sendGetEvents?: (ix, context, opts) => void + sendGetBlockHeader?: (ix, context, opts) => void + sendGetCollection?: (ix, context, opts) => void + sendPing?: (ix, context, opts) => void + sendGetBlock?: (ix, context, opts) => void + sendGetNetworkParameters?: (ix, context, opts) => void +} + +export const send = async (ix, context: IContext = {}, opts: IOpts = {}) => { invariant( - opts.node, + Boolean(opts?.node), `SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.` ) - invariant(context.ix, `SDK Send Error: context.ix must be defined.`) + invariant(Boolean(context.ix), `SDK Send Error: context.ix must be defined.`) ix = await ix diff --git a/packages/transport-http/src/send-ping.test.js b/packages/transport-http/src/send-ping.test.ts similarity index 100% rename from packages/transport-http/src/send-ping.test.js rename to packages/transport-http/src/send-ping.test.ts diff --git a/packages/transport-http/src/send-ping.js b/packages/transport-http/src/send-ping.ts similarity index 59% rename from packages/transport-http/src/send-ping.js rename to packages/transport-http/src/send-ping.ts index 67fc80de3..d7c956901 100644 --- a/packages/transport-http/src/send-ping.js +++ b/packages/transport-http/src/send-ping.ts @@ -1,10 +1,21 @@ import {invariant} from "@onflow/util-invariant" import {httpRequest as defaultHttpRequest} from "./http-request.js" -export async function sendPing(ix, context = {}, opts = {}) { - invariant(opts.node, `SDK Send Ping Error: opts.node must be defined.`) +interface IContext { + response?: Function; + ix?: any; +} + +interface IOpts { + node?: string + httpRequest?: any, + +} + +export async function sendPing(ix, context: IContext = {}, opts: IOpts = {}) { + invariant(Boolean(opts.node), `SDK Send Ping Error: opts.node must be defined.`) invariant( - context.response, + Boolean(context.response), `SDK Send Ping Error: context.response must be defined.` ) From 869ab99388ef7ae46d2ab472547698b9bae38407 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:12:07 -0400 Subject: [PATCH 15/45] move interaction types --- packages/sdk/src/interaction/interaction.ts | 112 +++----------------- packages/transport-http/src/send-ping.ts | 7 +- packages/typedefs/src/index.ts | 2 + packages/typedefs/src/interaction.ts | 85 +++++++++++++++ 4 files changed, 106 insertions(+), 100 deletions(-) create mode 100644 packages/typedefs/src/interaction.ts diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index c578f2226..d16e12511 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -1,48 +1,9 @@ import {invariant} from "@onflow/util-invariant" import {v4 as uuidv4} from "uuid" -export const UNKNOWN /* */ = "UNKNOWN" -export const SCRIPT /* */ = "SCRIPT" -export const TRANSACTION /* */ = "TRANSACTION" -export const GET_TRANSACTION_STATUS /* */ = "GET_TRANSACTION_STATUS" -export const GET_ACCOUNT /* */ = "GET_ACCOUNT" -export const GET_EVENTS /* */ = "GET_EVENTS" -export const PING /* */ = "PING" -export const GET_TRANSACTION /* */ = "GET_TRANSACTION" -export const GET_BLOCK /* */ = "GET_BLOCK" -export const GET_BLOCK_HEADER /* */ = "GET_BLOCK_HEADER" -export const GET_COLLECTION /* */ = "GET_COLLECTION" -export const GET_NETWORK_PARAMETERS /* */ = "GET_NETWORK_PARAMETERS" - -export const BAD /* */ = "BAD" -export const OK /* */ = "OK" - -export const ACCOUNT /* */ = "ACCOUNT" -export const PARAM /* */ = "PARAM" -export const ARGUMENT /* */ = "ARGUMENT" - -export const AUTHORIZER /* */ = "authorizer" -export const PAYER /* */ = "payer" -export const PROPOSER /* */ = "proposer" - -export interface IAcct { - "kind": typeof ACCOUNT, - "tempId": string | null, - "addr": string | null, - "keyId": number | string | null, - "sequenceNum": number | null, - "signature": any | null, - "signingFunction": any | null, - "resolve": any | null, - "role": { - "proposer": boolean, - "authorizer": boolean, - "payer": boolean, - "param": boolean, - }, - authorization: any, -} -type AcctFn = (IAcct) => IAcct; +import { IAcct, ACCOUNT, PARAM, ARGUMENT, UNKNOWN, OK, IIx, AUTHORIZER, PAYER, SCRIPT, TRANSACTION, GET_TRANSACTION_STATUS, GET_TRANSACTION, GET_ACCOUNT, GET_EVENTS, PING, GET_BLOCK, GET_BLOCK_HEADER, GET_COLLECTION, GET_NETWORK_PARAMETERS, BAD, PROPOSER } from "@onflow/typedefs"; + +type AcctFn = (acct: IAcct) => IAcct; type IAcctFn = AcctFn & Partial; const ACCT = `{ @@ -82,49 +43,6 @@ const ARG = `{ "resolveArgument": null }` -interface IIx { - "tag": string, - "assigns": Record, - "status": string, - "reason": string | null, - "accounts": Record, - "params": Record, - "arguments": Record, - "message": { - "cadence": string | null, - "refBlock": string | null, - "computeLimit": string | null, - "proposer": string | null, - "payer": string | null, - "authorizations": string[], - "params": Record[], - "arguments": Record[] - }, - "proposer": string | null, - "authorizations": string[], - "payer": string[], - "events": { - "eventType": string | null, - "start": string | null, - "end": string | null, - "blockIds": string[] - }, - "transaction": { - "id": string | null - }, - "block": { - "id": string | null, - "height": string | null, - "isSealed": boolean | null - }, - "account": { - "addr": string | null - }, - "collection": { - "id": string | null - } -} - const IX = `{ "tag":"${UNKNOWN}", "assigns":{}, @@ -189,7 +107,7 @@ export const Ok = (ix: IIx) => { return ix } -export const Bad = (ix: IIx, reason) => { +export const Bad = (ix: IIx, reason: string) => { ix.status = BAD ix.reason = reason return ix @@ -234,7 +152,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {rol const resolve = acct.resolve if (resolve) - acct.resolve = (acct, ...rest) => + acct.resolve = (acct: IAcct, ...rest: any[]) => [resolve, prepAccountKeyId].reduce( async (d, fn) => fn(await d, ...rest), acct @@ -293,7 +211,7 @@ export const makeGetBlockHeader /* */ = makeIx(GET_BLOCK_HEADER) export const makeGetCollection /* */ = makeIx(GET_COLLECTION) export const makeGetNetworkParameters /* */ = makeIx(GET_NETWORK_PARAMETERS) -const is = wat => (ix: IIx) => ix.tag === wat +const is = (wat: string) => (ix: IIx) => ix.tag === wat export const isUnknown /* */ = is(UNKNOWN) export const isScript /* */ = is(SCRIPT) @@ -312,9 +230,9 @@ export const isOk /* */ = (ix: IIx) => ix.status === OK export const isBad /* */ = (ix: IIx) => ix.status === BAD export const why /* */ = (ix: IIx) => ix.reason -export const isAccount /* */ = account => account.kind === ACCOUNT -export const isParam /* */ = param => param.kind === PARAM -export const isArgument /* */ = argument => argument.kind === ARGUMENT +export const isAccount /* */ = (account: Record) => account.kind === ACCOUNT +export const isParam /* */ = (param: Record) => param.kind === PARAM +export const isArgument /* */ = (argument: Record) => argument.kind === ARGUMENT const hardMode = (ix: IIx) => { for (let key of Object.keys(ix)) { @@ -324,7 +242,7 @@ const hardMode = (ix: IIx) => { return ix } -const recPipe = async (ix: IIx, fns = []) => { +const recPipe = async (ix: IIx, fns: (Function | IIx)[] = []): Promise => { try { ix = hardMode(await ix) if (isBad(ix)) throw new Error(`Interaction Error: ${ix.reason}`) @@ -340,19 +258,19 @@ const recPipe = async (ix: IIx, fns = []) => { } } -export const pipe = (...args) => { +export const pipe = (...args: any[]) => { const [arg1, arg2] = args - if (isArray(arg1) && arg2 == null) return d => pipe(d, arg1) + if (isArray(arg1) && arg2 == null) return (d: any) => pipe(d, arg1) return recPipe(arg1, arg2) } -const identity = (v, ..._) => v +const identity = (v: any, ..._: any[]) => v -export const get = (ix: IIx, key: string, fallback) => { +export const get = (ix: IIx, key: string, fallback: any) => { return ix.assigns[key] == null ? fallback : ix.assigns[key] } -export const put = (key: string, value) => (ix: IIx) => { +export const put = (key: string, value: any) => (ix: IIx) => { ix.assigns[key] = value return Ok(ix) } diff --git a/packages/transport-http/src/send-ping.ts b/packages/transport-http/src/send-ping.ts index d7c956901..6cc54276b 100644 --- a/packages/transport-http/src/send-ping.ts +++ b/packages/transport-http/src/send-ping.ts @@ -1,9 +1,10 @@ import {invariant} from "@onflow/util-invariant" import {httpRequest as defaultHttpRequest} from "./http-request.js" +import { IIx } from "@onflow/typedefs"; interface IContext { response?: Function; - ix?: any; + ix?: IIx; } interface IOpts { @@ -12,7 +13,7 @@ interface IOpts { } -export async function sendPing(ix, context: IContext = {}, opts: IOpts = {}) { +export async function sendPing(ix: IIx, context: IContext = {}, opts: IOpts = {}) { invariant(Boolean(opts.node), `SDK Send Ping Error: opts.node must be defined.`) invariant( Boolean(context.response), @@ -28,7 +29,7 @@ export async function sendPing(ix, context: IContext = {}, opts: IOpts = {}) { body: null, }) - let ret = context.response() + let ret = typeof context?.response === 'function' ? context.response() : {} ret.tag = ix.tag return ret diff --git a/packages/typedefs/src/index.ts b/packages/typedefs/src/index.ts index 5971369c2..0b10e8ba6 100644 --- a/packages/typedefs/src/index.ts +++ b/packages/typedefs/src/index.ts @@ -288,3 +288,5 @@ export type Provider = { */ name: string } + +export * from "./interaction" diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts new file mode 100644 index 000000000..bd70447fe --- /dev/null +++ b/packages/typedefs/src/interaction.ts @@ -0,0 +1,85 @@ + +export const UNKNOWN /* */ = "UNKNOWN" +export const SCRIPT /* */ = "SCRIPT" +export const TRANSACTION /* */ = "TRANSACTION" +export const GET_TRANSACTION_STATUS /* */ = "GET_TRANSACTION_STATUS" +export const GET_ACCOUNT /* */ = "GET_ACCOUNT" +export const GET_EVENTS /* */ = "GET_EVENTS" +export const PING /* */ = "PING" +export const GET_TRANSACTION /* */ = "GET_TRANSACTION" +export const GET_BLOCK /* */ = "GET_BLOCK" +export const GET_BLOCK_HEADER /* */ = "GET_BLOCK_HEADER" +export const GET_COLLECTION /* */ = "GET_COLLECTION" +export const GET_NETWORK_PARAMETERS /* */ = "GET_NETWORK_PARAMETERS" + +export const BAD /* */ = "BAD" +export const OK /* */ = "OK" + +export const ACCOUNT /* */ = "ACCOUNT" +export const PARAM /* */ = "PARAM" +export const ARGUMENT /* */ = "ARGUMENT" + +export const AUTHORIZER /* */ = "authorizer" +export const PAYER /* */ = "payer" +export const PROPOSER /* */ = "proposer" + +export interface IAcct { + "kind": typeof ACCOUNT, + "tempId": string | null, + "addr": string | null, + "keyId": number | string | null, + "sequenceNum": number | null, + "signature": any | null, + "signingFunction": any | null, + "resolve": any | null, + "role": { + "proposer": boolean, + "authorizer": boolean, + "payer": boolean, + "param": boolean, + }, + authorization: any, +} + +export interface IIx { + "tag": string, + "assigns": Record, + "status": string, + "reason": string | null, + "accounts": Record, + "params": Record, + "arguments": Record, + "message": { + "cadence": string | null, + "refBlock": string | null, + "computeLimit": string | null, + "proposer": string | null, + "payer": string | null, + "authorizations": string[], + "params": Record[], + "arguments": string[] + }, + "proposer": string | null, + "authorizations": string[], + "payer": string[], + "events": { + "eventType": string | null, + "start": string | null, + "end": string | null, + "blockIds": string[] + }, + "transaction": { + "id": string | null + }, + "block": { + "id": string | null, + "height": string | null, + "isSealed": boolean | null + }, + "account": { + "addr": string | null + }, + "collection": { + "id": string | null + } +} \ No newline at end of file From d1d5e5ed1c55b20ab45f3d6121a26b769d1e8afc Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:22:58 -0400 Subject: [PATCH 16/45] fix types --- packages/transport-http/src/send-http.ts | 58 +++++++++++++----------- packages/transport-http/src/send-ping.ts | 5 +- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/packages/transport-http/src/send-http.ts b/packages/transport-http/src/send-http.ts index 5d27855c0..72618f52e 100644 --- a/packages/transport-http/src/send-http.ts +++ b/packages/transport-http/src/send-http.ts @@ -8,42 +8,46 @@ import {sendGetEvents} from "./send-get-events.js" import {sendGetBlock} from "./send-get-block.js" import {sendGetBlockHeader} from "./send-get-block-header.js" import {sendGetCollection} from "./send-get-collection.js" -import {sendPing} from "./send-ping.js" +import {sendPing, IContext as ISendPingContext} from "./send-ping" import {sendGetNetworkParameters} from "./send-get-network-parameters.js" +import { IIx } from "@onflow/typedefs" interface IIxModule { - isTransaction: (any) => boolean; - isGetTransactionStatus: (any) => boolean; - isGetTransaction: (any) => boolean; - isScript: (any) => boolean; - isGetAccount: (any) => boolean; - isGetEvents: (any) => boolean; - isGetBlock: (any) => boolean; - isGetBlockHeader: (any) => boolean; - isGetCollection: (any) => boolean; - isPing: (any) => boolean; - isGetNetworkParameters: (any) => boolean; + isTransaction: (ix: IIx) => boolean; + isGetTransactionStatus: (ix: IIx) => boolean; + isGetTransaction: (ix: IIx) => boolean; + isScript: (ix: IIx) => boolean; + isGetAccount: (ix: IIx) => boolean; + isGetEvents: (ix: IIx) => boolean; + isGetBlock: (ix: IIx) => boolean; + isGetBlockHeader: (ix: IIx) => boolean; + isGetCollection: (ix: IIx) => boolean; + isPing: (ix: IIx) => boolean; + isGetNetworkParameters: (ix: IIx) => boolean; } -interface IContext { - ix?: IIxModule; +interface IContext extends ISendPingContext{ + ix: IIxModule; } -interface IOpts { +interface IOptsCommon { node?: string - sendTransaction?: (ix, context, opts) => void - sendGetTransactionStatus?: (ix, context, opts) => void - sendGetTransaction?: (ix, context, opts) => void - sendExecuteScript?: (ix, context, opts) => void - sendGetAccount?: (ix, context, opts) => void - sendGetEvents?: (ix, context, opts) => void - sendGetBlockHeader?: (ix, context, opts) => void - sendGetCollection?: (ix, context, opts) => void - sendPing?: (ix, context, opts) => void - sendGetBlock?: (ix, context, opts) => void - sendGetNetworkParameters?: (ix, context, opts) => void } -export const send = async (ix, context: IContext = {}, opts: IOpts = {}) => { +interface IOpts extends IOptsCommon { + sendTransaction?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetTransactionStatus?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetTransaction?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendExecuteScript?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetAccount?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetEvents?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetBlockHeader?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetCollection?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendPing?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetBlock?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendGetNetworkParameters?: (ix: IIx, context: IContext, opts: IOptsCommon) => void +} + +export const send = async (ix: IIx, context: IContext, opts: IOpts = {}) => { invariant( Boolean(opts?.node), `SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.` diff --git a/packages/transport-http/src/send-ping.ts b/packages/transport-http/src/send-ping.ts index 6cc54276b..b047bea4f 100644 --- a/packages/transport-http/src/send-ping.ts +++ b/packages/transport-http/src/send-ping.ts @@ -2,12 +2,11 @@ import {invariant} from "@onflow/util-invariant" import {httpRequest as defaultHttpRequest} from "./http-request.js" import { IIx } from "@onflow/typedefs"; -interface IContext { +export interface IContext { response?: Function; - ix?: IIx; } -interface IOpts { +export interface IOpts { node?: string httpRequest?: any, From dbf6bf8c53c6235c00e14e112a0febb422cfc37e Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 15:35:33 -0400 Subject: [PATCH 17/45] more types --- packages/sdk/src/build/build-arguments.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/src/build/build-arguments.ts b/packages/sdk/src/build/build-arguments.ts index b76e27152..768feaf7a 100644 --- a/packages/sdk/src/build/build-arguments.ts +++ b/packages/sdk/src/build/build-arguments.ts @@ -15,6 +15,6 @@ export function args(ax = []) { * @param {Function} xform - A function to transform the value * @returns {object} - An argument object */ -export function arg(value, xform) { +export function arg(value: any, xform: any) { return {value, xform} } From 0d47959b14e4ad28984e4cc59a1c34ce9a622f3c Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:00:43 -0400 Subject: [PATCH 18/45] authz types --- packages/sdk/src/test-utils/authz-fn.ts | 36 ++++++++++++++++++------- packages/typedefs/src/interaction.ts | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/sdk/src/test-utils/authz-fn.ts b/packages/sdk/src/test-utils/authz-fn.ts index 7085e4a89..175c8acfe 100644 --- a/packages/sdk/src/test-utils/authz-fn.ts +++ b/packages/sdk/src/test-utils/authz-fn.ts @@ -1,14 +1,19 @@ +import { IAcct } from "@onflow/typedefs" import {withPrefix} from "@onflow/util-address" -export const idof = acct => `${withPrefix(acct.addr)}-${acct.keyId}` +export const idof = (acct: IAcct) => `${withPrefix(acct.addr)}-${acct.keyId}` -export function sig(opts) { +export function sig(opts: Partial) { return ["SIGNATURE", opts.addr, opts.keyId].join(".") } -export function authzFn(opts = {}) { - return function (account) { - const acct = { +interface IAuthzOpts { + signingFunction?: (signable: any) => any +} + +export function authzFn(opts: IAuthzOpts = {}) { + return function (account: Partial) { + const acct: Partial = { ...account, ...opts, resolve: null, @@ -20,7 +25,7 @@ export function authzFn(opts = {}) { return acct - function fallbackSigningFunction(signable) { + function fallbackSigningFunction(_signable: any) { return { addr: acct.addr, keyId: acct.keyId, @@ -30,8 +35,12 @@ export function authzFn(opts = {}) { } } -export function authzResolve(opts = {}) { - return function (account) { +interface IAuthzResolveOpts { + tempId?: string +} + +export function authzResolve(opts: IAuthzResolveOpts = {}) { + return function (account: IAcct) { const {tempId, ...rest} = opts return { ...account, @@ -44,8 +53,15 @@ export function authzResolve(opts = {}) { const ROLE = {proposer: false, authorizer: false, payer: false} const noop = () => {} -export function authzResolveMany(opts = {}) { - return function (account) { +interface IAuthzResolveMany { + tempId?: string + authorizations: any[] + proposer?: any + payer?: any +} + +export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) { + return function (account: IAcct) { const tempId = opts.tempId || "AUTHZ_RESOLVE_MANY" return { ...account, diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index bd70447fe..17208f911 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -36,7 +36,7 @@ export interface IAcct { "proposer": boolean, "authorizer": boolean, "payer": boolean, - "param": boolean, + "param"?: boolean, }, authorization: any, } From fbb91f7223499f6ff88da1ac86bc5326bcc8313c Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:33:55 -0400 Subject: [PATCH 19/45] fix export --- packages/sdk/src/interaction/interaction.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index d16e12511..5acd4fe46 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -284,3 +284,5 @@ export const destroy = (key: string) => (ix: IIx) => { delete ix.assigns[key] return Ok(ix) } + +export * from "@onflow/typedefs" From 6c4ecba1ae780d4d0864dc304680c39848a2b4e1 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:38:52 -0400 Subject: [PATCH 20/45] fix imports --- packages/sdk/src/build/build-arguments.ts | 2 +- packages/sdk/src/build/build-at-block-height.js | 2 +- packages/sdk/src/build/build-at-block-height.test.js | 2 +- packages/sdk/src/build/build-at-block-id.js | 2 +- packages/sdk/src/build/build-at-block-id.test.js | 2 +- packages/sdk/src/build/build-authorizations.js | 2 +- packages/sdk/src/build/build-authorizations.test.js | 2 +- packages/sdk/src/build/build-get-account.js | 2 +- packages/sdk/src/build/build-get-account.test.js | 2 +- packages/sdk/src/build/build-get-block-header.js | 2 +- packages/sdk/src/build/build-get-block-header.test.js | 2 +- packages/sdk/src/build/build-get-block.js | 2 +- packages/sdk/src/build/build-get-block.test.js | 2 +- packages/sdk/src/build/build-get-collection.js | 2 +- packages/sdk/src/build/build-get-collection.test.js | 2 +- .../sdk/src/build/build-get-events-at-block-height-range.js | 2 +- .../src/build/build-get-events-at-block-height-range.test.js | 2 +- packages/sdk/src/build/build-get-events-at-block-ids.js | 2 +- packages/sdk/src/build/build-get-events-at-block-ids.test.js | 2 +- packages/sdk/src/build/build-get-events.js | 2 +- packages/sdk/src/build/build-get-latest-block.js | 2 +- packages/sdk/src/build/build-get-network-parameters.js | 2 +- packages/sdk/src/build/build-get-network-parameters.test.js | 2 +- packages/sdk/src/build/build-get-transaction-status.js | 2 +- packages/sdk/src/build/build-get-transaction-status.test.js | 2 +- packages/sdk/src/build/build-get-transaction.js | 2 +- packages/sdk/src/build/build-get-transaction.test.js | 2 +- packages/sdk/src/build/build-invariant.js | 2 +- packages/sdk/src/build/build-limit.test.js | 2 +- packages/sdk/src/build/build-payer.test.js | 2 +- packages/sdk/src/build/build-ping.js | 2 +- packages/sdk/src/build/build-ping.test.js | 2 +- packages/sdk/src/build/build-proposer.js | 2 +- packages/sdk/src/build/build-proposer.test.js | 2 +- packages/sdk/src/build/build-ref.js | 2 +- packages/sdk/src/build/build-ref.test.js | 2 +- packages/sdk/src/build/build-script.js | 2 +- packages/sdk/src/build/build-script.test.js | 2 +- packages/sdk/src/build/build-transaction.js | 2 +- packages/sdk/src/build/build-transaction.test.js | 2 +- packages/sdk/src/build/build-validator.js | 2 +- packages/sdk/src/build/build-voucher-intercept.js | 2 +- packages/sdk/src/build/build-voucher-intercept.test.js | 2 +- packages/sdk/src/build/build.js | 2 +- packages/sdk/src/contract.test.js | 2 +- packages/sdk/src/resolve/resolve-accounts.js | 2 +- packages/sdk/src/resolve/resolve-arguments.js | 2 +- packages/sdk/src/resolve/resolve-cadence.js | 2 +- packages/sdk/src/resolve/resolve-cadence.test.js | 2 +- packages/sdk/src/resolve/resolve-compute-limit.js | 2 +- packages/sdk/src/resolve/resolve-compute-limit.test.js | 2 +- packages/sdk/src/resolve/resolve-signatures.js | 2 +- packages/sdk/src/resolve/resolve-validators.js | 2 +- packages/sdk/src/resolve/resolve-voucher-intercept.js | 2 +- packages/sdk/src/resolve/resolve.js | 4 ++-- packages/sdk/src/sdk.ts | 2 +- packages/sdk/src/send/send.js | 4 ++-- 57 files changed, 59 insertions(+), 59 deletions(-) diff --git a/packages/sdk/src/build/build-arguments.ts b/packages/sdk/src/build/build-arguments.ts index 768feaf7a..9ff273f26 100644 --- a/packages/sdk/src/build/build-arguments.ts +++ b/packages/sdk/src/build/build-arguments.ts @@ -1,4 +1,4 @@ -import {pipe, makeArgument} from "../interaction/interaction.js" +import {pipe, makeArgument} from "../interaction/interaction" /** * @description - A utility builder to be used with other builders to pass in arguments with a value and supported type diff --git a/packages/sdk/src/build/build-at-block-height.js b/packages/sdk/src/build/build-at-block-height.js index 9bc4c0f2d..1a295287e 100644 --- a/packages/sdk/src/build/build-at-block-height.js +++ b/packages/sdk/src/build/build-at-block-height.js @@ -1,4 +1,4 @@ -import {pipe} from "../interaction/interaction.js" +import {pipe} from "../interaction/interaction" import {validator} from "./build-validator.js" /** diff --git a/packages/sdk/src/build/build-at-block-height.test.js b/packages/sdk/src/build/build-at-block-height.test.js index 97d2f9fac..9ba776184 100644 --- a/packages/sdk/src/build/build-at-block-height.test.js +++ b/packages/sdk/src/build/build-at-block-height.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {atBlockHeight} from "./build-at-block-height.js" describe("Build At Block ID", () => { diff --git a/packages/sdk/src/build/build-at-block-id.js b/packages/sdk/src/build/build-at-block-id.js index 2553bcee9..581568d0b 100644 --- a/packages/sdk/src/build/build-at-block-id.js +++ b/packages/sdk/src/build/build-at-block-id.js @@ -1,4 +1,4 @@ -import {isGetAccount, pipe, Ok} from "../interaction/interaction.js" +import {isGetAccount, pipe, Ok} from "../interaction/interaction" import {validator} from "./build-validator.js" export function atBlockId(id) { diff --git a/packages/sdk/src/build/build-at-block-id.test.js b/packages/sdk/src/build/build-at-block-id.test.js index 2bbb99bb9..edc119cc5 100644 --- a/packages/sdk/src/build/build-at-block-id.test.js +++ b/packages/sdk/src/build/build-at-block-id.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {atBlockId} from "./build-at-block-id.js" describe("Build At Block ID", () => { diff --git a/packages/sdk/src/build/build-authorizations.js b/packages/sdk/src/build/build-authorizations.js index 3775c9d0b..40aeb53b0 100644 --- a/packages/sdk/src/build/build-authorizations.js +++ b/packages/sdk/src/build/build-authorizations.js @@ -1,4 +1,4 @@ -import {pipe, prepAccount, AUTHORIZER} from "../interaction/interaction.js" +import {pipe, prepAccount, AUTHORIZER} from "../interaction/interaction" export function authorizations(ax = []) { return pipe( diff --git a/packages/sdk/src/build/build-authorizations.test.js b/packages/sdk/src/build/build-authorizations.test.js index 8962f7d7f..cc85d33f9 100644 --- a/packages/sdk/src/build/build-authorizations.test.js +++ b/packages/sdk/src/build/build-authorizations.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {authorizations, authorization} from "./build-authorizations.js" describe("Build Authorizations", () => { diff --git a/packages/sdk/src/build/build-get-account.js b/packages/sdk/src/build/build-get-account.js index 1496284f7..b25adf310 100644 --- a/packages/sdk/src/build/build-get-account.js +++ b/packages/sdk/src/build/build-get-account.js @@ -1,4 +1,4 @@ -import {pipe, makeGetAccount, Ok} from "../interaction/interaction.js" +import {pipe, makeGetAccount, Ok} from "../interaction/interaction" import {sansPrefix} from "@onflow/util-address" /** diff --git a/packages/sdk/src/build/build-get-account.test.js b/packages/sdk/src/build/build-get-account.test.js index 3e4b8e1d1..19695492f 100644 --- a/packages/sdk/src/build/build-get-account.test.js +++ b/packages/sdk/src/build/build-get-account.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {sansPrefix, withPrefix} from "@onflow/util-address" import {getAccount} from "./build-get-account.js" diff --git a/packages/sdk/src/build/build-get-block-header.js b/packages/sdk/src/build/build-get-block-header.js index 7dd29467f..b803793ab 100644 --- a/packages/sdk/src/build/build-get-block-header.js +++ b/packages/sdk/src/build/build-get-block-header.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetBlockHeader} from "../interaction/interaction.js" +import {pipe, Ok, makeGetBlockHeader} from "../interaction/interaction" /** * @description - A builder function that returns the interaction to get a block header diff --git a/packages/sdk/src/build/build-get-block-header.test.js b/packages/sdk/src/build/build-get-block-header.test.js index 583b60498..ea89714d5 100644 --- a/packages/sdk/src/build/build-get-block-header.test.js +++ b/packages/sdk/src/build/build-get-block-header.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetBlockHeader} from "../interaction/interaction.js" +import {interaction, isGetBlockHeader} from "../interaction/interaction" import {getBlockHeader} from "./build-get-block-header.js" describe("Build Get Block Header", () => { diff --git a/packages/sdk/src/build/build-get-block.js b/packages/sdk/src/build/build-get-block.js index 9fb4af689..0f8604c74 100644 --- a/packages/sdk/src/build/build-get-block.js +++ b/packages/sdk/src/build/build-get-block.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetBlock} from "../interaction/interaction.js" +import {pipe, Ok, makeGetBlock} from "../interaction/interaction" /** * @description - A builder function that returns the interaction to get the latest block diff --git a/packages/sdk/src/build/build-get-block.test.js b/packages/sdk/src/build/build-get-block.test.js index d0d4bb3da..9b157d4be 100644 --- a/packages/sdk/src/build/build-get-block.test.js +++ b/packages/sdk/src/build/build-get-block.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetBlock} from "../interaction/interaction.js" +import {interaction, isGetBlock} from "../interaction/interaction" import {getBlock} from "./build-get-block.js" describe("Build Get Block", () => { diff --git a/packages/sdk/src/build/build-get-collection.js b/packages/sdk/src/build/build-get-collection.js index 6ab976e97..96f0ca585 100644 --- a/packages/sdk/src/build/build-get-collection.js +++ b/packages/sdk/src/build/build-get-collection.js @@ -1,4 +1,4 @@ -import {pipe, makeGetCollection} from "../interaction/interaction.js" +import {pipe, makeGetCollection} from "../interaction/interaction" /** * @description - A builder function that returns all a collection containing a list of transaction ids by its collection id diff --git a/packages/sdk/src/build/build-get-collection.test.js b/packages/sdk/src/build/build-get-collection.test.js index 143c3a42b..207b097e5 100644 --- a/packages/sdk/src/build/build-get-collection.test.js +++ b/packages/sdk/src/build/build-get-collection.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetCollection} from "../interaction/interaction.js" +import {interaction, isGetCollection} from "../interaction/interaction" import {getCollection} from "./build-get-collection.js" describe("Build Get Collection", () => { diff --git a/packages/sdk/src/build/build-get-events-at-block-height-range.js b/packages/sdk/src/build/build-get-events-at-block-height-range.js index d88e0b3e4..58c19bd93 100644 --- a/packages/sdk/src/build/build-get-events-at-block-height-range.js +++ b/packages/sdk/src/build/build-get-events-at-block-height-range.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetEvents} from "../interaction/interaction.js" +import {pipe, Ok, makeGetEvents} from "../interaction/interaction" /** * @description - A builder function that returns all instances of a particular event (by name) within a height range diff --git a/packages/sdk/src/build/build-get-events-at-block-height-range.test.js b/packages/sdk/src/build/build-get-events-at-block-height-range.test.js index 9889ca07a..ae3e5c5db 100644 --- a/packages/sdk/src/build/build-get-events-at-block-height-range.test.js +++ b/packages/sdk/src/build/build-get-events-at-block-height-range.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetEvents} from "../interaction/interaction.js" +import {interaction, isGetEvents} from "../interaction/interaction" import {getEventsAtBlockHeightRange} from "./build-get-events-at-block-height-range.js" describe("Build Get Events At Block Height Range", () => { diff --git a/packages/sdk/src/build/build-get-events-at-block-ids.js b/packages/sdk/src/build/build-get-events-at-block-ids.js index 0865a1941..6fe534032 100644 --- a/packages/sdk/src/build/build-get-events-at-block-ids.js +++ b/packages/sdk/src/build/build-get-events-at-block-ids.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetEvents} from "../interaction/interaction.js" +import {pipe, Ok, makeGetEvents} from "../interaction/interaction" /** * @description - A builder function that returns all instances of a particular event (by name) within a set of blocks, specified by block ids diff --git a/packages/sdk/src/build/build-get-events-at-block-ids.test.js b/packages/sdk/src/build/build-get-events-at-block-ids.test.js index d4ac3cf2f..2c6d3e2cb 100644 --- a/packages/sdk/src/build/build-get-events-at-block-ids.test.js +++ b/packages/sdk/src/build/build-get-events-at-block-ids.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetEvents} from "../interaction/interaction.js" +import {interaction, isGetEvents} from "../interaction/interaction" import {getEventsAtBlockIds} from "./build-get-events-at-block-ids.js" describe("Build Get Events At Block Ids", () => { diff --git a/packages/sdk/src/build/build-get-events.js b/packages/sdk/src/build/build-get-events.js index 9783860d8..f338524e3 100644 --- a/packages/sdk/src/build/build-get-events.js +++ b/packages/sdk/src/build/build-get-events.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetEvents} from "../interaction/interaction.js" +import {pipe, Ok, makeGetEvents} from "../interaction/interaction" import * as logger from "@onflow/util-logger" export function getEvents(eventType, start, end) { diff --git a/packages/sdk/src/build/build-get-latest-block.js b/packages/sdk/src/build/build-get-latest-block.js index 0e823a212..005a73557 100644 --- a/packages/sdk/src/build/build-get-latest-block.js +++ b/packages/sdk/src/build/build-get-latest-block.js @@ -1,5 +1,5 @@ import {log} from "@onflow/util-logger" -import {pipe, Ok, makeGetLatestBlock} from "../interaction/interaction.js" +import {pipe, Ok, makeGetLatestBlock} from "../interaction/interaction" export function getLatestBlock(isSealed = false) { log.deprecate({ diff --git a/packages/sdk/src/build/build-get-network-parameters.js b/packages/sdk/src/build/build-get-network-parameters.js index 6ea5b29f0..760ba7a91 100644 --- a/packages/sdk/src/build/build-get-network-parameters.js +++ b/packages/sdk/src/build/build-get-network-parameters.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetNetworkParameters} from "../interaction/interaction.js" +import {pipe, Ok, makeGetNetworkParameters} from "../interaction/interaction" export function getNetworkParameters() { return pipe([ diff --git a/packages/sdk/src/build/build-get-network-parameters.test.js b/packages/sdk/src/build/build-get-network-parameters.test.js index f8f72de77..52d09008f 100644 --- a/packages/sdk/src/build/build-get-network-parameters.test.js +++ b/packages/sdk/src/build/build-get-network-parameters.test.js @@ -1,7 +1,7 @@ import { interaction, isGetNetworkParameters, -} from "../interaction/interaction.js" +} from "../interaction/interaction" import {getNetworkParameters} from "./build-get-network-parameters.js" describe("Build Get Network Parameters", () => { diff --git a/packages/sdk/src/build/build-get-transaction-status.js b/packages/sdk/src/build/build-get-transaction-status.js index 1dec09cfa..adb4b6806 100644 --- a/packages/sdk/src/build/build-get-transaction-status.js +++ b/packages/sdk/src/build/build-get-transaction-status.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetTransactionStatus} from "../interaction/interaction.js" +import {pipe, Ok, makeGetTransactionStatus} from "../interaction/interaction" /** * @description - A builder function that returns the status of transaction diff --git a/packages/sdk/src/build/build-get-transaction-status.test.js b/packages/sdk/src/build/build-get-transaction-status.test.js index 4de877cc6..e01a32035 100644 --- a/packages/sdk/src/build/build-get-transaction-status.test.js +++ b/packages/sdk/src/build/build-get-transaction-status.test.js @@ -1,7 +1,7 @@ import { interaction, isGetTransactionStatus, -} from "../interaction/interaction.js" +} from "../interaction/interaction" import {getTransactionStatus} from "./build-get-transaction-status.js" describe("Build Get Transaction Status", () => { diff --git a/packages/sdk/src/build/build-get-transaction.js b/packages/sdk/src/build/build-get-transaction.js index 899490bff..4f559843d 100644 --- a/packages/sdk/src/build/build-get-transaction.js +++ b/packages/sdk/src/build/build-get-transaction.js @@ -1,4 +1,4 @@ -import {pipe, Ok, makeGetTransaction} from "../interaction/interaction.js" +import {pipe, Ok, makeGetTransaction} from "../interaction/interaction" /** * @description - A builder function that returns a transaction diff --git a/packages/sdk/src/build/build-get-transaction.test.js b/packages/sdk/src/build/build-get-transaction.test.js index f094028fb..053228f29 100644 --- a/packages/sdk/src/build/build-get-transaction.test.js +++ b/packages/sdk/src/build/build-get-transaction.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetTransaction} from "../interaction/interaction.js" +import {interaction, isGetTransaction} from "../interaction/interaction" import {getTransaction} from "./build-get-transaction.js" describe("Build Get Transaction", () => { diff --git a/packages/sdk/src/build/build-invariant.js b/packages/sdk/src/build/build-invariant.js index fddb25e45..b6a431467 100644 --- a/packages/sdk/src/build/build-invariant.js +++ b/packages/sdk/src/build/build-invariant.js @@ -1,4 +1,4 @@ -import {Ok, Bad} from "../interaction/interaction.js" +import {Ok, Bad} from "../interaction/interaction" export function invariant(...args) { if (args.length > 1) { diff --git a/packages/sdk/src/build/build-limit.test.js b/packages/sdk/src/build/build-limit.test.js index 43702b10e..78c9582e7 100644 --- a/packages/sdk/src/build/build-limit.test.js +++ b/packages/sdk/src/build/build-limit.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {limit} from "./build-limit.js" describe("Build Limit", () => { diff --git a/packages/sdk/src/build/build-payer.test.js b/packages/sdk/src/build/build-payer.test.js index 4fff58f81..e8853b06b 100644 --- a/packages/sdk/src/build/build-payer.test.js +++ b/packages/sdk/src/build/build-payer.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {payer} from "./build-payer.js" describe("Build Payer", () => { diff --git a/packages/sdk/src/build/build-ping.js b/packages/sdk/src/build/build-ping.js index 6cf368de0..0379ff2cc 100644 --- a/packages/sdk/src/build/build-ping.js +++ b/packages/sdk/src/build/build-ping.js @@ -1,4 +1,4 @@ -import {makePing} from "../interaction/interaction.js" +import {makePing} from "../interaction/interaction" export function ping() { return makePing diff --git a/packages/sdk/src/build/build-ping.test.js b/packages/sdk/src/build/build-ping.test.js index 6404d5b70..3e21c3fe1 100644 --- a/packages/sdk/src/build/build-ping.test.js +++ b/packages/sdk/src/build/build-ping.test.js @@ -1,4 +1,4 @@ -import {interaction, isPing} from "../interaction/interaction.js" +import {interaction, isPing} from "../interaction/interaction" import {ping} from "./build-ping.js" describe("Build Ping", () => { diff --git a/packages/sdk/src/build/build-proposer.js b/packages/sdk/src/build/build-proposer.js index 1753f8089..aabbb9180 100644 --- a/packages/sdk/src/build/build-proposer.js +++ b/packages/sdk/src/build/build-proposer.js @@ -1,4 +1,4 @@ -import {prepAccount, PROPOSER} from "../interaction/interaction.js" +import {prepAccount, PROPOSER} from "../interaction/interaction" export async function proposer(authz) { return prepAccount(authz, {role: PROPOSER}) diff --git a/packages/sdk/src/build/build-proposer.test.js b/packages/sdk/src/build/build-proposer.test.js index 47370fcdf..60eae30fe 100644 --- a/packages/sdk/src/build/build-proposer.test.js +++ b/packages/sdk/src/build/build-proposer.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {proposer} from "./build-proposer.js" describe("Build Proposer", () => { diff --git a/packages/sdk/src/build/build-ref.js b/packages/sdk/src/build/build-ref.js index 7d60242c3..bc1648715 100644 --- a/packages/sdk/src/build/build-ref.js +++ b/packages/sdk/src/build/build-ref.js @@ -1,4 +1,4 @@ -import {pipe, Ok} from "../interaction/interaction.js" +import {pipe, Ok} from "../interaction/interaction" export function ref(refBlock) { return pipe([ diff --git a/packages/sdk/src/build/build-ref.test.js b/packages/sdk/src/build/build-ref.test.js index 516b35893..d9e26b2b5 100644 --- a/packages/sdk/src/build/build-ref.test.js +++ b/packages/sdk/src/build/build-ref.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {ref} from "./build-ref.js" describe("Build Ref", () => { diff --git a/packages/sdk/src/build/build-script.js b/packages/sdk/src/build/build-script.js index 45c3ca954..9dbd8072f 100644 --- a/packages/sdk/src/build/build-script.js +++ b/packages/sdk/src/build/build-script.js @@ -1,4 +1,4 @@ -import {pipe, Ok, put, makeScript} from "../interaction/interaction.js" +import {pipe, Ok, put, makeScript} from "../interaction/interaction" import {template} from "@onflow/util-template" export function script(...args) { diff --git a/packages/sdk/src/build/build-script.test.js b/packages/sdk/src/build/build-script.test.js index 7a390198c..ce69c14c4 100644 --- a/packages/sdk/src/build/build-script.test.js +++ b/packages/sdk/src/build/build-script.test.js @@ -1,4 +1,4 @@ -import {interaction, isScript} from "../interaction/interaction.js" +import {interaction, isScript} from "../interaction/interaction" import {script} from "./build-script.js" describe("Build Script", () => { diff --git a/packages/sdk/src/build/build-transaction.js b/packages/sdk/src/build/build-transaction.js index d4570d4eb..27b003d02 100644 --- a/packages/sdk/src/build/build-transaction.js +++ b/packages/sdk/src/build/build-transaction.js @@ -1,4 +1,4 @@ -import {pipe, put, Ok, makeTransaction} from "../interaction/interaction.js" +import {pipe, put, Ok, makeTransaction} from "../interaction/interaction" import {template} from "@onflow/util-template" const DEFAULT_SCRIPT_ACCOUNTS = [] diff --git a/packages/sdk/src/build/build-transaction.test.js b/packages/sdk/src/build/build-transaction.test.js index de961571e..4904bb44c 100644 --- a/packages/sdk/src/build/build-transaction.test.js +++ b/packages/sdk/src/build/build-transaction.test.js @@ -1,4 +1,4 @@ -import {interaction, isTransaction} from "../interaction/interaction.js" +import {interaction, isTransaction} from "../interaction/interaction" import {transaction} from "./build-transaction.js" describe("Build Transaction", () => { diff --git a/packages/sdk/src/build/build-validator.js b/packages/sdk/src/build/build-validator.js index 708a9602e..c55a4e7f2 100644 --- a/packages/sdk/src/build/build-validator.js +++ b/packages/sdk/src/build/build-validator.js @@ -1,4 +1,4 @@ -import {update} from "../interaction/interaction.js" +import {update} from "../interaction/interaction" export function validator(cb) { return update("ix.validators", validators => diff --git a/packages/sdk/src/build/build-voucher-intercept.js b/packages/sdk/src/build/build-voucher-intercept.js index ad99ba1a0..ae9392945 100644 --- a/packages/sdk/src/build/build-voucher-intercept.js +++ b/packages/sdk/src/build/build-voucher-intercept.js @@ -1,4 +1,4 @@ -import {put} from "../interaction/interaction.js" +import {put} from "../interaction/interaction" export function voucherIntercept(fn) { return put("ix.voucher-intercept", fn) diff --git a/packages/sdk/src/build/build-voucher-intercept.test.js b/packages/sdk/src/build/build-voucher-intercept.test.js index 6e6c6cf32..99e264d07 100644 --- a/packages/sdk/src/build/build-voucher-intercept.test.js +++ b/packages/sdk/src/build/build-voucher-intercept.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction.js" +import {interaction} from "../interaction/interaction" import {voucherIntercept} from "./build-voucher-intercept" describe("Build voucherIntercept", () => { diff --git a/packages/sdk/src/build/build.js b/packages/sdk/src/build/build.js index ada6bb030..c7c3b2725 100644 --- a/packages/sdk/src/build/build.js +++ b/packages/sdk/src/build/build.js @@ -1,4 +1,4 @@ -import {pipe, initInteraction} from "../interaction/interaction.js" +import {pipe, initInteraction} from "../interaction/interaction" export function build(fns = []) { return pipe(initInteraction(), fns) diff --git a/packages/sdk/src/contract.test.js b/packages/sdk/src/contract.test.js index 866d0c02f..57c4b5d9d 100644 --- a/packages/sdk/src/contract.test.js +++ b/packages/sdk/src/contract.test.js @@ -1,7 +1,7 @@ import * as root from "./sdk" import * as decode from "./decode/decode.js" import * as encode from "./encode/encode.js" -import * as interaction from "./interaction/interaction.js" +import * as interaction from "./interaction/interaction" import * as send from "./send/send.js" import * as template from "@onflow/util-template" diff --git a/packages/sdk/src/resolve/resolve-accounts.js b/packages/sdk/src/resolve/resolve-accounts.js index 8376d8e55..15deaa7ec 100644 --- a/packages/sdk/src/resolve/resolve-accounts.js +++ b/packages/sdk/src/resolve/resolve-accounts.js @@ -1,7 +1,7 @@ import {sansPrefix, withPrefix} from "@onflow/util-address" import {invariant} from "@onflow/util-invariant" import {log} from "@onflow/util-logger" -import {isTransaction} from "../interaction/interaction.js" +import {isTransaction} from "../interaction/interaction" import {createSignableVoucher} from "./voucher.js" import {v4 as uuidv4} from "uuid" diff --git a/packages/sdk/src/resolve/resolve-arguments.js b/packages/sdk/src/resolve/resolve-arguments.js index 04db4a7d1..eb1ad392c 100644 --- a/packages/sdk/src/resolve/resolve-arguments.js +++ b/packages/sdk/src/resolve/resolve-arguments.js @@ -1,5 +1,5 @@ import {invariant} from "@onflow/util-invariant" -import {isTransaction, isScript} from "../interaction/interaction.js" +import {isTransaction, isScript} from "../interaction/interaction" const isFn = v => typeof v === "function" diff --git a/packages/sdk/src/resolve/resolve-cadence.js b/packages/sdk/src/resolve/resolve-cadence.js index 2e73baeaa..3da21cbb4 100644 --- a/packages/sdk/src/resolve/resolve-cadence.js +++ b/packages/sdk/src/resolve/resolve-cadence.js @@ -1,4 +1,4 @@ -import {isTransaction, isScript, get} from "../interaction/interaction.js" +import {isTransaction, isScript, get} from "../interaction/interaction" import {invariant} from "@onflow/util-invariant" import {config} from "@onflow/config" import * as logger from "@onflow/util-logger" diff --git a/packages/sdk/src/resolve/resolve-cadence.test.js b/packages/sdk/src/resolve/resolve-cadence.test.js index a2dc77aa9..43763a241 100644 --- a/packages/sdk/src/resolve/resolve-cadence.test.js +++ b/packages/sdk/src/resolve/resolve-cadence.test.js @@ -1,4 +1,4 @@ -import {interaction, pipe, put, makeScript} from "../interaction/interaction.js" +import {interaction, pipe, put, makeScript} from "../interaction/interaction" import {resolveCadence} from "./resolve-cadence.js" import {config} from "@onflow/config" diff --git a/packages/sdk/src/resolve/resolve-compute-limit.js b/packages/sdk/src/resolve/resolve-compute-limit.js index 1bd5479b6..a93cd58cf 100644 --- a/packages/sdk/src/resolve/resolve-compute-limit.js +++ b/packages/sdk/src/resolve/resolve-compute-limit.js @@ -1,4 +1,4 @@ -import {isTransaction} from "../interaction/interaction.js" +import {isTransaction} from "../interaction/interaction" import {config} from "@onflow/config" import * as logger from "@onflow/util-logger" diff --git a/packages/sdk/src/resolve/resolve-compute-limit.test.js b/packages/sdk/src/resolve/resolve-compute-limit.test.js index 2b2e05c9e..a976e37f8 100644 --- a/packages/sdk/src/resolve/resolve-compute-limit.test.js +++ b/packages/sdk/src/resolve/resolve-compute-limit.test.js @@ -1,4 +1,4 @@ -import {interaction, pipe, makeTransaction} from "../interaction/interaction.js" +import {interaction, pipe, makeTransaction} from "../interaction/interaction" import {config} from "@onflow/config" import {resolveComputeLimit} from "./resolve-compute-limit.js" diff --git a/packages/sdk/src/resolve/resolve-signatures.js b/packages/sdk/src/resolve/resolve-signatures.js index 83bf7f117..9254bb9a2 100644 --- a/packages/sdk/src/resolve/resolve-signatures.js +++ b/packages/sdk/src/resolve/resolve-signatures.js @@ -1,4 +1,4 @@ -import {isTransaction} from "../interaction/interaction.js" +import {isTransaction} from "../interaction/interaction" import {sansPrefix} from "@onflow/util-address" import { encodeTransactionPayload as encodeInsideMessage, diff --git a/packages/sdk/src/resolve/resolve-validators.js b/packages/sdk/src/resolve/resolve-validators.js index 1974aff54..f86ebd02b 100644 --- a/packages/sdk/src/resolve/resolve-validators.js +++ b/packages/sdk/src/resolve/resolve-validators.js @@ -1,4 +1,4 @@ -import {get, pipe, Ok, Bad} from "../interaction/interaction.js" +import {get, pipe, Ok, Bad} from "../interaction/interaction" export async function resolveValidators(ix) { const validators = get(ix, "ix.validators", []) diff --git a/packages/sdk/src/resolve/resolve-voucher-intercept.js b/packages/sdk/src/resolve/resolve-voucher-intercept.js index 7a6067005..45ede7224 100644 --- a/packages/sdk/src/resolve/resolve-voucher-intercept.js +++ b/packages/sdk/src/resolve/resolve-voucher-intercept.js @@ -1,4 +1,4 @@ -import {get, isFn} from "../interaction/interaction.js" +import {get, isFn} from "../interaction/interaction" import {createSignableVoucher} from "./voucher.js" export async function resolveVoucherIntercept(ix) { diff --git a/packages/sdk/src/resolve/resolve.js b/packages/sdk/src/resolve/resolve.js index c17030dd8..50728726a 100644 --- a/packages/sdk/src/resolve/resolve.js +++ b/packages/sdk/src/resolve/resolve.js @@ -1,9 +1,9 @@ -import {pipe, isTransaction} from "../interaction/interaction.js" +import {pipe, isTransaction} from "../interaction/interaction" import {config} from "@onflow/config" import {invariant} from "@onflow/util-invariant" import {Buffer} from "@onflow/rlp" import {send as defaultSend} from "@onflow/transport-http" -import * as ixModule from "../interaction/interaction.js" +import * as ixModule from "../interaction/interaction" import {response} from "../response/response.js" import {build} from "../build/build.js" import {getBlock} from "../build/build-get-block.js" diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 54b679dbf..7e391b28f 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -33,7 +33,7 @@ export { isGetBlockHeader, isGetCollection, isGetNetworkParameters, -} from "./interaction/interaction.js" +} from "./interaction/interaction" export {createSignableVoucher, voucherToTxId} from "./resolve/voucher.js" export {encodeMessageFromSignable} from "./wallet-utils/encode-signable.js" export {template as cadence} from "@onflow/util-template" diff --git a/packages/sdk/src/send/send.js b/packages/sdk/src/send/send.js index 904105f27..55676da12 100644 --- a/packages/sdk/src/send/send.js +++ b/packages/sdk/src/send/send.js @@ -1,7 +1,7 @@ import {Buffer} from "@onflow/rlp" import {send as defaultSend} from "@onflow/transport-http" -import {initInteraction, pipe} from "../interaction/interaction.js" -import * as ixModule from "../interaction/interaction.js" +import {initInteraction, pipe} from "../interaction/interaction" +import * as ixModule from "../interaction/interaction" import {invariant} from "../build/build-invariant.js" import {response} from "../response/response.js" import {config} from "@onflow/config" From ac04e6bab158be393ac7327eebbf8a7e31c4b143 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:53:40 -0400 Subject: [PATCH 21/45] fixed tests --- packages/sdk/src/build/build-at-block-height.test.js | 4 ++-- packages/sdk/src/build/build-at-block-id.test.js | 4 ++-- packages/sdk/src/build/build-authorizations.test.js | 4 ++-- packages/sdk/src/build/build-get-account.test.js | 6 +++--- packages/sdk/src/build/build-get-block-header.test.js | 6 +++--- packages/sdk/src/build/build-get-block.test.js | 6 +++--- packages/sdk/src/build/build-get-collection.test.js | 4 ++-- .../build/build-get-events-at-block-height-range.test.js | 4 ++-- .../sdk/src/build/build-get-events-at-block-ids.test.js | 4 ++-- packages/sdk/src/build/build-get-network-parameters.test.js | 4 ++-- packages/sdk/src/build/build-get-transaction-status.test.js | 4 ++-- packages/sdk/src/build/build-get-transaction.test.js | 4 ++-- packages/sdk/src/build/build-limit.test.js | 4 ++-- packages/sdk/src/build/build-payer.test.js | 4 ++-- packages/sdk/src/build/build-ping.test.js | 4 ++-- packages/sdk/src/build/build-proposer.test.js | 4 ++-- packages/sdk/src/build/build-ref.test.js | 4 ++-- packages/sdk/src/build/build-script.test.js | 4 ++-- packages/sdk/src/build/build-transaction.test.js | 4 ++-- packages/sdk/src/build/build-voucher-intercept.test.js | 4 ++-- 20 files changed, 43 insertions(+), 43 deletions(-) diff --git a/packages/sdk/src/build/build-at-block-height.test.js b/packages/sdk/src/build/build-at-block-height.test.js index 9ba776184..d30830bc1 100644 --- a/packages/sdk/src/build/build-at-block-height.test.js +++ b/packages/sdk/src/build/build-at-block-height.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {atBlockHeight} from "./build-at-block-height.js" describe("Build At Block ID", () => { test("At Block ID", async () => { const blockHeight = 123 - const ix = await atBlockHeight(blockHeight)(interaction()) + const ix = await atBlockHeight(blockHeight)(initInteraction()) expect(ix.block.height).toBe(blockHeight) }) diff --git a/packages/sdk/src/build/build-at-block-id.test.js b/packages/sdk/src/build/build-at-block-id.test.js index edc119cc5..71738f04b 100644 --- a/packages/sdk/src/build/build-at-block-id.test.js +++ b/packages/sdk/src/build/build-at-block-id.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {atBlockId} from "./build-at-block-id.js" describe("Build At Block ID", () => { test("At Block ID", async () => { const blockId = "abc123" - const ix = await atBlockId(blockId)(interaction()) + const ix = await atBlockId(blockId)(initInteraction()) expect(ix.block.id).toBe(blockId) }) diff --git a/packages/sdk/src/build/build-authorizations.test.js b/packages/sdk/src/build/build-authorizations.test.js index cc85d33f9..6357f0b9b 100644 --- a/packages/sdk/src/build/build-authorizations.test.js +++ b/packages/sdk/src/build/build-authorizations.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {authorizations, authorization} from "./build-authorizations.js" describe("Build Authorizations", () => { @@ -7,7 +7,7 @@ describe("Build Authorizations", () => { await authorizations([ authorization("0xabc123", () => ({signature: "123"}), 1, 123), ]) - )(interaction()) + )(initInteraction()) const authorizerAccount = ix.accounts[ix.authorizations] diff --git a/packages/sdk/src/build/build-get-account.test.js b/packages/sdk/src/build/build-get-account.test.js index 19695492f..125d328df 100644 --- a/packages/sdk/src/build/build-get-account.test.js +++ b/packages/sdk/src/build/build-get-account.test.js @@ -1,4 +1,4 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {sansPrefix, withPrefix} from "@onflow/util-address" import {getAccount} from "./build-get-account.js" @@ -7,14 +7,14 @@ const ADDRESS = "0xf117a8efa34ffd58" describe("address as input", () => { test("sansPrefix", async () => { const addr = sansPrefix(ADDRESS) - const result = await getAccount(addr)(interaction()) + const result = await getAccount(addr)(initInteraction()) expect(result.account.addr).toBe(sansPrefix(ADDRESS)) }) test("withPrefix", async () => { const addr = withPrefix(ADDRESS) - const result = await getAccount(addr)(interaction()) + const result = await getAccount(addr)(initInteraction()) expect(result.account.addr).toBe(sansPrefix(ADDRESS)) }) diff --git a/packages/sdk/src/build/build-get-block-header.test.js b/packages/sdk/src/build/build-get-block-header.test.js index ea89714d5..b82e09dfa 100644 --- a/packages/sdk/src/build/build-get-block-header.test.js +++ b/packages/sdk/src/build/build-get-block-header.test.js @@ -1,11 +1,11 @@ -import {interaction, isGetBlockHeader} from "../interaction/interaction" +import {initInteraction, isGetBlockHeader} from "../interaction/interaction" import {getBlockHeader} from "./build-get-block-header.js" describe("Build Get Block Header", () => { test("Get Block Header, isSealed = false", async () => { const isSealed = false - const ix = await getBlockHeader(isSealed)(interaction()) + const ix = await getBlockHeader(isSealed)(initInteraction()) expect(isGetBlockHeader(ix)).toBe(true) expect(ix.block.isSealed).toEqual(isSealed) @@ -14,7 +14,7 @@ describe("Build Get Block Header", () => { test("Get Block Header, isSealed = true", async () => { const isSealed = true - const ix = await getBlockHeader(isSealed)(interaction()) + const ix = await getBlockHeader(isSealed)(initInteraction()) expect(isGetBlockHeader(ix)).toBe(true) expect(ix.block.isSealed).toEqual(isSealed) diff --git a/packages/sdk/src/build/build-get-block.test.js b/packages/sdk/src/build/build-get-block.test.js index 9b157d4be..7d43a19f2 100644 --- a/packages/sdk/src/build/build-get-block.test.js +++ b/packages/sdk/src/build/build-get-block.test.js @@ -1,11 +1,11 @@ -import {interaction, isGetBlock} from "../interaction/interaction" +import {initInteraction, isGetBlock} from "../interaction/interaction" import {getBlock} from "./build-get-block.js" describe("Build Get Block", () => { test("Get Block - isSealed = false", async () => { const isSealed = false - const ix = await getBlock(isSealed)(interaction()) + const ix = await getBlock(isSealed)(initInteraction()) expect(isGetBlock(ix)).toBe(true) expect(ix.block.isSealed).toBe(false) @@ -14,7 +14,7 @@ describe("Build Get Block", () => { test("Get Block - isSealed = false", async () => { const isSealed = true - const ix = await getBlock(isSealed)(interaction()) + const ix = await getBlock(isSealed)(initInteraction()) expect(isGetBlock(ix)).toBe(true) expect(ix.block.isSealed).toBe(true) diff --git a/packages/sdk/src/build/build-get-collection.test.js b/packages/sdk/src/build/build-get-collection.test.js index 207b097e5..8f227c893 100644 --- a/packages/sdk/src/build/build-get-collection.test.js +++ b/packages/sdk/src/build/build-get-collection.test.js @@ -1,11 +1,11 @@ -import {interaction, isGetCollection} from "../interaction/interaction" +import {initInteraction, isGetCollection} from "../interaction/interaction" import {getCollection} from "./build-get-collection.js" describe("Build Get Collection", () => { test("Get Collection", async () => { const collectionId = "my-collection-id" - const ix = await getCollection(collectionId)(interaction()) + const ix = await getCollection(collectionId)(initInteraction()) expect(isGetCollection(ix)).toBe(true) expect(ix.collection.id).toBe(collectionId) diff --git a/packages/sdk/src/build/build-get-events-at-block-height-range.test.js b/packages/sdk/src/build/build-get-events-at-block-height-range.test.js index ae3e5c5db..06a9e0d08 100644 --- a/packages/sdk/src/build/build-get-events-at-block-height-range.test.js +++ b/packages/sdk/src/build/build-get-events-at-block-height-range.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetEvents} from "../interaction/interaction" +import {initInteraction, isGetEvents} from "../interaction/interaction" import {getEventsAtBlockHeightRange} from "./build-get-events-at-block-height-range.js" describe("Build Get Events At Block Height Range", () => { @@ -11,7 +11,7 @@ describe("Build Get Events At Block Height Range", () => { eventName, start, end - )(interaction()) + )(initInteraction()) expect(isGetEvents(ix)).toBe(true) expect(ix.events.eventType).toBe(eventName) diff --git a/packages/sdk/src/build/build-get-events-at-block-ids.test.js b/packages/sdk/src/build/build-get-events-at-block-ids.test.js index 2c6d3e2cb..84f07a281 100644 --- a/packages/sdk/src/build/build-get-events-at-block-ids.test.js +++ b/packages/sdk/src/build/build-get-events-at-block-ids.test.js @@ -1,4 +1,4 @@ -import {interaction, isGetEvents} from "../interaction/interaction" +import {initInteraction, isGetEvents} from "../interaction/interaction" import {getEventsAtBlockIds} from "./build-get-events-at-block-ids.js" describe("Build Get Events At Block Ids", () => { @@ -6,7 +6,7 @@ describe("Build Get Events At Block Ids", () => { const eventName = "MyEvent" const blockIds = ["abc", "123"] - let ix = await getEventsAtBlockIds(eventName, blockIds)(interaction()) + let ix = await getEventsAtBlockIds(eventName, blockIds)(initInteraction()) expect(isGetEvents(ix)).toBe(true) expect(ix.events.eventType).toBe(eventName) diff --git a/packages/sdk/src/build/build-get-network-parameters.test.js b/packages/sdk/src/build/build-get-network-parameters.test.js index 52d09008f..ef46a6ce8 100644 --- a/packages/sdk/src/build/build-get-network-parameters.test.js +++ b/packages/sdk/src/build/build-get-network-parameters.test.js @@ -1,12 +1,12 @@ import { - interaction, + initInteraction, isGetNetworkParameters, } from "../interaction/interaction" import {getNetworkParameters} from "./build-get-network-parameters.js" describe("Build Get Network Parameters", () => { test("Get Network Parameters", async () => { - let ix = await getNetworkParameters()(interaction()) + let ix = await getNetworkParameters()(initInteraction()) expect(isGetNetworkParameters(ix)).toBe(true) }) diff --git a/packages/sdk/src/build/build-get-transaction-status.test.js b/packages/sdk/src/build/build-get-transaction-status.test.js index e01a32035..75496b8fe 100644 --- a/packages/sdk/src/build/build-get-transaction-status.test.js +++ b/packages/sdk/src/build/build-get-transaction-status.test.js @@ -1,5 +1,5 @@ import { - interaction, + initInteraction, isGetTransactionStatus, } from "../interaction/interaction" import {getTransactionStatus} from "./build-get-transaction-status.js" @@ -8,7 +8,7 @@ describe("Build Get Transaction Status", () => { test("Get Transaction Status", async () => { const transactionId = "abc123" - let ix = await getTransactionStatus(transactionId)(interaction()) + let ix = await getTransactionStatus(transactionId)(initInteraction()) expect(isGetTransactionStatus(ix)).toBe(true) expect(ix.transaction.id).toBe(transactionId) diff --git a/packages/sdk/src/build/build-get-transaction.test.js b/packages/sdk/src/build/build-get-transaction.test.js index 053228f29..da9a22e4d 100644 --- a/packages/sdk/src/build/build-get-transaction.test.js +++ b/packages/sdk/src/build/build-get-transaction.test.js @@ -1,11 +1,11 @@ -import {interaction, isGetTransaction} from "../interaction/interaction" +import {initInteraction, isGetTransaction} from "../interaction/interaction" import {getTransaction} from "./build-get-transaction.js" describe("Build Get Transaction", () => { test("Get Transaction", async () => { const transactionId = "abc123" - let ix = await getTransaction(transactionId)(interaction()) + let ix = await getTransaction(transactionId)(initInteraction()) expect(isGetTransaction(ix)).toBe(true) expect(ix.transaction.id).toBe(transactionId) diff --git a/packages/sdk/src/build/build-limit.test.js b/packages/sdk/src/build/build-limit.test.js index 78c9582e7..31d603760 100644 --- a/packages/sdk/src/build/build-limit.test.js +++ b/packages/sdk/src/build/build-limit.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {limit} from "./build-limit.js" describe("Build Limit", () => { test("Build Limit", async () => { const txLimit = 100 - let ix = await limit(txLimit)(interaction()) + let ix = await limit(txLimit)(initInteraction()) expect(ix.message.computeLimit).toEqual(txLimit) }) diff --git a/packages/sdk/src/build/build-payer.test.js b/packages/sdk/src/build/build-payer.test.js index e8853b06b..a60295323 100644 --- a/packages/sdk/src/build/build-payer.test.js +++ b/packages/sdk/src/build/build-payer.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {payer} from "./build-payer.js" describe("Build Payer", () => { test("Build Payer", async () => { const authz = {addr: "0xabc123"} - let ix = await (await payer(authz))(interaction()) + let ix = await (await payer(authz))(initInteraction()) const payerAccount = ix.accounts[ix.payer] diff --git a/packages/sdk/src/build/build-ping.test.js b/packages/sdk/src/build/build-ping.test.js index 3e21c3fe1..97179a32a 100644 --- a/packages/sdk/src/build/build-ping.test.js +++ b/packages/sdk/src/build/build-ping.test.js @@ -1,9 +1,9 @@ -import {interaction, isPing} from "../interaction/interaction" +import {initInteraction, isPing} from "../interaction/interaction" import {ping} from "./build-ping.js" describe("Build Ping", () => { test("Build Ping", async () => { - let ix = await ping()(interaction()) + let ix = await ping()(initInteraction()) expect(isPing(ix)).toBe(true) }) diff --git a/packages/sdk/src/build/build-proposer.test.js b/packages/sdk/src/build/build-proposer.test.js index 60eae30fe..7d1972f3b 100644 --- a/packages/sdk/src/build/build-proposer.test.js +++ b/packages/sdk/src/build/build-proposer.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {proposer} from "./build-proposer.js" describe("Build Proposer", () => { test("Build Proposer", async () => { const authz = {addr: "0xabc123"} - let ix = await (await proposer(authz))(interaction()) + let ix = await (await proposer(authz))(initInteraction()) const proposerAccount = ix.accounts[ix.proposer] diff --git a/packages/sdk/src/build/build-ref.test.js b/packages/sdk/src/build/build-ref.test.js index d9e26b2b5..2a6919636 100644 --- a/packages/sdk/src/build/build-ref.test.js +++ b/packages/sdk/src/build/build-ref.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {ref} from "./build-ref.js" describe("Build Ref", () => { test("Build Ref", async () => { const refBlockId = "abc123" - let ix = await ref(refBlockId)(interaction()) + let ix = await ref(refBlockId)(initInteraction()) expect(ix.message.refBlock).toEqual(refBlockId) }) diff --git a/packages/sdk/src/build/build-script.test.js b/packages/sdk/src/build/build-script.test.js index ce69c14c4..576e16229 100644 --- a/packages/sdk/src/build/build-script.test.js +++ b/packages/sdk/src/build/build-script.test.js @@ -1,11 +1,11 @@ -import {interaction, isScript} from "../interaction/interaction" +import {initInteraction, isScript} from "../interaction/interaction" import {script} from "./build-script.js" describe("Build Script", () => { test("Build Script", async () => { const cadence = "pub fun main(): Int { return 123 }" - let ix = await script(cadence)(interaction()) + let ix = await script(cadence)(initInteraction()) expect(isScript(ix)).toBe(true) expect(ix.assigns["ix.cadence"]).not.toBeUndefined() diff --git a/packages/sdk/src/build/build-transaction.test.js b/packages/sdk/src/build/build-transaction.test.js index 4904bb44c..e64ae28c5 100644 --- a/packages/sdk/src/build/build-transaction.test.js +++ b/packages/sdk/src/build/build-transaction.test.js @@ -1,11 +1,11 @@ -import {interaction, isTransaction} from "../interaction/interaction" +import {initInteraction, isTransaction} from "../interaction/interaction" import {transaction} from "./build-transaction.js" describe("Build Transaction", () => { test("Build Transaction", async () => { const cadence = "transaction { increaseMyBallerStatus() }" - let ix = await transaction(cadence)(interaction()) + let ix = await transaction(cadence)(initInteraction()) expect(isTransaction(ix)).toBe(true) expect(ix.assigns["ix.cadence"]).not.toBeUndefined() diff --git a/packages/sdk/src/build/build-voucher-intercept.test.js b/packages/sdk/src/build/build-voucher-intercept.test.js index 99e264d07..91a9129ff 100644 --- a/packages/sdk/src/build/build-voucher-intercept.test.js +++ b/packages/sdk/src/build/build-voucher-intercept.test.js @@ -1,11 +1,11 @@ -import {interaction} from "../interaction/interaction" +import {initInteraction} from "../interaction/interaction" import {voucherIntercept} from "./build-voucher-intercept" describe("Build voucherIntercept", () => { test("Build voucherIntercept", async () => { const checkFunc = async () => "test func" - const ix = await voucherIntercept(checkFunc)(interaction()) + const ix = await voucherIntercept(checkFunc)(initInteraction()) expect(ix.assigns["ix.voucher-intercept"]).toEqual(checkFunc) }) From 8662e4ab9a2203af7088790b3b652d8c0d3c1c58 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:38:00 -0400 Subject: [PATCH 22/45] fix paths --- .../sdk/src/resolve/resolve-cadence.test.js | 18 +++++++++--------- .../src/resolve/resolve-compute-limit.test.js | 6 +++--- .../resolve-proposer-sequence-number.js | 2 +- .../sdk/src/resolve/resolve-ref-block-id.js | 2 +- packages/sdk/src/resolve/resolve.js | 2 +- packages/sdk/src/sdk.ts | 2 +- packages/sdk/src/send/send.js | 2 +- packages/transport-http/src/sdk-send-http.ts | 4 ++-- packages/transport-http/src/send-ping.test.ts | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/sdk/src/resolve/resolve-cadence.test.js b/packages/sdk/src/resolve/resolve-cadence.test.js index 43763a241..086449d61 100644 --- a/packages/sdk/src/resolve/resolve-cadence.test.js +++ b/packages/sdk/src/resolve/resolve-cadence.test.js @@ -1,4 +1,4 @@ -import {interaction, pipe, put, makeScript} from "../interaction/interaction" +import {initInteraction, pipe, put, makeScript} from "../interaction/interaction" import {resolveCadence} from "./resolve-cadence.js" import {config} from "@onflow/config" @@ -13,7 +13,7 @@ describe("resolveCadence", () => { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toBe(CADENCE) }) @@ -27,7 +27,7 @@ describe("resolveCadence", () => { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toBe(await CADENCE()) }) @@ -59,7 +59,7 @@ describe("resolveCadence", () => { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(await RESULT()) }) @@ -111,7 +111,7 @@ describe("resolveCadence", () => { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(await RESULT()) }) @@ -138,7 +138,7 @@ pub fun main(): Address { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(expected) }) @@ -165,7 +165,7 @@ pub fun main(): Address { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(expected) }) @@ -193,7 +193,7 @@ pub fun main(): Address { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(expected) }) @@ -218,7 +218,7 @@ pub fun main(): Address { makeScript, put("ix.cadence", CADENCE), resolveCadence, - ])(interaction()) + ])(initInteraction()) expect(ix.message.cadence).toEqual(expected) }) diff --git a/packages/sdk/src/resolve/resolve-compute-limit.test.js b/packages/sdk/src/resolve/resolve-compute-limit.test.js index a976e37f8..286116132 100644 --- a/packages/sdk/src/resolve/resolve-compute-limit.test.js +++ b/packages/sdk/src/resolve/resolve-compute-limit.test.js @@ -1,4 +1,4 @@ -import {interaction, pipe, makeTransaction} from "../interaction/interaction" +import {initInteraction, pipe, makeTransaction} from "../interaction/interaction" import {config} from "@onflow/config" import {resolveComputeLimit} from "./resolve-compute-limit.js" @@ -21,7 +21,7 @@ describe("resolveComputeLimit", () => { }, }), resolveComputeLimit, - ])(interaction()) + ])(initInteraction()) expect(ix.message.computeLimit).toBe(TRANSACTION_COMPUTE_LIMIT) } @@ -36,7 +36,7 @@ describe("resolveComputeLimit", () => { }, async () => { const ix = await pipe([makeTransaction, resolveComputeLimit])( - interaction() + initInteraction() ) expect(ix.message.computeLimit).toBe(CONFIG_COMPUTE_LIMIT) } diff --git a/packages/sdk/src/resolve/resolve-proposer-sequence-number.js b/packages/sdk/src/resolve/resolve-proposer-sequence-number.js index 92148d188..4ec55db77 100644 --- a/packages/sdk/src/resolve/resolve-proposer-sequence-number.js +++ b/packages/sdk/src/resolve/resolve-proposer-sequence-number.js @@ -1,6 +1,6 @@ import {isTransaction, Ok} from "../interaction/interaction" import * as ixModule from "../interaction/interaction" -import {response as responseModule} from "../response/response.js" +import {response as responseModule} from "../response/response" import {config} from "@onflow/config" import {decodeResponse} from "../decode/decode.js" import {getAccount} from "../build/build-get-account.js" diff --git a/packages/sdk/src/resolve/resolve-ref-block-id.js b/packages/sdk/src/resolve/resolve-ref-block-id.js index 26dd7e706..0a11e1c86 100644 --- a/packages/sdk/src/resolve/resolve-ref-block-id.js +++ b/packages/sdk/src/resolve/resolve-ref-block-id.js @@ -5,7 +5,7 @@ import { pipe, } from "../interaction/interaction" import * as ixModule from "../interaction/interaction" -import {response} from "../response/response.js" +import {response} from "../response/response" import {config} from "@onflow/config" import {decodeResponse} from "../decode/decode.js" import {getBlock} from "../build/build-get-block.js" diff --git a/packages/sdk/src/resolve/resolve.js b/packages/sdk/src/resolve/resolve.js index 50728726a..4fa5fd526 100644 --- a/packages/sdk/src/resolve/resolve.js +++ b/packages/sdk/src/resolve/resolve.js @@ -4,7 +4,7 @@ import {invariant} from "@onflow/util-invariant" import {Buffer} from "@onflow/rlp" import {send as defaultSend} from "@onflow/transport-http" import * as ixModule from "../interaction/interaction" -import {response} from "../response/response.js" +import {response} from "../response/response" import {build} from "../build/build.js" import {getBlock} from "../build/build-get-block.js" import {getAccount} from "../build/build-get-account.js" diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 7e391b28f..46f0858cd 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -75,7 +75,7 @@ export {resolveFinalNormalization} from "./resolve/resolve-final-normalization" export {resolveProposerSequenceNumber} from "./resolve/resolve-proposer-sequence-number" export {resolveArguments} from "./resolve/resolve-arguments.js" export {resolveAccounts} from "./resolve/resolve-accounts.js" -export {response} from "./response/response.js" +export {response} from "./response/response" export {resolveSignatures} from "./resolve/resolve-signatures.js" export {resolveValidators} from "./resolve/resolve-validators.js" export {resolveRefBlockId} from "./resolve/resolve-ref-block-id.js" diff --git a/packages/sdk/src/send/send.js b/packages/sdk/src/send/send.js index 55676da12..e2baf17c6 100644 --- a/packages/sdk/src/send/send.js +++ b/packages/sdk/src/send/send.js @@ -3,7 +3,7 @@ import {send as defaultSend} from "@onflow/transport-http" import {initInteraction, pipe} from "../interaction/interaction" import * as ixModule from "../interaction/interaction" import {invariant} from "../build/build-invariant.js" -import {response} from "../response/response.js" +import {response} from "../response/response" import {config} from "@onflow/config" import {resolve as defaultResolve} from "../resolve/resolve.js" diff --git a/packages/transport-http/src/sdk-send-http.ts b/packages/transport-http/src/sdk-send-http.ts index 35a8edf65..6778d25bf 100644 --- a/packages/transport-http/src/sdk-send-http.ts +++ b/packages/transport-http/src/sdk-send-http.ts @@ -6,7 +6,7 @@ export {sendGetCollection} from "./send-get-collection.js" export {sendGetEvents} from "./send-get-events.js" export {sendGetTransaction} from "./send-get-transaction.js" export {sendGetTransactionStatus} from "./send-get-transaction-status.js" -export {sendPing} from "./send-ping.js" +export {sendPing} from "./send-ping" export {sendTransaction} from "./send-transaction.js" export {sendGetNetworkParameters} from "./send-get-network-parameters.js" -export {send} from "./send-http.js" +export {send} from "./send-http" diff --git a/packages/transport-http/src/send-ping.test.ts b/packages/transport-http/src/send-ping.test.ts index bfef942fa..de4fa3181 100644 --- a/packages/transport-http/src/send-ping.test.ts +++ b/packages/transport-http/src/send-ping.test.ts @@ -1,4 +1,4 @@ -import {sendPing} from "./send-ping.js" +import {sendPing} from "./send-ping" import {Buffer} from "@onflow/rlp" import {build, ping, resolve, response as responseADT} from "@onflow/sdk" From 9783a33b59b0ded50a199476bc0ce8891b984cb5 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:55:44 -0400 Subject: [PATCH 23/45] fix path --- packages/sdk/readme.md | 2 +- packages/sdk/src/sdk.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sdk/readme.md b/packages/sdk/readme.md index 18feeb02e..65bef283a 100644 --- a/packages/sdk/readme.md +++ b/packages/sdk/readme.md @@ -497,7 +497,7 @@ const response = await sdk.send(await sdk.build([ - [Builders](./src/build) - - [`sdk.args` & `sdk.arg`](./src/build/build-arguments.js) + - [`sdk.args` & `sdk.arg`](./src/build/build-arguments) - [`sdk.atBlockHeight`](./src/build/build-at-block-height.js) - [`sdk.atBlockId`](./src/build/build-at-block-id.js) - [`sdk.authorizations` & `authorization`](./src/build/build-authorizations.js) diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 46f0858cd..51b80f9d4 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -58,7 +58,7 @@ export {getTransactionStatus} from "./build/build-get-transaction-status.js" export {getTransaction} from "./build/build-get-transaction.js" export {getNetworkParameters} from "./build/build-get-network-parameters.js" export {limit} from "./build/build-limit.js" -export {args, arg} from "./build/build-arguments.js" +export {args, arg} from "./build/build-arguments" export {proposer} from "./build/build-proposer.js" export {payer} from "./build/build-payer.js" export {ping} from "./build/build-ping.js" From e1110136685075012ec4619a1b433a1e5a4b651d Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:31:22 -0400 Subject: [PATCH 24/45] fix some tests --- packages/sdk/src/contract.test.js | 3 ++- .../{response.test.js.snap => response.test.ts.snap} | 0 packages/transport-http/.babelrc | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) rename packages/sdk/src/response/__snapshots__/{response.test.js.snap => response.test.ts.snap} (100%) diff --git a/packages/sdk/src/contract.test.js b/packages/sdk/src/contract.test.js index 57c4b5d9d..5f272a731 100644 --- a/packages/sdk/src/contract.test.js +++ b/packages/sdk/src/contract.test.js @@ -9,6 +9,7 @@ const interfaceContract = (label, wat) => ([template]) => { const keys = template.replace(/\s+/g, "|").split("|").filter(Boolean) + console.log({keys}) describe(label, () => { for (let key of keys) @@ -43,7 +44,7 @@ describe("consume", () => { ` interfaceContract("@onflow/interaction", interaction)` - interaction + initInteraction pipe Ok isOk isBad why put get update makeGetAccount makeGetEvents diff --git a/packages/sdk/src/response/__snapshots__/response.test.js.snap b/packages/sdk/src/response/__snapshots__/response.test.ts.snap similarity index 100% rename from packages/sdk/src/response/__snapshots__/response.test.js.snap rename to packages/sdk/src/response/__snapshots__/response.test.ts.snap diff --git a/packages/transport-http/.babelrc b/packages/transport-http/.babelrc index 67fc2886b..1e3225d50 100644 --- a/packages/transport-http/.babelrc +++ b/packages/transport-http/.babelrc @@ -1,7 +1,11 @@ { "presets": [ [ - "@babel/preset-env" - ] + "@babel/preset-env", + { + "useBuiltIns": false + } + ], + "@babel/preset-typescript" ] } From 503adedcdd5011152fc8f30ddb74cbf9f6446ff5 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:04:03 -0400 Subject: [PATCH 25/45] clean console log --- packages/sdk/src/contract.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sdk/src/contract.test.js b/packages/sdk/src/contract.test.js index 5f272a731..4a9001db4 100644 --- a/packages/sdk/src/contract.test.js +++ b/packages/sdk/src/contract.test.js @@ -9,7 +9,6 @@ const interfaceContract = (label, wat) => ([template]) => { const keys = template.replace(/\s+/g, "|").split("|").filter(Boolean) - console.log({keys}) describe(label, () => { for (let key of keys) From 7c28b15e2372361374064618f6152f9171afb0ee Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:13:30 -0400 Subject: [PATCH 26/45] fix logic --- packages/sdk/src/interaction/interaction.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index 5acd4fe46..ef54336fe 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -118,7 +118,7 @@ const makeIx = (wat: string) => (ix: IIx) => { return Ok(ix) } -const prepAccountKeyId = (acct: IAcct | IAcctFn): IAcct | IAcctFn => { +const prepAccountKeyId = (acct: Partial | IAcctFn): Partial | IAcctFn => { if (acct.keyId == null) return acct invariant(!isNaN(parseInt(acct.keyId.toString())), "account.keyId must be an integer") @@ -130,12 +130,12 @@ const prepAccountKeyId = (acct: IAcct | IAcctFn): IAcct | IAcctFn => { } interface IPrepAccountOpts { - role: string | null + role?: string | null } export const initAccount = (): IAcct => JSON.parse(ACCT) -export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {role: null}) => (ix: IIx) => { +export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) => (ix: IIx) => { invariant( typeof acct === "function" || typeof acct === "object", "prepAccount must be passed an authorization function or an account object" @@ -147,22 +147,23 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {rol const tempId = uuidv4() if (acct.authorization && isFn(acct.authorization)) - acct = {...ACCOUNT, resolve: acct.authorization} - if (!acct.authorization && isFn(acct)) acct = {...ACCOUNT, resolve: acct} + account = {resolve: acct.authorization} + if (!acct.authorization && isFn(acct)) account = {resolve: acct} - const resolve = acct.resolve - if (resolve) - acct.resolve = (acct: IAcct, ...rest: any[]) => + const resolve = account.resolve + if (resolve) { + account.resolve = (acct: IAcct, ...rest: any[]) => [resolve, prepAccountKeyId].reduce( async (d, fn) => fn(await d, ...rest), acct ) - acct = prepAccountKeyId(acct) + } + account = prepAccountKeyId(account) ix.accounts[tempId] = { ...ACCOUNT, tempId, - ...acct, + ...account, role: { ...ACCOUNT.role, ...(typeof acct.role === "object" ? acct.role : {}), From 3ce27e25f824ea3434767520fabd9fd52d892920 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:10:00 -0400 Subject: [PATCH 27/45] addressing PR comments --- packages/sdk/TRANSITIONS.md | 17 +++++++++++++++ packages/sdk/src/interaction/interaction.ts | 24 +++++++++++++++++---- packages/sdk/src/sdk.ts | 2 +- packages/transport-http/package.json | 2 +- packages/transport-http/src/send-http.ts | 2 +- packages/transport-http/src/send-ping.ts | 6 +++--- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/packages/sdk/TRANSITIONS.md b/packages/sdk/TRANSITIONS.md index 7d200aae0..ae9621c2e 100644 --- a/packages/sdk/TRANSITIONS.md +++ b/packages/sdk/TRANSITIONS.md @@ -1,5 +1,22 @@ # Transitions +## 0010 Deprecate interaction + +- **Date:** Sept 25th 2023 +- **Type:** Deprecation of interaction method + +The "interaction" method has been deprecated and will be removed in future versions. + +Please update your code to use the "initInteraction" method for improved functionality and compatibility. + +```javascript + // Deprecated: + const result = interaction(); + + // Recommended: + const result = initInteraction(); +``` + ## 0009 Deprecate default compute limit - **Date:** Jun 7th 2022 diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index ef54336fe..704395501 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -1,5 +1,6 @@ import {invariant} from "@onflow/util-invariant" import {v4 as uuidv4} from "uuid" +import {log, LEVELS} from "@onflow/util-logger" import { IAcct, ACCOUNT, PARAM, ARGUMENT, UNKNOWN, OK, IIx, AUTHORIZER, PAYER, SCRIPT, TRANSACTION, GET_TRANSACTION_STATUS, GET_TRANSACTION, GET_ACCOUNT, GET_EVENTS, PING, GET_BLOCK, GET_BLOCK_HEADER, GET_COLLECTION, GET_NETWORK_PARAMETERS, BAD, PROPOSER } from "@onflow/typedefs"; @@ -88,7 +89,21 @@ const IX = `{ const KEYS = new Set(Object.keys(JSON.parse(IX) as IIx)) + export const initInteraction = (): IIx => JSON.parse(IX) +/** + * @deprecated + */ +export const interaction = () => { + log.deprecate({ + pkg: "FCL/SDK", + message: `The interaction been deprecated from the Flow JS-SDK/FCL. use initInteraction instead`, + transition: + "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0010-deprecate-interaction", + level: LEVELS.warn, + }) + return initInteraction() +} export const isNumber = d => typeof d === "number" export const isArray = d => Array.isArray(d) @@ -130,7 +145,7 @@ const prepAccountKeyId = (acct: Partial | IAcctFn): Partial | IAcc } interface IPrepAccountOpts { - role?: string | null + role?: typeof AUTHORIZER | typeof PAYER | typeof PROPOSER | null } export const initAccount = (): IAcct => JSON.parse(ACCT) @@ -145,6 +160,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) const ACCOUNT = initAccount() const role = opts.role const tempId = uuidv4() + let account: Partial = acct if (acct.authorization && isFn(acct.authorization)) account = {resolve: acct.authorization} @@ -167,7 +183,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) role: { ...ACCOUNT.role, ...(typeof acct.role === "object" ? acct.role : {}), - [role]: true, + ...(role ? {[role]: true} : {}), }, } @@ -175,7 +191,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) ix.authorizations.push(tempId) } else if (role === PAYER) { ix.payer.push(tempId) - } else { + } else if (role) { ix[role] = tempId } @@ -265,7 +281,7 @@ export const pipe = (...args: any[]) => { return recPipe(arg1, arg2) } -const identity = (v: any, ..._: any[]) => v +const identity = (v: T, ..._: any[]) => v export const get = (ix: IIx, key: string, fallback: any) => { return ix.assigns[key] == null ? fallback : ix.assigns[key] diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 51b80f9d4..769188d47 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -11,7 +11,7 @@ export { } from "./encode/encode" // Utils export { - initInteraction as interaction, // deprecated + interaction, // deprecated initInteraction, isOk, isBad, diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index 5e7c915c0..ce5441f0b 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -23,7 +23,7 @@ "main": "dist/sdk-send-http.js", "module": "dist/sdk-send-http.module.js", "unpkg": "dist/sdk-send-http.umd.js", - "types": "dist/types/sdk-send-http.d.ts", + "types": "dist/sdk-send-http.d.ts", "scripts": { "alpha": "npm publish --tag alpha", "prepublishOnly": "npm test && npm run build", diff --git a/packages/transport-http/src/send-http.ts b/packages/transport-http/src/send-http.ts index 72618f52e..918601a78 100644 --- a/packages/transport-http/src/send-http.ts +++ b/packages/transport-http/src/send-http.ts @@ -8,7 +8,7 @@ import {sendGetEvents} from "./send-get-events.js" import {sendGetBlock} from "./send-get-block.js" import {sendGetBlockHeader} from "./send-get-block-header.js" import {sendGetCollection} from "./send-get-collection.js" -import {sendPing, IContext as ISendPingContext} from "./send-ping" +import {sendPing, ISendPingContext} from "./send-ping" import {sendGetNetworkParameters} from "./send-get-network-parameters.js" import { IIx } from "@onflow/typedefs" diff --git a/packages/transport-http/src/send-ping.ts b/packages/transport-http/src/send-ping.ts index b047bea4f..da44d3570 100644 --- a/packages/transport-http/src/send-ping.ts +++ b/packages/transport-http/src/send-ping.ts @@ -2,17 +2,17 @@ import {invariant} from "@onflow/util-invariant" import {httpRequest as defaultHttpRequest} from "./http-request.js" import { IIx } from "@onflow/typedefs"; -export interface IContext { +export interface ISendPingContext { response?: Function; } -export interface IOpts { +interface ISendPingOpts { node?: string httpRequest?: any, } -export async function sendPing(ix: IIx, context: IContext = {}, opts: IOpts = {}) { +export async function sendPing(ix: IIx, context: ISendPingContext = {}, opts: ISendPingOpts = {}) { invariant(Boolean(opts.node), `SDK Send Ping Error: opts.node must be defined.`) invariant( Boolean(context.response), From 3aca2d34c39d2d773c3aceeed9365158ee27c899 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:24:14 -0400 Subject: [PATCH 28/45] fix build arguments --- packages/sdk/src/build/build-arguments.ts | 6 +++++- packages/types/src/types.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/build/build-arguments.ts b/packages/sdk/src/build/build-arguments.ts index 9ff273f26..7b9ba8fc5 100644 --- a/packages/sdk/src/build/build-arguments.ts +++ b/packages/sdk/src/build/build-arguments.ts @@ -1,4 +1,5 @@ import {pipe, makeArgument} from "../interaction/interaction" +import {TypeDescriptorInput, TypeDescriptor} from "@onflow/types" /** * @description - A utility builder to be used with other builders to pass in arguments with a value and supported type @@ -15,6 +16,9 @@ export function args(ax = []) { * @param {Function} xform - A function to transform the value * @returns {object} - An argument object */ -export function arg(value: any, xform: any) { +export function arg>(value: TypeDescriptorInput, xform: T) { return {value, xform} } diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index cc392f607..9617d6993 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -18,7 +18,7 @@ export interface TypeDescriptor> { asInjection: (x: T) => T } -type TypeDescriptorInput< +export type TypeDescriptorInput< X extends TypeDescriptor> > = X extends TypeDescriptor> ? T : never From 79a34d531117084c29c289b2ad421d7b6bcd519c Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:30:27 -0400 Subject: [PATCH 29/45] shallow copy acct --- packages/sdk/src/interaction/interaction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index 704395501..f4c73c4d9 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -160,7 +160,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) const ACCOUNT = initAccount() const role = opts.role const tempId = uuidv4() - let account: Partial = acct + let account: Partial = {...acct} if (acct.authorization && isFn(acct.authorization)) account = {resolve: acct.authorization} From 31b7122bfb58b00d78716fa60803f9ee4cfe5f75 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:58:40 -0400 Subject: [PATCH 30/45] convert encode --- .../fcl/src/wallet-provider-spec/draft-v3.md | 2 +- .../fcl/src/wallet-provider-spec/draft-v4.md | 2 +- packages/rlp/src/index.ts | 2 +- packages/sdk/readme.md | 2 +- packages/sdk/src/contract.test.js | 2 +- packages/sdk/src/encode/encode.test.js | 4 +- .../sdk/src/encode/{encode.js => encode.ts} | 149 ++++++++++++------ ...esolve-accounts.js => resolve-accounts.ts} | 12 +- .../sdk/src/resolve/resolve-signatures.js | 2 +- packages/sdk/src/resolve/resolve.js | 2 +- .../src/resolve/{voucher.js => voucher.ts} | 29 ++-- packages/sdk/src/sdk.ts | 2 +- .../sdk/src/wallet-utils/encode-signable.js | 2 +- .../src/wallet-utils/encode-signable.test.js | 2 +- packages/sdk/src/wallet-utils/validate-tx.js | 2 +- .../sdk/src/wallet-utils/validate-tx.test.js | 2 +- packages/util-address/src/index.ts | 5 +- 17 files changed, 146 insertions(+), 77 deletions(-) rename packages/sdk/src/encode/{encode.js => encode.ts} (57%) rename packages/sdk/src/resolve/{resolve-accounts.js => resolve-accounts.ts} (96%) rename packages/sdk/src/resolve/{voucher.js => voucher.ts} (72%) diff --git a/packages/fcl/src/wallet-provider-spec/draft-v3.md b/packages/fcl/src/wallet-provider-spec/draft-v3.md index 80e19a87f..363e80a69 100644 --- a/packages/fcl/src/wallet-provider-spec/draft-v3.md +++ b/packages/fcl/src/wallet-provider-spec/draft-v3.md @@ -471,7 +471,7 @@ An authorization service is expected to know the Account and the Key that will b FCL will use the `method` provided to request an array of composite signature from authorization service (Wrapped in a `PollingResponse`). The authorization service will be sent a `Signable`. The service is expected to construct an encoded message to sign from `Signable.voucher`. -It then needs to hash the encoded message, and prepend a required [transaction domain tag](https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/src/encode/encode.js#L12-L13). +It then needs to hash the encoded message, and prepend a required [transaction domain tag](../../../sdk/src/encode/encode.ts#L12-L13). Finally it signs the payload with the user/s keys, producing a signature. This signature, as a HEX string, is sent back to FCL as part of the `CompositeSignature` which includes the user address and keyID in the data property of a `PollingResponse`. diff --git a/packages/fcl/src/wallet-provider-spec/draft-v4.md b/packages/fcl/src/wallet-provider-spec/draft-v4.md index 30f49a414..b78519324 100644 --- a/packages/fcl/src/wallet-provider-spec/draft-v4.md +++ b/packages/fcl/src/wallet-provider-spec/draft-v4.md @@ -732,7 +732,7 @@ An authorization service is expected to know the Account and the Key that will b FCL will use the `method` provided to request an array of composite signature from authorization service (Wrapped in a `PollingResponse`). The authorization service will be sent a `Signable`. The service is expected to construct an encoded message to sign from `Signable.voucher`. -It then needs to hash the encoded message, and prepend a required [transaction domain tag](https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/src/encode/encode.js#L12-L13). +It then needs to hash the encoded message, and prepend a required [transaction domain tag](../../../sdk/src/encode/encode.ts#L12-L13). Finally it signs the payload with the user/s keys, producing a signature. This signature, as a HEX string, is sent back to FCL as part of the `CompositeSignature` which includes the user address and keyID in the data property of a `PollingResponse`. diff --git a/packages/rlp/src/index.ts b/packages/rlp/src/index.ts index 1ed6933f2..9260f5ccc 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -2,7 +2,7 @@ import {Buffer} from "buffer" export {Buffer} -type EncodeInput = +export type EncodeInput = | Buffer | string | number diff --git a/packages/sdk/readme.md b/packages/sdk/readme.md index 65bef283a..d5bf62343 100644 --- a/packages/sdk/readme.md +++ b/packages/sdk/readme.md @@ -526,7 +526,7 @@ const response = await sdk.send(await sdk.build([ - [`sdk.validator`](./src/build/build-validator.js) - [Resolvers](./src/resolve) - - [`sdk.resolveAccounts`](./src/resolve/resolve-accounts.js) + - [`sdk.resolveAccounts`](./src/resolve/resolve-accounts) - [`sdk.resolveArguments`](./src/resolve/resolve-arguments.js) - [`sdk.resolveCadence`](./src/resolve/resolve-cadence.js) - [`sdk.resolveFinalNormalization`](./src/resolve/resolve-final-normalization.js) diff --git a/packages/sdk/src/contract.test.js b/packages/sdk/src/contract.test.js index 4a9001db4..40f95cea8 100644 --- a/packages/sdk/src/contract.test.js +++ b/packages/sdk/src/contract.test.js @@ -1,6 +1,6 @@ import * as root from "./sdk" import * as decode from "./decode/decode.js" -import * as encode from "./encode/encode.js" +import * as encode from "./encode/encode" import * as interaction from "./interaction/interaction" import * as send from "./send/send.js" import * as template from "@onflow/util-template" diff --git a/packages/sdk/src/encode/encode.test.js b/packages/sdk/src/encode/encode.test.js index bb8d8ada7..8c224fe61 100644 --- a/packages/sdk/src/encode/encode.test.js +++ b/packages/sdk/src/encode/encode.test.js @@ -4,8 +4,8 @@ import { encodeTransactionPayload, encodeTransactionEnvelope, encodeTxIdFromVoucher, -} from "./encode.js" -import * as root from "./encode.js" +} from "./encode" +import * as root from "./encode" it("export contract interface", () => { expect(root).toStrictEqual( diff --git a/packages/sdk/src/encode/encode.js b/packages/sdk/src/encode/encode.ts similarity index 57% rename from packages/sdk/src/encode/encode.js rename to packages/sdk/src/encode/encode.ts index 388487ced..3f5aeb57b 100644 --- a/packages/sdk/src/encode/encode.js +++ b/packages/sdk/src/encode/encode.ts @@ -1,46 +1,46 @@ import {SHA3} from "sha3" -import {encode, Buffer} from "@onflow/rlp" +import {encode, Buffer, EncodeInput} from "@onflow/rlp" import {sansPrefix} from "@onflow/util-address" -export const encodeTransactionPayload = tx => +export const encodeTransactionPayload = (tx: ITx) => prependTransactionDomainTag(rlpEncode(preparePayload(tx))) -export const encodeTransactionEnvelope = tx => +export const encodeTransactionEnvelope = (tx: ITx) => prependTransactionDomainTag(rlpEncode(prepareEnvelope(tx))) -export const encodeTxIdFromVoucher = voucher => +export const encodeTxIdFromVoucher = (voucher: IVoucher) => sha3_256(rlpEncode(prepareVoucher(voucher))) -const rightPaddedHexBuffer = (value, pad) => - Buffer.from(value.padEnd(pad * 2, 0), "hex") +const rightPaddedHexBuffer = (value: string, pad: number) => + Buffer.from(value.padEnd(pad * 2, "0"), "hex") -const leftPaddedHexBuffer = (value, pad) => - Buffer.from(value.padStart(pad * 2, 0), "hex") +const leftPaddedHexBuffer = (value: string, pad: number) => + Buffer.from(value.padStart(pad * 2, "0"), "hex") const TRANSACTION_DOMAIN_TAG = rightPaddedHexBuffer( Buffer.from("FLOW-V0.0-transaction").toString("hex"), 32 ).toString("hex") -const prependTransactionDomainTag = tx => TRANSACTION_DOMAIN_TAG + tx +const prependTransactionDomainTag = (tx: string) => TRANSACTION_DOMAIN_TAG + tx -const addressBuffer = addr => leftPaddedHexBuffer(addr, 8) +const addressBuffer = (addr: string) => leftPaddedHexBuffer(addr, 8) -const blockBuffer = block => leftPaddedHexBuffer(block, 32) +const blockBuffer = (block: string) => leftPaddedHexBuffer(block, 32) -const argumentToString = arg => Buffer.from(JSON.stringify(arg), "utf8") +const argumentToString = (arg: Record) => Buffer.from(JSON.stringify(arg), "utf8") -const scriptBuffer = script => Buffer.from(script, "utf8") -const signatureBuffer = signature => Buffer.from(signature, "hex") +const scriptBuffer = (script: string) => Buffer.from(script, "utf8") +const signatureBuffer = (signature: string) => Buffer.from(signature, "hex") -const rlpEncode = v => { +const rlpEncode = (v: EncodeInput) => { return encode(v).toString("hex") } -const sha3_256 = msg => { +const sha3_256 = (msg: string) => { const sha = new SHA3(256) sha.update(Buffer.from(msg, "hex")) return sha.digest().toString("hex") } -const preparePayload = tx => { +const preparePayload = (tx: ITx) => { validatePayload(tx) return [ @@ -56,19 +56,19 @@ const preparePayload = tx => { ] } -const prepareEnvelope = tx => { +const prepareEnvelope = (tx: ITx) => { validateEnvelope(tx) return [preparePayload(tx), preparePayloadSignatures(tx)] } -const preparePayloadSignatures = tx => { +const preparePayloadSignatures = (tx: ITx) => { const signers = collectSigners(tx) return tx.payloadSigs .map(sig => { return { - signerIndex: signers.get(sig.address), + signerIndex: signers.get(sig.address) || '', keyId: sig.keyId, sig: sig.sig, } @@ -79,17 +79,19 @@ const preparePayloadSignatures = tx => { if (a.keyId > b.keyId) return 1 if (a.keyId < b.keyId) return -1 + + return 0 }) .map(sig => { return [sig.signerIndex, sig.keyId, signatureBuffer(sig.sig)] }) } -const collectSigners = tx => { - const signers = new Map() +const collectSigners = (tx: IVoucher | ITx) => { + const signers = new Map() let i = 0 - const addSigner = addr => { + const addSigner = (addr: string) => { if (!signers.has(addr)) { signers.set(addr, i) i++ @@ -103,21 +105,23 @@ const collectSigners = tx => { return signers } -const prepareVoucher = voucher => { +const prepareVoucher = (voucher: IVoucher) => { validateVoucher(voucher) const signers = collectSigners(voucher) - const prepareSigs = sigs => { + const prepareSigs = (sigs: ISig[]) => { return sigs - .map(({address, keyId, sig}) => { - return {signerIndex: signers.get(address), keyId, sig} + .map(({ address, keyId, sig }) => { + return { signerIndex: signers.get(address) || '', keyId, sig } }) .sort((a, b) => { if (a.signerIndex > b.signerIndex) return 1 if (a.signerIndex < b.signerIndex) return -1 if (a.keyId > b.keyId) return 1 if (a.keyId < b.keyId) return -1 + + return 0 }) .map(sig => { return [sig.signerIndex, sig.keyId, signatureBuffer(sig.sig)] @@ -143,14 +147,14 @@ const prepareVoucher = voucher => { ] } -const validatePayload = tx => { +const validatePayload = (tx: ITx) => { payloadFields.forEach(field => checkField(tx, field)) proposalKeyFields.forEach(field => checkField(tx.proposalKey, field, "proposalKey") ) } -const validateEnvelope = tx => { +const validateEnvelope = (tx: ITx) => { payloadSigsFields.forEach(field => checkField(tx, field)) tx.payloadSigs.forEach((sig, index) => { payloadSigFields.forEach(field => @@ -159,7 +163,7 @@ const validateEnvelope = tx => { }) } -const validateVoucher = voucher => { +const validateVoucher = (voucher: IVoucher) => { payloadFields.forEach(field => checkField(voucher, field)) proposalKeyFields.forEach(field => checkField(voucher.proposalKey, field, "proposalKey") @@ -178,12 +182,64 @@ const validateVoucher = voucher => { }) } -const isNumber = v => typeof v === "number" -const isString = v => typeof v === "string" -const isObject = v => v !== null && typeof v === "object" -const isArray = v => isObject(v) && v instanceof Array +const isNumber = (v: any): v is number => typeof v === "number" +const isString = (v: any): v is string => typeof v === "string" +const isObject = (v: any) => v !== null && typeof v === "object" +const isArray = (v: any) => isObject(v) && v instanceof Array + +interface IVoucherArgument { + type: string + value: string +} + +interface IVoucherProposalKey { + address: string + keyId: number | null + sequenceNum: number | null +} + +interface ISig { + address: string, + keyId: number, + sig: string, +} + +interface ITxProposalKey { + address: string + keyId: number + sequenceNum: number +} +interface ITx { + cadence: string; + refBlock: string; + computeLimit: number; + arguments: IVoucherArgument[] + proposalKey: ITxProposalKey + payer: string + authorizers: string[] + payloadSigs: ISig[] + envelopeSigs: ITxProposalKey[] +} + +interface IVoucher { + cadence: string; + refBlock: string; + computeLimit: number; + arguments: IVoucherArgument[] + proposalKey: IVoucherProposalKey + payer: string + authorizers: string[] + payloadSigs: ISig[] + envelopeSigs: ISig[] +} + +interface IPayloadField { + name: string, + check: (v: any) => boolean, + defaultVal?: string +} -const payloadFields = [ +const payloadFields: IPayloadField[] = [ {name: "cadence", check: isString}, {name: "arguments", check: isArray}, {name: "refBlock", check: isString, defaultVal: "0"}, @@ -193,42 +249,47 @@ const payloadFields = [ {name: "authorizers", check: isArray}, ] -const proposalKeyFields = [ +const proposalKeyFields: IPayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sequenceNum", check: isNumber}, ] -const payloadSigsFields = [{name: "payloadSigs", check: isArray}] +const payloadSigsFields: IPayloadField[] = [{name: "payloadSigs", check: isArray}] -const payloadSigFields = [ +const payloadSigFields: IPayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sig", check: isString}, ] -const envelopeSigsFields = [{name: "envelopeSigs", check: isArray}] +const envelopeSigsFields: IPayloadField[] = [{ name: "envelopeSigs", check: isArray }] -const envelopeSigFields = [ +const envelopeSigFields: IPayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sig", check: isString}, ] -const checkField = (obj, field, base, index) => { +const checkField = ( + obj: Record, + field: IPayloadField, + base?: string, + index?: number +) => { const {name, check, defaultVal} = field if (obj[name] == null && defaultVal != null) obj[name] = defaultVal if (obj[name] == null) throw missingFieldError(name, base, index) if (!check(obj[name])) throw invalidFieldError(name, base, index) } -const printFieldName = (field, base, index) => { +const printFieldName = (field: string, base?: string, index?: number) => { if (!!base) return index == null ? `${base}.${field}` : `${base}.${index}.${field}` return field } -const missingFieldError = (field, base, index) => +const missingFieldError = (field: string, base?: string, index?: number) => new Error(`Missing field ${printFieldName(field, base, index)}`) -const invalidFieldError = (field, base, index) => +const invalidFieldError = (field: string, base?: string, index?: number) => new Error(`Invalid field ${printFieldName(field, base, index)}`) diff --git a/packages/sdk/src/resolve/resolve-accounts.js b/packages/sdk/src/resolve/resolve-accounts.ts similarity index 96% rename from packages/sdk/src/resolve/resolve-accounts.js rename to packages/sdk/src/resolve/resolve-accounts.ts index 15deaa7ec..c0e2ae822 100644 --- a/packages/sdk/src/resolve/resolve-accounts.js +++ b/packages/sdk/src/resolve/resolve-accounts.ts @@ -1,14 +1,14 @@ import {sansPrefix, withPrefix} from "@onflow/util-address" import {invariant} from "@onflow/util-invariant" import {log} from "@onflow/util-logger" -import {isTransaction} from "../interaction/interaction" +import {IAcct, IIx, isTransaction} from "../interaction/interaction" 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 => +const idof = (acct: IAcct) => `${withPrefix(acct.addr)}-${acct.keyId}` +const isFn = (v: any): v is Function => v && (Object.prototype.toString.call(v) === "[object Function]" || "function" === typeof v || @@ -49,7 +49,7 @@ function recurseFlatMap(el, depthLimit = 3) { ) } -export function buildPreSignable(acct, ix) { +export function buildPreSignable(acct: IAcct, ix: IIx) { try { return { f_type: "PreSignable", @@ -67,7 +67,7 @@ export function buildPreSignable(acct, ix) { } } -async function removeUnusedIxAccounts(ix) { +async function removeUnusedIxAccounts(ix: IIx) { const payerTempIds = Array.isArray(ix.payer) ? ix.payer : [ix.payer] const authorizersTempIds = Array.isArray(ix.authorizations) ? ix.authorizations @@ -295,7 +295,7 @@ async function resolveAccountType(ix, type, {debugLogger}) { } } -export async function resolveAccounts(ix, opts = {}) { +export async function resolveAccounts(ix: IIx, opts = {}) { if (isTransaction(ix)) { if (!Array.isArray(ix.payer)) { log.deprecate({ diff --git a/packages/sdk/src/resolve/resolve-signatures.js b/packages/sdk/src/resolve/resolve-signatures.js index 9254bb9a2..e2930e346 100644 --- a/packages/sdk/src/resolve/resolve-signatures.js +++ b/packages/sdk/src/resolve/resolve-signatures.js @@ -3,7 +3,7 @@ import {sansPrefix} from "@onflow/util-address" import { encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, -} from "../encode/encode.js" +} from "../encode/encode" import { createSignableVoucher, findInsideSigners, diff --git a/packages/sdk/src/resolve/resolve.js b/packages/sdk/src/resolve/resolve.js index 4fa5fd526..4a17237e9 100644 --- a/packages/sdk/src/resolve/resolve.js +++ b/packages/sdk/src/resolve/resolve.js @@ -12,7 +12,7 @@ import {decodeResponse as decode} from "../decode/decode.js" import {resolveCadence} from "./resolve-cadence.js" import {resolveArguments} from "./resolve-arguments.js" -import {resolveAccounts} from "./resolve-accounts.js" +import {resolveAccounts} from "./resolve-accounts" import {resolveSignatures} from "./resolve-signatures.js" import {resolveValidators} from "./resolve-validators.js" import {resolveFinalNormalization} from "./resolve-final-normalization.js" diff --git a/packages/sdk/src/resolve/voucher.js b/packages/sdk/src/resolve/voucher.ts similarity index 72% rename from packages/sdk/src/resolve/voucher.js rename to packages/sdk/src/resolve/voucher.ts index 0a07cbfaf..1cac3ca1a 100644 --- a/packages/sdk/src/resolve/voucher.js +++ b/packages/sdk/src/resolve/voucher.ts @@ -1,10 +1,13 @@ import {withPrefix} from "@onflow/util-address" -import {encodeTxIdFromVoucher} from "../encode/encode.js" +import {encodeTxIdFromVoucher} from "../encode/encode" +import { IIx } from "@onflow/typedefs" -export function findInsideSigners(ix) { +export function findInsideSigners(ix: IIx) { // Inside Signers Are: (authorizers + proposer) - payer let inside = new Set(ix.authorizations) - inside.add(ix.proposer) + if (ix.proposer) { + inside.add(ix.proposer) + } if (Array.isArray(ix.payer)) { ix.payer.forEach(p => inside.delete(p)) } else { @@ -13,20 +16,20 @@ export function findInsideSigners(ix) { return Array.from(inside) } -export function findOutsideSigners(ix) { +export function findOutsideSigners(ix: IIx) { // Outside Signers Are: (payer) let outside = new Set(Array.isArray(ix.payer) ? ix.payer : [ix.payer]) return Array.from(outside) } -export const createSignableVoucher = ix => { +export const createSignableVoucher = (ix: IIx) => { const buildAuthorizers = () => { const authorizations = ix.authorizations .map(cid => withPrefix(ix.accounts[cid].addr)) - .reduce((prev, current) => { + .reduce((prev: (string | null)[], current) => { return prev.find(item => item === current) ? prev : [...prev, current] }, []) - return authorizations[0] ? authorizations : [] + return authorizations?.[0] ? authorizations : [] } const buildInsideSigners = () => @@ -43,16 +46,18 @@ export const createSignableVoucher = ix => { sig: ix.accounts[id].signature, })) + const proposalKey = ix.proposer ? { + address: withPrefix(ix.accounts[ix.proposer].addr), + keyId: ix.accounts[ix.proposer].keyId, + sequenceNum: ix.accounts[ix.proposer].sequenceNum, + } : {} + return { cadence: ix.message.cadence, refBlock: ix.message.refBlock || null, computeLimit: ix.message.computeLimit, arguments: ix.message.arguments.map(id => ix.arguments[id].asArgument), - proposalKey: { - address: withPrefix(ix.accounts[ix.proposer].addr), - keyId: ix.accounts[ix.proposer].keyId, - sequenceNum: ix.accounts[ix.proposer].sequenceNum, - }, + proposalKey, payer: withPrefix( ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr ), diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 769188d47..51772448d 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -74,7 +74,7 @@ export {resolveCadence} from "./resolve/resolve-cadence.js" export {resolveFinalNormalization} from "./resolve/resolve-final-normalization" export {resolveProposerSequenceNumber} from "./resolve/resolve-proposer-sequence-number" export {resolveArguments} from "./resolve/resolve-arguments.js" -export {resolveAccounts} from "./resolve/resolve-accounts.js" +export {resolveAccounts} from "./resolve/resolve-accounts" export {response} from "./response/response" export {resolveSignatures} from "./resolve/resolve-signatures.js" export {resolveValidators} from "./resolve/resolve-validators.js" diff --git a/packages/sdk/src/wallet-utils/encode-signable.js b/packages/sdk/src/wallet-utils/encode-signable.js index 006d2ed4d..724c78d0a 100644 --- a/packages/sdk/src/wallet-utils/encode-signable.js +++ b/packages/sdk/src/wallet-utils/encode-signable.js @@ -2,7 +2,7 @@ import {withPrefix, sansPrefix} from "@onflow/util-address" import { encodeTransactionPayload, encodeTransactionEnvelope, -} from "../encode/encode.js" +} from "../encode/encode" const findPayloadSigners = voucher => { // Payload Signers Are: (authorizers + proposer) - payer diff --git a/packages/sdk/src/wallet-utils/encode-signable.test.js b/packages/sdk/src/wallet-utils/encode-signable.test.js index bbf8298a9..f6d88aa44 100644 --- a/packages/sdk/src/wallet-utils/encode-signable.test.js +++ b/packages/sdk/src/wallet-utils/encode-signable.test.js @@ -5,7 +5,7 @@ import { import { encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, -} from "../encode/encode.js" +} from "../encode/encode" const MESSAGE = { cadence: "transaction()...", diff --git a/packages/sdk/src/wallet-utils/validate-tx.js b/packages/sdk/src/wallet-utils/validate-tx.js index f56551510..03b639d0c 100644 --- a/packages/sdk/src/wallet-utils/validate-tx.js +++ b/packages/sdk/src/wallet-utils/validate-tx.js @@ -1,7 +1,7 @@ import { encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, -} from "../encode/encode.js" +} from "../encode/encode" import {invariant} from "@onflow/util-invariant" const isPayer = signable => { diff --git a/packages/sdk/src/wallet-utils/validate-tx.test.js b/packages/sdk/src/wallet-utils/validate-tx.test.js index fa63122f8..b0ae56c26 100644 --- a/packages/sdk/src/wallet-utils/validate-tx.test.js +++ b/packages/sdk/src/wallet-utils/validate-tx.test.js @@ -2,7 +2,7 @@ import {validateSignableTransaction} from "./" import { encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, -} from "../encode/encode.js" +} from "../encode/encode" const MESSAGE = { cadence: "", diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts index 33e05de1a..4f8eb4fc4 100644 --- a/packages/util-address/src/index.ts +++ b/packages/util-address/src/index.ts @@ -1,3 +1,6 @@ + +export function sansPrefix(address: null): null; +export function sansPrefix(address: string): string; /** * @description Removes 0x from address if present * @param address - Flow address @@ -15,7 +18,7 @@ export function sansPrefix(address: string | null): string | null { */ export function withPrefix(address: string | null): string | null { if (address == null) return null - return "0x" + sansPrefix(address) + return `0x` + sansPrefix(address) } /** From 1050275302b032b3c458ab63bcdbce5abff28d85 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:06:22 -0400 Subject: [PATCH 31/45] fix references --- packages/sdk/readme.md | 2 +- packages/sdk/src/encode/encode.ts | 2 +- packages/sdk/src/resolve/resolve-accounts.ts | 2 +- packages/sdk/src/resolve/resolve-signatures.js | 2 +- packages/sdk/src/resolve/resolve-voucher-intercept.js | 2 +- packages/sdk/src/resolve/voucher.ts | 4 ++-- packages/sdk/src/sdk.ts | 2 +- packages/typedefs/src/interaction.ts | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/sdk/readme.md b/packages/sdk/readme.md index d5bf62343..29f881fa8 100644 --- a/packages/sdk/readme.md +++ b/packages/sdk/readme.md @@ -537,4 +537,4 @@ const response = await sdk.send(await sdk.build([ - [`sdk.resolveValidators`](./src/resolve/resolve-validators.js) - [Other Utils](./src/) - - [`sdk.voucherToTxId`](./src/resolve/voucher.js) + - [`sdk.voucherToTxId`](./src/resolve/voucher.ts) diff --git a/packages/sdk/src/encode/encode.ts b/packages/sdk/src/encode/encode.ts index 3f5aeb57b..2847651cf 100644 --- a/packages/sdk/src/encode/encode.ts +++ b/packages/sdk/src/encode/encode.ts @@ -221,7 +221,7 @@ interface ITx { envelopeSigs: ITxProposalKey[] } -interface IVoucher { +export interface IVoucher { cadence: string; refBlock: string; computeLimit: number; diff --git a/packages/sdk/src/resolve/resolve-accounts.ts b/packages/sdk/src/resolve/resolve-accounts.ts index c0e2ae822..6101c1792 100644 --- a/packages/sdk/src/resolve/resolve-accounts.ts +++ b/packages/sdk/src/resolve/resolve-accounts.ts @@ -2,7 +2,7 @@ import {sansPrefix, withPrefix} from "@onflow/util-address" import {invariant} from "@onflow/util-invariant" import {log} from "@onflow/util-logger" import {IAcct, IIx, isTransaction} from "../interaction/interaction" -import {createSignableVoucher} from "./voucher.js" +import {createSignableVoucher} from "./voucher" import {v4 as uuidv4} from "uuid" const MAX_DEPTH_LIMIT = 5 diff --git a/packages/sdk/src/resolve/resolve-signatures.js b/packages/sdk/src/resolve/resolve-signatures.js index e2930e346..97238f910 100644 --- a/packages/sdk/src/resolve/resolve-signatures.js +++ b/packages/sdk/src/resolve/resolve-signatures.js @@ -8,7 +8,7 @@ import { createSignableVoucher, findInsideSigners, findOutsideSigners, -} from "./voucher.js" +} from "./voucher" export async function resolveSignatures(ix) { if (isTransaction(ix)) { diff --git a/packages/sdk/src/resolve/resolve-voucher-intercept.js b/packages/sdk/src/resolve/resolve-voucher-intercept.js index 45ede7224..f1f6ac211 100644 --- a/packages/sdk/src/resolve/resolve-voucher-intercept.js +++ b/packages/sdk/src/resolve/resolve-voucher-intercept.js @@ -1,5 +1,5 @@ import {get, isFn} from "../interaction/interaction" -import {createSignableVoucher} from "./voucher.js" +import {createSignableVoucher} from "./voucher" export async function resolveVoucherIntercept(ix) { const fn = get(ix, "ix.voucher-intercept") diff --git a/packages/sdk/src/resolve/voucher.ts b/packages/sdk/src/resolve/voucher.ts index 1cac3ca1a..df7539172 100644 --- a/packages/sdk/src/resolve/voucher.ts +++ b/packages/sdk/src/resolve/voucher.ts @@ -1,5 +1,5 @@ import {withPrefix} from "@onflow/util-address" -import {encodeTxIdFromVoucher} from "../encode/encode" +import {IVoucher, encodeTxIdFromVoucher} from "../encode/encode" import { IIx } from "@onflow/typedefs" export function findInsideSigners(ix: IIx) { @@ -67,6 +67,6 @@ export const createSignableVoucher = (ix: IIx) => { } } -export const voucherToTxId = voucher => { +export const voucherToTxId = (voucher: IVoucher) => { return encodeTxIdFromVoucher(voucher) } diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index 51772448d..ead9110d2 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -34,7 +34,7 @@ export { isGetCollection, isGetNetworkParameters, } from "./interaction/interaction" -export {createSignableVoucher, voucherToTxId} from "./resolve/voucher.js" +export {createSignableVoucher, voucherToTxId} from "./resolve/voucher" export {encodeMessageFromSignable} from "./wallet-utils/encode-signable.js" export {template as cadence} from "@onflow/util-template" export {template as cdc} from "@onflow/util-template" diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index 17208f911..8457980a6 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -25,7 +25,7 @@ export const PROPOSER /* */ = "proposer" export interface IAcct { "kind": typeof ACCOUNT, - "tempId": string | null, + "tempId": string, "addr": string | null, "keyId": number | string | null, "sequenceNum": number | null, From bd2a320b4bc38fb93005c6a7a6bdd52e6be51010 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:09:18 -0400 Subject: [PATCH 32/45] revert changes --- packages/util-address/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts index 4f8eb4fc4..f8764346d 100644 --- a/packages/util-address/src/index.ts +++ b/packages/util-address/src/index.ts @@ -18,7 +18,7 @@ export function sansPrefix(address: string | null): string | null { */ export function withPrefix(address: string | null): string | null { if (address == null) return null - return `0x` + sansPrefix(address) + return "0x" + sansPrefix(address) } /** From eb422eaf5f6af2a5299f539497468c3894aed35e Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:34:54 -0400 Subject: [PATCH 33/45] ts resolve signature --- packages/sdk/readme.md | 8 ++-- packages/sdk/src/encode/encode.ts | 35 ++++++++-------- .../src/resolve/resolve-signatures.test.js | 2 +- ...ve-signatures.js => resolve-signatures.ts} | 41 +++++++++++-------- packages/sdk/src/resolve/resolve.js | 2 +- packages/sdk/src/sdk.ts | 2 +- packages/typedefs/src/interaction.ts | 6 +-- packages/util-address/src/index.ts | 1 + 8 files changed, 52 insertions(+), 45 deletions(-) rename packages/sdk/src/resolve/{resolve-signatures.js => resolve-signatures.ts} (75%) diff --git a/packages/sdk/readme.md b/packages/sdk/readme.md index 29f881fa8..650e0a752 100644 --- a/packages/sdk/readme.md +++ b/packages/sdk/readme.md @@ -497,7 +497,7 @@ const response = await sdk.send(await sdk.build([ - [Builders](./src/build) - - [`sdk.args` & `sdk.arg`](./src/build/build-arguments) + - [`sdk.args` & `sdk.arg`](./src/build/build-arguments.ts) - [`sdk.atBlockHeight`](./src/build/build-at-block-height.js) - [`sdk.atBlockId`](./src/build/build-at-block-id.js) - [`sdk.authorizations` & `authorization`](./src/build/build-authorizations.js) @@ -509,7 +509,7 @@ const response = await sdk.send(await sdk.build([ - [`sdk.getCollection`](./src/build/build-get-collection) - [`sdk.getEvents`](./src/build/build-get-events.js) - [`sdk.getEventsAtBlockHeightRange`](./src/build/build-get-events-at-block-height-range.js) - - [`sdk.getEventsAtBlockIds`](./src/build/build-get-events-at-block-ids) + - [`sdk.getEventsAtBlockIds`](./src/build/build-get-events-at-block-ids.js) - [`sdk.getLatestBlock`](./src/build/build-get-latest-block.js) - [`sdk.getTransactionStatus`](./src/build/build-get-transaction-status.js) - [`sdk.getTransaction`](./src/build/build-get-transaction.js) @@ -526,14 +526,14 @@ const response = await sdk.send(await sdk.build([ - [`sdk.validator`](./src/build/build-validator.js) - [Resolvers](./src/resolve) - - [`sdk.resolveAccounts`](./src/resolve/resolve-accounts) + - [`sdk.resolveAccounts`](./src/resolve/resolve-accounts.ts) - [`sdk.resolveArguments`](./src/resolve/resolve-arguments.js) - [`sdk.resolveCadence`](./src/resolve/resolve-cadence.js) - [`sdk.resolveFinalNormalization`](./src/resolve/resolve-final-normalization.js) - [`sdk.resolveVoucherIntercept`](./src/resolve/resolve-voucher-intercept.js) - [`sdk.resolveProposerSequenceNumber`](./src/resolve/resolve-proposer-sequence-number.js) - [`sdk.resolveRefBlockId`](./src/resolve/resolve-ref-block-id.js) - - [`sdk.resolveSignatures`](./src/resolve/resolve-signatures.js) + - [`sdk.resolveSignatures`](./src/resolve/resolve-signatures.ts) - [`sdk.resolveValidators`](./src/resolve/resolve-validators.js) - [Other Utils](./src/) diff --git a/packages/sdk/src/encode/encode.ts b/packages/sdk/src/encode/encode.ts index 2847651cf..25e80ade2 100644 --- a/packages/sdk/src/encode/encode.ts +++ b/packages/sdk/src/encode/encode.ts @@ -44,11 +44,11 @@ const preparePayload = (tx: ITx) => { validatePayload(tx) return [ - scriptBuffer(tx.cadence), + scriptBuffer(tx.cadence || ''), tx.arguments.map(argumentToString), - blockBuffer(tx.refBlock), + blockBuffer(tx.refBlock || ''), tx.computeLimit, - addressBuffer(sansPrefix(tx.proposalKey.address)), + addressBuffer(sansPrefix(tx.proposalKey.address || '')), tx.proposalKey.keyId, tx.proposalKey.sequenceNum, addressBuffer(sansPrefix(tx.payer)), @@ -65,8 +65,7 @@ const prepareEnvelope = (tx: ITx) => { const preparePayloadSignatures = (tx: ITx) => { const signers = collectSigners(tx) - return tx.payloadSigs - .map(sig => { + return tx.payloadSigs?.map((sig: ISig) => { return { signerIndex: signers.get(sig.address) || '', keyId: sig.keyId, @@ -98,7 +97,9 @@ const collectSigners = (tx: IVoucher | ITx) => { } } - addSigner(tx.proposalKey.address) + if (tx.proposalKey.address){ + addSigner(tx.proposalKey.address) + } addSigner(tx.payer) tx.authorizers.forEach(addSigner) @@ -156,7 +157,7 @@ const validatePayload = (tx: ITx) => { const validateEnvelope = (tx: ITx) => { payloadSigsFields.forEach(field => checkField(tx, field)) - tx.payloadSigs.forEach((sig, index) => { + tx.payloadSigs?.forEach((sig, index) => { payloadSigFields.forEach(field => checkField(sig, field, "payloadSigs", index) ) @@ -204,21 +205,21 @@ interface ISig { sig: string, } -interface ITxProposalKey { - address: string - keyId: number - sequenceNum: number +export interface ITxProposalKey { + address?: string + keyId?: number + sequenceNum?: number } -interface ITx { - cadence: string; - refBlock: string; - computeLimit: number; +export interface ITx { + cadence: string | null; + refBlock: string | null; + computeLimit: string | null; arguments: IVoucherArgument[] proposalKey: ITxProposalKey payer: string authorizers: string[] - payloadSigs: ISig[] - envelopeSigs: ITxProposalKey[] + payloadSigs?: ISig[] + envelopeSigs?: ITxProposalKey[] } export interface IVoucher { diff --git a/packages/sdk/src/resolve/resolve-signatures.test.js b/packages/sdk/src/resolve/resolve-signatures.test.js index 30465ad7e..074c03d7d 100644 --- a/packages/sdk/src/resolve/resolve-signatures.test.js +++ b/packages/sdk/src/resolve/resolve-signatures.test.js @@ -1,4 +1,4 @@ -import {resolveSignatures, buildSignable} from "./resolve-signatures.js" +import {resolveSignatures, buildSignable} from "./resolve-signatures" import { build, resolve, diff --git a/packages/sdk/src/resolve/resolve-signatures.js b/packages/sdk/src/resolve/resolve-signatures.ts similarity index 75% rename from packages/sdk/src/resolve/resolve-signatures.js rename to packages/sdk/src/resolve/resolve-signatures.ts index 97238f910..125fba64b 100644 --- a/packages/sdk/src/resolve/resolve-signatures.js +++ b/packages/sdk/src/resolve/resolve-signatures.ts @@ -1,6 +1,8 @@ -import {isTransaction} from "../interaction/interaction" +import {IAcct, IIx, isTransaction} from "../interaction/interaction" import {sansPrefix} from "@onflow/util-address" import { + ITx, + ITxProposalKey, encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, } from "../encode/encode" @@ -10,7 +12,7 @@ import { findOutsideSigners, } from "./voucher" -export async function resolveSignatures(ix) { +export async function resolveSignatures(ix: IIx) { if (isTransaction(ix)) { try { let insideSigners = findInsideSigners(ix) @@ -28,9 +30,9 @@ export async function resolveSignatures(ix) { const outsidePayload = encodeOutsideMessage({ ...prepForEncoding(ix), payloadSigs: insideSigners.map(id => ({ - address: ix.accounts[id].addr, - keyId: ix.accounts[id].keyId, - sig: ix.accounts[id].signature, + address: ix.accounts[id].addr || '', + keyId: ix.accounts[id].keyId || 0, + sig: ix.accounts[id].signature || '', })), }) @@ -49,8 +51,8 @@ export async function resolveSignatures(ix) { return ix } -function fetchSignature(ix, payload) { - return async function innerFetchSignature(id) { +function fetchSignature(ix: IIx, payload: string) { + return async function innerFetchSignature(id: string) { const acct = ix.accounts[id] if (acct.signature != null && acct.signature !== undefined) return const {signature} = await acct.signingFunction( @@ -60,7 +62,7 @@ function fetchSignature(ix, payload) { } } -export function buildSignable(acct, message, ix) { +export function buildSignable(acct: IAcct, message: string, ix: IIx) { try { return { f_type: "Signable", @@ -81,25 +83,28 @@ export function buildSignable(acct, message, ix) { } } -function prepForEncoding(ix) { +function prepForEncoding(ix: IIx): ITx { const payerAddress = sansPrefix( (Array.isArray(ix.payer) ? ix.accounts[ix.payer[0]] : ix.accounts[ix.payer]) - .addr + .addr || "" ) + + const proposalKey: ITxProposalKey = ix.proposer ? { + address: sansPrefix(ix.accounts[ix.proposer].addr) || '', + keyId: ix.accounts[ix.proposer].keyId || 0, + sequenceNum: ix.accounts[ix.proposer].sequenceNum || 0, + } : {} + return { cadence: ix.message.cadence, - refBlock: ix.message.refBlock || null, + refBlock: ix.message.refBlock, computeLimit: ix.message.computeLimit, arguments: ix.message.arguments.map(id => ix.arguments[id].asArgument), - proposalKey: { - address: sansPrefix(ix.accounts[ix.proposer].addr), - keyId: ix.accounts[ix.proposer].keyId, - sequenceNum: ix.accounts[ix.proposer].sequenceNum, - }, + proposalKey, payer: payerAddress, authorizers: ix.authorizations - .map(cid => sansPrefix(ix.accounts[cid].addr)) - .reduce((prev, current) => { + .map(cid => sansPrefix(ix.accounts[cid].addr) || '') + .reduce((prev: string[], current) => { return prev.find(item => item === current) ? prev : [...prev, current] }, []), } diff --git a/packages/sdk/src/resolve/resolve.js b/packages/sdk/src/resolve/resolve.js index 4a17237e9..b357c7cea 100644 --- a/packages/sdk/src/resolve/resolve.js +++ b/packages/sdk/src/resolve/resolve.js @@ -13,7 +13,7 @@ import {decodeResponse as decode} from "../decode/decode.js" import {resolveCadence} from "./resolve-cadence.js" import {resolveArguments} from "./resolve-arguments.js" import {resolveAccounts} from "./resolve-accounts" -import {resolveSignatures} from "./resolve-signatures.js" +import {resolveSignatures} from "./resolve-signatures" import {resolveValidators} from "./resolve-validators.js" import {resolveFinalNormalization} from "./resolve-final-normalization.js" import {resolveVoucherIntercept} from "./resolve-voucher-intercept.js" diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index ead9110d2..31776b9ac 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -76,7 +76,7 @@ export {resolveProposerSequenceNumber} from "./resolve/resolve-proposer-sequence export {resolveArguments} from "./resolve/resolve-arguments.js" export {resolveAccounts} from "./resolve/resolve-accounts" export {response} from "./response/response" -export {resolveSignatures} from "./resolve/resolve-signatures.js" +export {resolveSignatures} from "./resolve/resolve-signatures" export {resolveValidators} from "./resolve/resolve-validators.js" export {resolveRefBlockId} from "./resolve/resolve-ref-block-id.js" export {resolveVoucherIntercept} from "./resolve/resolve-voucher-intercept.js" diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index 8457980a6..23a8e02bf 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -27,9 +27,9 @@ export interface IAcct { "kind": typeof ACCOUNT, "tempId": string, "addr": string | null, - "keyId": number | string | null, + "keyId": number | null, "sequenceNum": number | null, - "signature": any | null, + "signature": string | null, "signingFunction": any | null, "resolve": any | null, "role": { @@ -46,7 +46,7 @@ export interface IIx { "assigns": Record, "status": string, "reason": string | null, - "accounts": Record, + "accounts": Record, "params": Record, "arguments": Record, "message": { diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts index f8764346d..b59ec3763 100644 --- a/packages/util-address/src/index.ts +++ b/packages/util-address/src/index.ts @@ -1,6 +1,7 @@ export function sansPrefix(address: null): null; export function sansPrefix(address: string): string; +export function sansPrefix(address: string | null): string | null; /** * @description Removes 0x from address if present * @param address - Flow address From 9313effa74272fa5fbaeee5f1d6d4a6ea7717deb Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:46:30 -0400 Subject: [PATCH 34/45] fix resolve accounts and interaction types --- package-lock.json | 7 +++++ packages/sdk/package.json | 1 + packages/sdk/src/interaction/interaction.ts | 12 ++++----- packages/sdk/src/resolve/resolve-accounts.ts | 28 +++++++++++--------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7ffbcfc3..bfcda4586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5288,6 +5288,12 @@ "version": "2.0.3", "license": "MIT" }, + "node_modules/@types/uuid": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", + "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.24", "dev": true, @@ -20453,6 +20459,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ec29f38c2..e15a7b198 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -20,6 +20,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index f4c73c4d9..bff08fbf2 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -105,11 +105,11 @@ export const interaction = () => { return initInteraction() } -export const isNumber = d => typeof d === "number" -export const isArray = d => Array.isArray(d) -export const isObj = d => d !== null && typeof d === "object" -export const isNull = d => d == null -export const isFn = d => typeof d === "function" +export const isNumber = (d: any): d is number => typeof d === "number" +export const isArray = (d: any): d is any[] => Array.isArray(d) +export const isObj = (d: any): d is Record => d !== null && typeof d === "object" +export const isNull = (d: any): d is null => d == null +export const isFn = (d: any): d is Function => typeof d === "function" export const isInteraction = (ix: IIx) => { if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false @@ -198,7 +198,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) return ix } -export const makeArgument = arg => ix => { +export const makeArgument = (arg: Record) => (ix: IIx) => { let tempId = uuidv4() ix.message.arguments.push(tempId) diff --git a/packages/sdk/src/resolve/resolve-accounts.ts b/packages/sdk/src/resolve/resolve-accounts.ts index 6101c1792..856fd10cb 100644 --- a/packages/sdk/src/resolve/resolve-accounts.ts +++ b/packages/sdk/src/resolve/resolve-accounts.ts @@ -25,9 +25,9 @@ const ROLES = { function debug() { const SPACE = " " const SPACE_COUNT_PER_INDENT = 4 - const DEBUG_MESSAGE = [] + const DEBUG_MESSAGE: string[] = [] return [ - function (msg, indent = 0) { + function (msg = '', indent = 0) { DEBUG_MESSAGE.push( Array(indent * SPACE_COUNT_PER_INDENT) .fill(SPACE) @@ -40,7 +40,7 @@ function debug() { ] } -function recurseFlatMap(el, depthLimit = 3) { +function recurseFlatMap(el: T, depthLimit = 3) { if (depthLimit <= 0) return el if (!Array.isArray(el)) return el return recurseFlatMap( @@ -67,12 +67,14 @@ export function buildPreSignable(acct: IAcct, ix: IIx) { } } -async function removeUnusedIxAccounts(ix: IIx) { +async function removeUnusedIxAccounts(ix: IIx, opts: Record) { 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) + const proposerTempIds = ix.proposer === null + ? [] + : Array.isArray(ix.proposer) ? ix.proposer : [ix.proposer] @@ -115,7 +117,7 @@ function addAccountToIx(ix, newAccount) { return ix.accounts[newAccount.tempId] } -function uniqueAccountsFlatMap(accounts) { +function uniqueAccountsFlatMap(accounts: IAcct[]) { const flatMapped = recurseFlatMap(accounts) const seen = new Set() @@ -132,7 +134,7 @@ function uniqueAccountsFlatMap(accounts) { seen.add(accountId) return account }) - .filter(e => e !== null) + .filter(e => e !== null) as IAcct[] return uniqueAccountsFlatMapped } @@ -214,7 +216,7 @@ async function recurseResolveAccount( return account.tempId } -async function resolveAccountType(ix, type, {debugLogger}) { +async function resolveAccountType(ix: IIx, type, {debugLogger}) { invariant( ix && typeof ix === "object", "resolveAccountType Error: ix not defined" @@ -228,10 +230,10 @@ async function resolveAccountType(ix, type, {debugLogger}) { let accountTempIDs = Array.isArray(ix[type]) ? ix[type] : [ix[type]] - let allResolvedAccounts = [] + let allResolvedAccounts: IAcct[] = [] for (let accountId of accountTempIDs) { let account = ix.accounts[accountId] - invariant(account, `resolveAccountType Error: account not found`) + invariant(Boolean(account), `resolveAccountType Error: account not found`) let resolvedAccountTempIds = await recurseResolveAccount( ix, @@ -246,8 +248,8 @@ async function resolveAccountType(ix, type, {debugLogger}) { ? resolvedAccountTempIds : [resolvedAccountTempIds] - let resolvedAccounts = resolvedAccountTempIds.map( - resolvedAccountTempId => ix.accounts[resolvedAccountTempId] + let resolvedAccounts: IAcct[] = resolvedAccountTempIds.map( + (resolvedAccountTempId: string) => ix.accounts[resolvedAccountTempId] ) let flatResolvedAccounts = uniqueAccountsFlatMap(resolvedAccounts) @@ -295,7 +297,7 @@ async function resolveAccountType(ix, type, {debugLogger}) { } } -export async function resolveAccounts(ix: IIx, opts = {}) { +export async function resolveAccounts(ix: IIx, opts: Record = {}) { if (isTransaction(ix)) { if (!Array.isArray(ix.payer)) { log.deprecate({ From b73afdf1363be01dff9017ce0a41b6f3a1117016 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:46:30 -0400 Subject: [PATCH 35/45] fixed types --- package-lock.json | 7 +++++++ packages/sdk/package.json | 1 + packages/sdk/src/interaction/interaction.ts | 12 ++++++------ packages/sdk/src/test-utils/authz-fn.ts | 6 +++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7ffbcfc3..bfcda4586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5288,6 +5288,12 @@ "version": "2.0.3", "license": "MIT" }, + "node_modules/@types/uuid": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", + "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.24", "dev": true, @@ -20453,6 +20459,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ec29f38c2..e15a7b198 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -20,6 +20,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index f4c73c4d9..bff08fbf2 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -105,11 +105,11 @@ export const interaction = () => { return initInteraction() } -export const isNumber = d => typeof d === "number" -export const isArray = d => Array.isArray(d) -export const isObj = d => d !== null && typeof d === "object" -export const isNull = d => d == null -export const isFn = d => typeof d === "function" +export const isNumber = (d: any): d is number => typeof d === "number" +export const isArray = (d: any): d is any[] => Array.isArray(d) +export const isObj = (d: any): d is Record => d !== null && typeof d === "object" +export const isNull = (d: any): d is null => d == null +export const isFn = (d: any): d is Function => typeof d === "function" export const isInteraction = (ix: IIx) => { if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false @@ -198,7 +198,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) return ix } -export const makeArgument = arg => ix => { +export const makeArgument = (arg: Record) => (ix: IIx) => { let tempId = uuidv4() ix.message.arguments.push(tempId) diff --git a/packages/sdk/src/test-utils/authz-fn.ts b/packages/sdk/src/test-utils/authz-fn.ts index 175c8acfe..79b5af1a2 100644 --- a/packages/sdk/src/test-utils/authz-fn.ts +++ b/packages/sdk/src/test-utils/authz-fn.ts @@ -61,7 +61,7 @@ interface IAuthzResolveMany { } export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) { - return function (account: IAcct) { + return function (account: IAcct): IAcct { const tempId = opts.tempId || "AUTHZ_RESOLVE_MANY" return { ...account, @@ -79,8 +79,8 @@ export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) } } -export function authzDeepResolveMany(opts = {}, depth = 1) { - return function (account) { +export function authzDeepResolveMany(opts: IAuthzResolveMany = {authorizations: []}, depth = 1) { + return function (account: IAcct): IAcct { const tempId = opts.tempId || "AUTHZ_DEEP_RESOLVE_MANY" return { ...account, From ffe5d30fa51652fef5f9335ac99b9cec03eefe50 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:59:52 -0400 Subject: [PATCH 36/45] fix path to interactions --- packages/sdk/src/build/build-payer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/src/build/build-payer.js b/packages/sdk/src/build/build-payer.js index 7e27fa817..e791af322 100644 --- a/packages/sdk/src/build/build-payer.js +++ b/packages/sdk/src/build/build-payer.js @@ -1,4 +1,4 @@ -import {pipe, prepAccount, PAYER} from "../interaction/interaction.js" +import {pipe, prepAccount, PAYER} from "../interaction/interaction" export function payer(ax = []) { if (!Array.isArray(ax)) ax = [ax] From 1921cbfdcf80f659ba88f3018b0274d2d7466d4a Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Tue, 7 Nov 2023 08:03:39 -0500 Subject: [PATCH 37/45] revert changes to changelogs --- packages/config/CHANGELOG.md | 15 --------------- packages/fcl-bundle/CHANGELOG.md | 8 -------- packages/fcl-wc/CHANGELOG.md | 14 -------------- packages/fcl/CHANGELOG.md | 20 -------------------- packages/rlp/CHANGELOG.md | 8 -------- packages/sdk/CHANGELOG.md | 18 ------------------ packages/transport-grpc/CHANGELOG.md | 14 -------------- packages/transport-http/CHANGELOG.md | 14 -------------- packages/typedefs/CHANGELOG.md | 6 ------ packages/types/CHANGELOG.md | 13 ------------- packages/util-actor/CHANGELOG.md | 8 -------- packages/util-address/CHANGELOG.md | 8 -------- packages/util-encode-key/CHANGELOG.md | 14 -------------- packages/util-invariant/CHANGELOG.md | 8 -------- packages/util-logger/CHANGELOG.md | 8 -------- packages/util-template/CHANGELOG.md | 13 ------------- packages/util-uid/CHANGELOG.md | 8 -------- 17 files changed, 197 deletions(-) diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index ad8d825cc..b15da29f7 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,20 +1,5 @@ # @onflow/config -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5) Thanks [@nialexsan](https://github.com/nialexsan)! - Add Typescript to @onflow/config - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-logger@1.3.0-typescript.0 - - @onflow/util-actor@1.3.0-typescript.0 - ## 1.1.2 ### Patch Changes diff --git a/packages/fcl-bundle/CHANGELOG.md b/packages/fcl-bundle/CHANGELOG.md index 301c92ac5..b182bc8e7 100644 --- a/packages/fcl-bundle/CHANGELOG.md +++ b/packages/fcl-bundle/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/fcl-bundle -## 1.4.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Switched to rollup-plugin-typescript2 - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.3.1 ### Patch Changes diff --git a/packages/fcl-wc/CHANGELOG.md b/packages/fcl-wc/CHANGELOG.md index 5c7527319..612d3c282 100644 --- a/packages/fcl-wc/CHANGELOG.md +++ b/packages/fcl-wc/CHANGELOG.md @@ -1,19 +1,5 @@ # @onflow/fcl-wc -## 5.0.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-logger@1.3.0-typescript.0 - - @onflow/config@1.2.0-typescript.0 - - @onflow/fcl@1.8.0-typescript.0 - ## 4.0.0 ### Patch Changes diff --git a/packages/fcl/CHANGELOG.md b/packages/fcl/CHANGELOG.md index 1f080e91c..503389d36 100644 --- a/packages/fcl/CHANGELOG.md +++ b/packages/fcl/CHANGELOG.md @@ -1,25 +1,5 @@ # @onflow/fcl -## 1.8.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`81d4b40e`](https://github.com/onflow/fcl-js/commit/81d4b40e5b76ffb85b6185a274ae1cbce5988e7b), [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: - - @onflow/types@1.2.0-typescript.0 - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-template@1.2.0-typescript.0 - - @onflow/util-address@1.2.0-typescript.0 - - @onflow/util-logger@1.3.0-typescript.0 - - @onflow/util-uid@1.2.0-typescript.0 - - @onflow/rlp@1.2.0-typescript.0 - - @onflow/util-actor@1.3.0-typescript.0 - - @onflow/config@1.2.0-typescript.0 - - @onflow/sdk@1.3.0-typescript.0 - ## 1.7.0 ### Minor Changes diff --git a/packages/rlp/CHANGELOG.md b/packages/rlp/CHANGELOG.md index 99b31e860..7b291c04e 100644 --- a/packages/rlp/CHANGELOG.md +++ b/packages/rlp/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/rlp -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.1.0 ### Minor Changes diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index f9aecf820..0a81749b7 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,23 +1,5 @@ # @onflow/sdk -## 1.3.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2), [`6b81c1ff`](https://github.com/onflow/fcl-js/commit/6b81c1ffc54ed1c073d0b6581df5fb34d7a33ec5), [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-template@1.2.0-typescript.0 - - @onflow/util-address@1.2.0-typescript.0 - - @onflow/util-logger@1.3.0-typescript.0 - - @onflow/rlp@1.2.0-typescript.0 - - @onflow/transport-http@1.8.0-typescript.0 - - @onflow/util-actor@1.3.0-typescript.0 - - @onflow/config@1.2.0-typescript.0 - ## 1.2.3 ### Patch Changes diff --git a/packages/transport-grpc/CHANGELOG.md b/packages/transport-grpc/CHANGELOG.md index 60b4edf4b..b9aedc552 100644 --- a/packages/transport-grpc/CHANGELOG.md +++ b/packages/transport-grpc/CHANGELOG.md @@ -1,19 +1,5 @@ # @onflow/transport-grpc -## 1.3.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-template@1.2.0-typescript.0 - - @onflow/util-address@1.2.0-typescript.0 - - @onflow/rlp@1.2.0-typescript.0 - ## 1.2.2 ### Patch Changes diff --git a/packages/transport-http/CHANGELOG.md b/packages/transport-http/CHANGELOG.md index df89ead5e..d21ec051f 100644 --- a/packages/transport-http/CHANGELOG.md +++ b/packages/transport-http/CHANGELOG.md @@ -1,19 +1,5 @@ # @onflow/transport-http -## 1.8.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/util-template@1.2.0-typescript.0 - - @onflow/util-address@1.2.0-typescript.0 - - @onflow/util-logger@1.3.0-typescript.0 - ## 1.7.2 ### Patch Changes diff --git a/packages/typedefs/CHANGELOG.md b/packages/typedefs/CHANGELOG.md index 69aa86833..2180a078a 100644 --- a/packages/typedefs/CHANGELOG.md +++ b/packages/typedefs/CHANGELOG.md @@ -1,11 +1,5 @@ # @onflow/typedefs -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.1.1 ### Patch Changes diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index cdc39904d..d346f1c99 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,18 +1,5 @@ # @onflow/types -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`81d4b40e`](https://github.com/onflow/fcl-js/commit/81d4b40e5b76ffb85b6185a274ae1cbce5988e7b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert @onflow/types to TypeScript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: - - @onflow/util-logger@1.3.0-typescript.0 - ## 1.1.0 ### Minor Changes diff --git a/packages/util-actor/CHANGELOG.md b/packages/util-actor/CHANGELOG.md index 572bd2299..c01689dd0 100644 --- a/packages/util-actor/CHANGELOG.md +++ b/packages/util-actor/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/util-actor -## 1.3.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`0960cdce`](https://github.com/onflow/fcl-js/commit/0960cdce6808b265ef92791da06a6772e9353537) Thanks [@nialexsan](https://github.com/nialexsan)! - Enhance TS support for @onflow/util-actor - ## 1.2.0 ### Minor Changes diff --git a/packages/util-address/CHANGELOG.md b/packages/util-address/CHANGELOG.md index fb931d5d4..c014ddafa 100644 --- a/packages/util-address/CHANGELOG.md +++ b/packages/util-address/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/util-address -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.1.0 ### Minor Changes diff --git a/packages/util-encode-key/CHANGELOG.md b/packages/util-encode-key/CHANGELOG.md index 7a2ec43da..a2a08e51f 100644 --- a/packages/util-encode-key/CHANGELOG.md +++ b/packages/util-encode-key/CHANGELOG.md @@ -1,19 +1,5 @@ # @onflow/util-encode-key -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: - - @onflow/util-invariant@1.2.0-typescript.0 - - @onflow/rlp@1.2.0-typescript.0 - ## 1.1.0 ### Minor Changes diff --git a/packages/util-invariant/CHANGELOG.md b/packages/util-invariant/CHANGELOG.md index e2aa26bbf..826b3b5d4 100644 --- a/packages/util-invariant/CHANGELOG.md +++ b/packages/util-invariant/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/util-invariant -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.1.0 ### Minor Changes diff --git a/packages/util-logger/CHANGELOG.md b/packages/util-logger/CHANGELOG.md index 89d086a5c..7d532bf11 100644 --- a/packages/util-logger/CHANGELOG.md +++ b/packages/util-logger/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/util-logger -## 1.3.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.2.2 ### Patch Changes diff --git a/packages/util-template/CHANGELOG.md b/packages/util-template/CHANGELOG.md index ed98b7483..1d6b910bd 100644 --- a/packages/util-template/CHANGELOG.md +++ b/packages/util-template/CHANGELOG.md @@ -1,18 +1,5 @@ # @onflow/util-template -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - -### Patch Changes - -- Updated dependencies [[`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b), [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2)]: - - @onflow/util-logger@1.3.0-typescript.0 - ## 1.1.0 ### Minor Changes diff --git a/packages/util-uid/CHANGELOG.md b/packages/util-uid/CHANGELOG.md index 49e19395e..841eb6100 100644 --- a/packages/util-uid/CHANGELOG.md +++ b/packages/util-uid/CHANGELOG.md @@ -1,13 +1,5 @@ # @onflow/util-uid -## 1.2.0-typescript.0 - -### Minor Changes - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`9fca84a3`](https://github.com/onflow/fcl-js/commit/9fca84a3151d7f6aeb33870a302e9793f024516b) Thanks [@nialexsan](https://github.com/nialexsan)! - Convert to Typescript - -- [#1801](https://github.com/onflow/fcl-js/pull/1801) [`86ce9f75`](https://github.com/onflow/fcl-js/commit/86ce9f75b5542a6bce76012e36a7a3d4fb6867f2) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build - ## 1.1.0 ### Minor Changes From cb56493ef84a8a83d7655f50a2e0fd21c64e5694 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:51:54 -0500 Subject: [PATCH 38/45] fix types for resolve-accounts --- packages/sdk/src/resolve/resolve-accounts.ts | 41 ++++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/sdk/src/resolve/resolve-accounts.ts b/packages/sdk/src/resolve/resolve-accounts.ts index 856fd10cb..4733ce44d 100644 --- a/packages/sdk/src/resolve/resolve-accounts.ts +++ b/packages/sdk/src/resolve/resolve-accounts.ts @@ -14,12 +14,12 @@ const isFn = (v: any): v is Function => "function" === typeof v || v instanceof Function) -const genAccountId = (...ids) => ids.join("-") +const genAccountId = (...ids: (string | boolean | undefined)[]) => ids.join("-") -const ROLES = { - PAYER: "payer", - PROPOSER: "proposer", - AUTHORIZATIONS: "authorizations", +enum ROLES { + PAYER = "payer", + PROPOSER = "proposer", + AUTHORIZATIONS = "authorizations", } function debug() { @@ -49,7 +49,7 @@ function recurseFlatMap(el: T, depthLimit = 3) { ) } -export function buildPreSignable(acct: IAcct, ix: IIx) { +export function buildPreSignable(acct: Partial, ix: IIx) { try { return { f_type: "PreSignable", @@ -90,7 +90,7 @@ async function removeUnusedIxAccounts(ix: IIx, opts: Record) { } } -function addAccountToIx(ix, newAccount) { +function addAccountToIx(ix: IIx, newAccount: IAcct) { if ( typeof newAccount.addr === "string" && (typeof newAccount.keyId === "number" || @@ -140,10 +140,10 @@ function uniqueAccountsFlatMap(accounts: IAcct[]) { } async function recurseResolveAccount( - ix, - currentAccountTempId, + ix: IIx, + currentAccountTempId: string, depthLimit = MAX_DEPTH_LIMIT, - {debugLogger} + {debugLogger}: {debugLogger: (msg?: string, indent?: number) => void} ) { if (depthLimit <= 0) { throw new Error( @@ -180,18 +180,18 @@ async function recurseResolveAccount( let flatResolvedAccounts = recurseFlatMap(resolvedAccounts) - flatResolvedAccounts = flatResolvedAccounts.map(flatResolvedAccount => + flatResolvedAccounts = flatResolvedAccounts.map((flatResolvedAccount: IAcct) => addAccountToIx(ix, flatResolvedAccount) ) account.resolve = flatResolvedAccounts.map( - flatResolvedAccount => flatResolvedAccount.tempId + (flatResolvedAccount: IAcct) => flatResolvedAccount.tempId ) account = addAccountToIx(ix, account) const recursedAccounts = await Promise.all( - flatResolvedAccounts.map(async resolvedAccount => { + flatResolvedAccounts.map(async (resolvedAccount: IAcct) => { return await recurseResolveAccount( ix, resolvedAccount.tempId, @@ -216,7 +216,14 @@ async function recurseResolveAccount( return account.tempId } -async function resolveAccountType(ix: IIx, type, {debugLogger}) { +const getAccountTempIDs = (rawTempIds: string | string[] | null) => { + if (rawTempIds === null) { + return [] + } + return Array.isArray(rawTempIds) ? rawTempIds : [rawTempIds] +} + +async function resolveAccountType(ix: IIx, type: ROLES, {debugLogger}: {debugLogger: (msg?: string, indent?: number) => void}) { invariant( ix && typeof ix === "object", "resolveAccountType Error: ix not defined" @@ -228,7 +235,7 @@ async function resolveAccountType(ix: IIx, type, {debugLogger}) { "resolveAccountType Error: type must be 'payer', 'proposer' or 'authorizations'" ) - let accountTempIDs = Array.isArray(ix[type]) ? ix[type] : [ix[type]] + let accountTempIDs = getAccountTempIDs(ix[type]) let allResolvedAccounts: IAcct[] = [] for (let accountId of accountTempIDs) { @@ -278,9 +285,9 @@ async function resolveAccountType(ix: IIx, type, {debugLogger}) { ) } - ix[type] = Array.isArray(ix[type]) + ix[type] = (Array.isArray(ix[type]) ? [...new Set(allResolvedAccounts.map(acct => acct.tempId))] - : allResolvedAccounts[0].tempId + : allResolvedAccounts[0].tempId) as string & string[] // Ensure all payers are of the same account if (type === ROLES.PAYER) { From 103a4ffa60c0fd8c95c328e58d800d97d76ed229 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:49:47 -0500 Subject: [PATCH 39/45] address comments --- packages/sdk/readme.md | 2 +- .../sdk/src/interaction/interaction.test.ts | 8 +-- packages/sdk/src/interaction/interaction.ts | 52 +++++++++---------- packages/sdk/src/test-utils/authz-fn.ts | 16 +++--- packages/transport-http/src/send-http.ts | 52 +++++++++---------- packages/transport-http/src/send-ping.ts | 4 +- packages/typedefs/src/interaction.ts | 4 +- 7 files changed, 69 insertions(+), 69 deletions(-) diff --git a/packages/sdk/readme.md b/packages/sdk/readme.md index 65bef283a..a85319f90 100644 --- a/packages/sdk/readme.md +++ b/packages/sdk/readme.md @@ -497,7 +497,7 @@ const response = await sdk.send(await sdk.build([ - [Builders](./src/build) - - [`sdk.args` & `sdk.arg`](./src/build/build-arguments) + - [`sdk.args` & `sdk.arg`](./src/build/build-arguments.ts) - [`sdk.atBlockHeight`](./src/build/build-at-block-height.js) - [`sdk.atBlockId`](./src/build/build-at-block-id.js) - [`sdk.authorizations` & `authorization`](./src/build/build-authorizations.js) diff --git a/packages/sdk/src/interaction/interaction.test.ts b/packages/sdk/src/interaction/interaction.test.ts index 72baea36a..595a3ca50 100644 --- a/packages/sdk/src/interaction/interaction.test.ts +++ b/packages/sdk/src/interaction/interaction.test.ts @@ -1,10 +1,10 @@ import {resolveAccounts} from "../sdk" -import {IAcct, prepAccount, initAccount, initInteraction} from "./interaction" +import {InteractionAccount, prepAccount, initAccount, initInteraction} from "./interaction" describe("prepAccount", () => { test("prepAccount converts account object keyId to integer", async () => { const keyId = "1" - const acct: IAcct = { + const acct: InteractionAccount = { ...initAccount(), addr: "f8d6e0586b0a20c7", keyId, @@ -20,7 +20,7 @@ describe("prepAccount", () => { test("prepAccount converts authorization function keyId to integer", async () => { const keyId = "1" - const authz = (acct: IAcct): IAcct => { + const authz = (acct: InteractionAccount): InteractionAccount => { return { ...acct, addr: "f8d6e0586b0a20c7", @@ -43,7 +43,7 @@ describe("prepAccount", () => { }) test("prepAccount does not affect keyId if undefined/does not exist", async () => { - const authz = (acct: IAcct): IAcct => { + const authz = (acct: InteractionAccount): InteractionAccount => { return { ...acct, addr: "f8d6e0586b0a20c7", diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index bff08fbf2..24c2c6ee4 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -2,10 +2,10 @@ import {invariant} from "@onflow/util-invariant" import {v4 as uuidv4} from "uuid" import {log, LEVELS} from "@onflow/util-logger" -import { IAcct, ACCOUNT, PARAM, ARGUMENT, UNKNOWN, OK, IIx, AUTHORIZER, PAYER, SCRIPT, TRANSACTION, GET_TRANSACTION_STATUS, GET_TRANSACTION, GET_ACCOUNT, GET_EVENTS, PING, GET_BLOCK, GET_BLOCK_HEADER, GET_COLLECTION, GET_NETWORK_PARAMETERS, BAD, PROPOSER } from "@onflow/typedefs"; +import { InteractionAccount, ACCOUNT, PARAM, ARGUMENT, UNKNOWN, OK, Interaction, AUTHORIZER, PAYER, SCRIPT, TRANSACTION, GET_TRANSACTION_STATUS, GET_TRANSACTION, GET_ACCOUNT, GET_EVENTS, PING, GET_BLOCK, GET_BLOCK_HEADER, GET_COLLECTION, GET_NETWORK_PARAMETERS, BAD, PROPOSER } from "@onflow/typedefs"; -type AcctFn = (acct: IAcct) => IAcct; -type IAcctFn = AcctFn & Partial; +type AcctFn = (acct: InteractionAccount) => InteractionAccount; +type AccountFn = AcctFn & Partial; const ACCT = `{ "kind":"${ACCOUNT}", @@ -87,10 +87,10 @@ const IX = `{ } }` -const KEYS = new Set(Object.keys(JSON.parse(IX) as IIx)) +const KEYS = new Set(Object.keys(JSON.parse(IX) as Interaction)) -export const initInteraction = (): IIx => JSON.parse(IX) +export const initInteraction = (): Interaction => JSON.parse(IX) /** * @deprecated */ @@ -111,29 +111,29 @@ export const isObj = (d: any): d is Record => d !== null && typeof export const isNull = (d: any): d is null => d == null export const isFn = (d: any): d is Function => typeof d === "function" -export const isInteraction = (ix: IIx) => { +export const isInteraction = (ix: Interaction) => { if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false for (let key of KEYS) if (!ix.hasOwnProperty(key)) return false return true } -export const Ok = (ix: IIx) => { +export const Ok = (ix: Interaction) => { ix.status = OK return ix } -export const Bad = (ix: IIx, reason: string) => { +export const Bad = (ix: Interaction, reason: string) => { ix.status = BAD ix.reason = reason return ix } -const makeIx = (wat: string) => (ix: IIx) => { +const makeIx = (wat: string) => (ix: Interaction) => { ix.tag = wat return Ok(ix) } -const prepAccountKeyId = (acct: Partial | IAcctFn): Partial | IAcctFn => { +const prepAccountKeyId = (acct: Partial | AccountFn): Partial | AccountFn => { if (acct.keyId == null) return acct invariant(!isNaN(parseInt(acct.keyId.toString())), "account.keyId must be an integer") @@ -141,16 +141,16 @@ const prepAccountKeyId = (acct: Partial | IAcctFn): Partial | IAcc return { ...acct, keyId: parseInt(acct.keyId.toString()), - } as IAcct | IAcctFn + } as InteractionAccount | AccountFn } interface IPrepAccountOpts { role?: typeof AUTHORIZER | typeof PAYER | typeof PROPOSER | null } -export const initAccount = (): IAcct => JSON.parse(ACCT) +export const initAccount = (): InteractionAccount => JSON.parse(ACCT) -export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) => (ix: IIx) => { +export const prepAccount = (acct: InteractionAccount | AccountFn, opts: IPrepAccountOpts = {}) => (ix: Interaction) => { invariant( typeof acct === "function" || typeof acct === "object", "prepAccount must be passed an authorization function or an account object" @@ -160,7 +160,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) const ACCOUNT = initAccount() const role = opts.role const tempId = uuidv4() - let account: Partial = {...acct} + let account: Partial = {...acct} if (acct.authorization && isFn(acct.authorization)) account = {resolve: acct.authorization} @@ -168,7 +168,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) const resolve = account.resolve if (resolve) { - account.resolve = (acct: IAcct, ...rest: any[]) => + account.resolve = (acct: InteractionAccount, ...rest: any[]) => [resolve, prepAccountKeyId].reduce( async (d, fn) => fn(await d, ...rest), acct @@ -198,7 +198,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) return ix } -export const makeArgument = (arg: Record) => (ix: IIx) => { +export const makeArgument = (arg: Record) => (ix: Interaction) => { let tempId = uuidv4() ix.message.arguments.push(tempId) @@ -228,7 +228,7 @@ export const makeGetBlockHeader /* */ = makeIx(GET_BLOCK_HEADER) export const makeGetCollection /* */ = makeIx(GET_COLLECTION) export const makeGetNetworkParameters /* */ = makeIx(GET_NETWORK_PARAMETERS) -const is = (wat: string) => (ix: IIx) => ix.tag === wat +const is = (wat: string) => (ix: Interaction) => ix.tag === wat export const isUnknown /* */ = is(UNKNOWN) export const isScript /* */ = is(SCRIPT) @@ -243,15 +243,15 @@ export const isGetBlockHeader /* */ = is(GET_BLOCK_HEADER) export const isGetCollection /* */ = is(GET_COLLECTION) export const isGetNetworkParameters /* */ = is(GET_NETWORK_PARAMETERS) -export const isOk /* */ = (ix: IIx) => ix.status === OK -export const isBad /* */ = (ix: IIx) => ix.status === BAD -export const why /* */ = (ix: IIx) => ix.reason +export const isOk /* */ = (ix: Interaction) => ix.status === OK +export const isBad /* */ = (ix: Interaction) => ix.status === BAD +export const why /* */ = (ix: Interaction) => ix.reason export const isAccount /* */ = (account: Record) => account.kind === ACCOUNT export const isParam /* */ = (param: Record) => param.kind === PARAM export const isArgument /* */ = (argument: Record) => argument.kind === ARGUMENT -const hardMode = (ix: IIx) => { +const hardMode = (ix: Interaction) => { for (let key of Object.keys(ix)) { if (!KEYS.has(key)) throw new Error(`"${key}" is an invalid root level Interaction property.`) @@ -259,7 +259,7 @@ const hardMode = (ix: IIx) => { return ix } -const recPipe = async (ix: IIx, fns: (Function | IIx)[] = []): Promise => { +const recPipe = async (ix: Interaction, fns: (Function | Interaction)[] = []): Promise => { try { ix = hardMode(await ix) if (isBad(ix)) throw new Error(`Interaction Error: ${ix.reason}`) @@ -283,21 +283,21 @@ export const pipe = (...args: any[]) => { const identity = (v: T, ..._: any[]) => v -export const get = (ix: IIx, key: string, fallback: any) => { +export const get = (ix: Interaction, key: string, fallback: any) => { return ix.assigns[key] == null ? fallback : ix.assigns[key] } -export const put = (key: string, value: any) => (ix: IIx) => { +export const put = (key: string, value: any) => (ix: Interaction) => { ix.assigns[key] = value return Ok(ix) } -export const update = (key: string, fn = identity) => (ix: IIx) => { +export const update = (key: string, fn = identity) => (ix: Interaction) => { ix.assigns[key] = fn(ix.assigns[key], ix) return Ok(ix) } -export const destroy = (key: string) => (ix: IIx) => { +export const destroy = (key: string) => (ix: Interaction) => { delete ix.assigns[key] return Ok(ix) } diff --git a/packages/sdk/src/test-utils/authz-fn.ts b/packages/sdk/src/test-utils/authz-fn.ts index 79b5af1a2..dce507949 100644 --- a/packages/sdk/src/test-utils/authz-fn.ts +++ b/packages/sdk/src/test-utils/authz-fn.ts @@ -1,9 +1,9 @@ -import { IAcct } from "@onflow/typedefs" +import { InteractionAccount } from "@onflow/typedefs" import {withPrefix} from "@onflow/util-address" -export const idof = (acct: IAcct) => `${withPrefix(acct.addr)}-${acct.keyId}` +export const idof = (acct: InteractionAccount) => `${withPrefix(acct.addr)}-${acct.keyId}` -export function sig(opts: Partial) { +export function sig(opts: Partial) { return ["SIGNATURE", opts.addr, opts.keyId].join(".") } @@ -12,8 +12,8 @@ interface IAuthzOpts { } export function authzFn(opts: IAuthzOpts = {}) { - return function (account: Partial) { - const acct: Partial = { + return function (account: Partial) { + const acct: Partial = { ...account, ...opts, resolve: null, @@ -40,7 +40,7 @@ interface IAuthzResolveOpts { } export function authzResolve(opts: IAuthzResolveOpts = {}) { - return function (account: IAcct) { + return function (account: InteractionAccount) { const {tempId, ...rest} = opts return { ...account, @@ -61,7 +61,7 @@ interface IAuthzResolveMany { } export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) { - return function (account: IAcct): IAcct { + return function (account: InteractionAccount): InteractionAccount { const tempId = opts.tempId || "AUTHZ_RESOLVE_MANY" return { ...account, @@ -80,7 +80,7 @@ export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) } export function authzDeepResolveMany(opts: IAuthzResolveMany = {authorizations: []}, depth = 1) { - return function (account: IAcct): IAcct { + return function (account: InteractionAccount): InteractionAccount { const tempId = opts.tempId || "AUTHZ_DEEP_RESOLVE_MANY" return { ...account, diff --git a/packages/transport-http/src/send-http.ts b/packages/transport-http/src/send-http.ts index 918601a78..b6d9a93fe 100644 --- a/packages/transport-http/src/send-http.ts +++ b/packages/transport-http/src/send-http.ts @@ -10,23 +10,23 @@ import {sendGetBlockHeader} from "./send-get-block-header.js" import {sendGetCollection} from "./send-get-collection.js" import {sendPing, ISendPingContext} from "./send-ping" import {sendGetNetworkParameters} from "./send-get-network-parameters.js" -import { IIx } from "@onflow/typedefs" +import { Interaction } from "@onflow/typedefs" -interface IIxModule { - isTransaction: (ix: IIx) => boolean; - isGetTransactionStatus: (ix: IIx) => boolean; - isGetTransaction: (ix: IIx) => boolean; - isScript: (ix: IIx) => boolean; - isGetAccount: (ix: IIx) => boolean; - isGetEvents: (ix: IIx) => boolean; - isGetBlock: (ix: IIx) => boolean; - isGetBlockHeader: (ix: IIx) => boolean; - isGetCollection: (ix: IIx) => boolean; - isPing: (ix: IIx) => boolean; - isGetNetworkParameters: (ix: IIx) => boolean; +interface InteractionModule { + isTransaction: (ix: Interaction) => boolean; + isGetTransactionStatus: (ix: Interaction) => boolean; + isGetTransaction: (ix: Interaction) => boolean; + isScript: (ix: Interaction) => boolean; + isGetAccount: (ix: Interaction) => boolean; + isGetEvents: (ix: Interaction) => boolean; + isGetBlock: (ix: Interaction) => boolean; + isGetBlockHeader: (ix: Interaction) => boolean; + isGetCollection: (ix: Interaction) => boolean; + isPing: (ix: Interaction) => boolean; + isGetNetworkParameters: (ix: Interaction) => boolean; } interface IContext extends ISendPingContext{ - ix: IIxModule; + ix: InteractionModule; } interface IOptsCommon { @@ -34,20 +34,20 @@ interface IOptsCommon { } interface IOpts extends IOptsCommon { - sendTransaction?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetTransactionStatus?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetTransaction?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendExecuteScript?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetAccount?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetEvents?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetBlockHeader?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetCollection?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendPing?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetBlock?: (ix: IIx, context: IContext, opts: IOptsCommon) => void - sendGetNetworkParameters?: (ix: IIx, context: IContext, opts: IOptsCommon) => void + sendTransaction?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetTransactionStatus?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetTransaction?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendExecuteScript?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetAccount?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetEvents?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetBlockHeader?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetCollection?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendPing?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetBlock?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void + sendGetNetworkParameters?: (ix: Interaction, context: IContext, opts: IOptsCommon) => void } -export const send = async (ix: IIx, context: IContext, opts: IOpts = {}) => { +export const send = async (ix: Interaction, context: IContext, opts: IOpts = {}) => { invariant( Boolean(opts?.node), `SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.` diff --git a/packages/transport-http/src/send-ping.ts b/packages/transport-http/src/send-ping.ts index da44d3570..378e1c8eb 100644 --- a/packages/transport-http/src/send-ping.ts +++ b/packages/transport-http/src/send-ping.ts @@ -1,6 +1,6 @@ import {invariant} from "@onflow/util-invariant" import {httpRequest as defaultHttpRequest} from "./http-request.js" -import { IIx } from "@onflow/typedefs"; +import { Interaction } from "@onflow/typedefs"; export interface ISendPingContext { response?: Function; @@ -12,7 +12,7 @@ interface ISendPingOpts { } -export async function sendPing(ix: IIx, context: ISendPingContext = {}, opts: ISendPingOpts = {}) { +export async function sendPing(ix: Interaction, context: ISendPingContext = {}, opts: ISendPingOpts = {}) { invariant(Boolean(opts.node), `SDK Send Ping Error: opts.node must be defined.`) invariant( Boolean(context.response), diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index 17208f911..df01c5d6f 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -23,7 +23,7 @@ export const AUTHORIZER /* */ = "authorizer" export const PAYER /* */ = "payer" export const PROPOSER /* */ = "proposer" -export interface IAcct { +export interface InteractionAccount { "kind": typeof ACCOUNT, "tempId": string | null, "addr": string | null, @@ -41,7 +41,7 @@ export interface IAcct { authorization: any, } -export interface IIx { +export interface Interaction { "tag": string, "assigns": Record, "status": string, From e50b20d749c2a7c8686bb0ec301464cef474794d Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:23:08 -0500 Subject: [PATCH 40/45] changeset --- .changeset/brown-dingos-taste.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/brown-dingos-taste.md diff --git a/.changeset/brown-dingos-taste.md b/.changeset/brown-dingos-taste.md new file mode 100644 index 000000000..3aea43be6 --- /dev/null +++ b/.changeset/brown-dingos-taste.md @@ -0,0 +1,9 @@ +--- +"@onflow/transport-http": minor +"@onflow/typedefs": minor +"@onflow/types": minor +"@onflow/fcl": minor +"@onflow/sdk": minor +--- + +TS conversion From 452e6f7f5a44e5789913827be58841015707d724 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:30:54 -0500 Subject: [PATCH 41/45] more descriptive names --- package-lock.json | 8 +++--- packages/sdk/src/encode/encode.ts | 28 +++++++++---------- .../sdk/src/resolve/resolve-signatures.ts | 8 +++--- packages/sdk/src/resolve/voucher.ts | 8 +++--- packages/typedefs/src/interaction.ts | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 35eef3738..f94d4572e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19691,7 +19691,7 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.8.1", + "version": "1.9.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", @@ -19777,7 +19777,7 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "5.0.1", + "version": "6.0.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", @@ -19795,7 +19795,7 @@ "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl": "^1.8.1" + "@onflow/fcl": "^1.9.0" } }, "packages/fcl/node_modules/eslint-plugin-jsdoc": { @@ -20589,7 +20589,7 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.8.1", + "version": "1.9.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", diff --git a/packages/sdk/src/encode/encode.ts b/packages/sdk/src/encode/encode.ts index 25e80ade2..3464dbda2 100644 --- a/packages/sdk/src/encode/encode.ts +++ b/packages/sdk/src/encode/encode.ts @@ -2,9 +2,9 @@ import {SHA3} from "sha3" import {encode, Buffer, EncodeInput} from "@onflow/rlp" import {sansPrefix} from "@onflow/util-address" -export const encodeTransactionPayload = (tx: ITx) => +export const encodeTransactionPayload = (tx: Transaction) => prependTransactionDomainTag(rlpEncode(preparePayload(tx))) -export const encodeTransactionEnvelope = (tx: ITx) => +export const encodeTransactionEnvelope = (tx: Transaction) => prependTransactionDomainTag(rlpEncode(prepareEnvelope(tx))) export const encodeTxIdFromVoucher = (voucher: IVoucher) => sha3_256(rlpEncode(prepareVoucher(voucher))) @@ -40,7 +40,7 @@ const sha3_256 = (msg: string) => { return sha.digest().toString("hex") } -const preparePayload = (tx: ITx) => { +const preparePayload = (tx: Transaction) => { validatePayload(tx) return [ @@ -56,13 +56,13 @@ const preparePayload = (tx: ITx) => { ] } -const prepareEnvelope = (tx: ITx) => { +const prepareEnvelope = (tx: Transaction) => { validateEnvelope(tx) return [preparePayload(tx), preparePayloadSignatures(tx)] } -const preparePayloadSignatures = (tx: ITx) => { +const preparePayloadSignatures = (tx: Transaction) => { const signers = collectSigners(tx) return tx.payloadSigs?.map((sig: ISig) => { @@ -86,7 +86,7 @@ const preparePayloadSignatures = (tx: ITx) => { }) } -const collectSigners = (tx: IVoucher | ITx) => { +const collectSigners = (tx: IVoucher | Transaction) => { const signers = new Map() let i = 0 @@ -148,14 +148,14 @@ const prepareVoucher = (voucher: IVoucher) => { ] } -const validatePayload = (tx: ITx) => { +const validatePayload = (tx: Transaction) => { payloadFields.forEach(field => checkField(tx, field)) proposalKeyFields.forEach(field => checkField(tx.proposalKey, field, "proposalKey") ) } -const validateEnvelope = (tx: ITx) => { +const validateEnvelope = (tx: Transaction) => { payloadSigsFields.forEach(field => checkField(tx, field)) tx.payloadSigs?.forEach((sig, index) => { payloadSigFields.forEach(field => @@ -201,25 +201,25 @@ interface IVoucherProposalKey { interface ISig { address: string, - keyId: number, + keyId: number | string, sig: string, } -export interface ITxProposalKey { +export interface TransactionProposalKey { address?: string - keyId?: number + keyId?: number | string sequenceNum?: number } -export interface ITx { +export interface Transaction { cadence: string | null; refBlock: string | null; computeLimit: string | null; arguments: IVoucherArgument[] - proposalKey: ITxProposalKey + proposalKey: TransactionProposalKey payer: string authorizers: string[] payloadSigs?: ISig[] - envelopeSigs?: ITxProposalKey[] + envelopeSigs?: TransactionProposalKey[] } export interface IVoucher { diff --git a/packages/sdk/src/resolve/resolve-signatures.ts b/packages/sdk/src/resolve/resolve-signatures.ts index 65d128681..9eb56fd64 100644 --- a/packages/sdk/src/resolve/resolve-signatures.ts +++ b/packages/sdk/src/resolve/resolve-signatures.ts @@ -1,8 +1,8 @@ import {InteractionAccount, Interaction, isTransaction} from "../interaction/interaction" import {sansPrefix} from "@onflow/util-address" import { - ITx, - ITxProposalKey, + Transaction, + TransactionProposalKey, encodeTransactionPayload as encodeInsideMessage, encodeTransactionEnvelope as encodeOutsideMessage, } from "../encode/encode" @@ -83,13 +83,13 @@ export function buildSignable(acct: InteractionAccount, message: string, ix: Int } } -function prepForEncoding(ix: Interaction): ITx { +function prepForEncoding(ix: Interaction): Transaction { const payerAddress = sansPrefix( (Array.isArray(ix.payer) ? ix.accounts[ix.payer[0]] : ix.accounts[ix.payer]) .addr || "" ) - const proposalKey: ITxProposalKey = ix.proposer ? { + const proposalKey: TransactionProposalKey = ix.proposer ? { address: sansPrefix(ix.accounts[ix.proposer].addr) || '', keyId: ix.accounts[ix.proposer].keyId || 0, sequenceNum: ix.accounts[ix.proposer].sequenceNum || 0, diff --git a/packages/sdk/src/resolve/voucher.ts b/packages/sdk/src/resolve/voucher.ts index df7539172..07db9aa26 100644 --- a/packages/sdk/src/resolve/voucher.ts +++ b/packages/sdk/src/resolve/voucher.ts @@ -1,8 +1,8 @@ import {withPrefix} from "@onflow/util-address" import {IVoucher, encodeTxIdFromVoucher} from "../encode/encode" -import { IIx } from "@onflow/typedefs" +import { Interaction } from "@onflow/typedefs" -export function findInsideSigners(ix: IIx) { +export function findInsideSigners(ix: Interaction) { // Inside Signers Are: (authorizers + proposer) - payer let inside = new Set(ix.authorizations) if (ix.proposer) { @@ -16,13 +16,13 @@ export function findInsideSigners(ix: IIx) { return Array.from(inside) } -export function findOutsideSigners(ix: IIx) { +export function findOutsideSigners(ix: Interaction) { // Outside Signers Are: (payer) let outside = new Set(Array.isArray(ix.payer) ? ix.payer : [ix.payer]) return Array.from(outside) } -export const createSignableVoucher = (ix: IIx) => { +export const createSignableVoucher = (ix: Interaction) => { const buildAuthorizers = () => { const authorizations = ix.authorizations .map(cid => withPrefix(ix.accounts[cid].addr)) diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index e87230edf..bf3ef6736 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -25,7 +25,7 @@ export const PROPOSER /* */ = "proposer" export interface InteractionAccount { "kind": typeof ACCOUNT, - "tempId": string | null, + "tempId": string, "addr": string | null, "keyId": number | string | null, "sequenceNum": number | null, From d2fceef63884471eaae0bee255f349b4feed1cbb Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:42:13 -0500 Subject: [PATCH 42/45] PKG -- [sdk] rename interfaces --- packages/sdk/src/encode/encode.ts | 48 ++++++++++++++--------------- packages/sdk/src/resolve/voucher.ts | 4 +-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/sdk/src/encode/encode.ts b/packages/sdk/src/encode/encode.ts index 3464dbda2..46d274d9b 100644 --- a/packages/sdk/src/encode/encode.ts +++ b/packages/sdk/src/encode/encode.ts @@ -6,7 +6,7 @@ export const encodeTransactionPayload = (tx: Transaction) => prependTransactionDomainTag(rlpEncode(preparePayload(tx))) export const encodeTransactionEnvelope = (tx: Transaction) => prependTransactionDomainTag(rlpEncode(prepareEnvelope(tx))) -export const encodeTxIdFromVoucher = (voucher: IVoucher) => +export const encodeTxIdFromVoucher = (voucher: Voucher) => sha3_256(rlpEncode(prepareVoucher(voucher))) const rightPaddedHexBuffer = (value: string, pad: number) => @@ -65,7 +65,7 @@ const prepareEnvelope = (tx: Transaction) => { const preparePayloadSignatures = (tx: Transaction) => { const signers = collectSigners(tx) - return tx.payloadSigs?.map((sig: ISig) => { + return tx.payloadSigs?.map((sig: Sig) => { return { signerIndex: signers.get(sig.address) || '', keyId: sig.keyId, @@ -86,7 +86,7 @@ const preparePayloadSignatures = (tx: Transaction) => { }) } -const collectSigners = (tx: IVoucher | Transaction) => { +const collectSigners = (tx: Voucher | Transaction) => { const signers = new Map() let i = 0 @@ -106,12 +106,12 @@ const collectSigners = (tx: IVoucher | Transaction) => { return signers } -const prepareVoucher = (voucher: IVoucher) => { +const prepareVoucher = (voucher: Voucher) => { validateVoucher(voucher) const signers = collectSigners(voucher) - const prepareSigs = (sigs: ISig[]) => { + const prepareSigs = (sigs: Sig[]) => { return sigs .map(({ address, keyId, sig }) => { return { signerIndex: signers.get(address) || '', keyId, sig } @@ -164,7 +164,7 @@ const validateEnvelope = (tx: Transaction) => { }) } -const validateVoucher = (voucher: IVoucher) => { +const validateVoucher = (voucher: Voucher) => { payloadFields.forEach(field => checkField(voucher, field)) proposalKeyFields.forEach(field => checkField(voucher.proposalKey, field, "proposalKey") @@ -188,18 +188,18 @@ const isString = (v: any): v is string => typeof v === "string" const isObject = (v: any) => v !== null && typeof v === "object" const isArray = (v: any) => isObject(v) && v instanceof Array -interface IVoucherArgument { +interface VoucherArgument { type: string value: string } -interface IVoucherProposalKey { +interface VoucherProposalKey { address: string keyId: number | null sequenceNum: number | null } -interface ISig { +interface Sig { address: string, keyId: number | string, sig: string, @@ -214,33 +214,33 @@ export interface Transaction { cadence: string | null; refBlock: string | null; computeLimit: string | null; - arguments: IVoucherArgument[] + arguments: VoucherArgument[] proposalKey: TransactionProposalKey payer: string authorizers: string[] - payloadSigs?: ISig[] + payloadSigs?: Sig[] envelopeSigs?: TransactionProposalKey[] } -export interface IVoucher { +export interface Voucher { cadence: string; refBlock: string; computeLimit: number; - arguments: IVoucherArgument[] - proposalKey: IVoucherProposalKey + arguments: VoucherArgument[] + proposalKey: VoucherProposalKey payer: string authorizers: string[] - payloadSigs: ISig[] - envelopeSigs: ISig[] + payloadSigs: Sig[] + envelopeSigs: Sig[] } -interface IPayloadField { +interface PayloadField { name: string, check: (v: any) => boolean, defaultVal?: string } -const payloadFields: IPayloadField[] = [ +const payloadFields: PayloadField[] = [ {name: "cadence", check: isString}, {name: "arguments", check: isArray}, {name: "refBlock", check: isString, defaultVal: "0"}, @@ -250,23 +250,23 @@ const payloadFields: IPayloadField[] = [ {name: "authorizers", check: isArray}, ] -const proposalKeyFields: IPayloadField[] = [ +const proposalKeyFields: PayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sequenceNum", check: isNumber}, ] -const payloadSigsFields: IPayloadField[] = [{name: "payloadSigs", check: isArray}] +const payloadSigsFields: PayloadField[] = [{name: "payloadSigs", check: isArray}] -const payloadSigFields: IPayloadField[] = [ +const payloadSigFields: PayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sig", check: isString}, ] -const envelopeSigsFields: IPayloadField[] = [{ name: "envelopeSigs", check: isArray }] +const envelopeSigsFields: PayloadField[] = [{ name: "envelopeSigs", check: isArray }] -const envelopeSigFields: IPayloadField[] = [ +const envelopeSigFields: PayloadField[] = [ {name: "address", check: isString}, {name: "keyId", check: isNumber}, {name: "sig", check: isString}, @@ -274,7 +274,7 @@ const envelopeSigFields: IPayloadField[] = [ const checkField = ( obj: Record, - field: IPayloadField, + field: PayloadField, base?: string, index?: number ) => { diff --git a/packages/sdk/src/resolve/voucher.ts b/packages/sdk/src/resolve/voucher.ts index 07db9aa26..02fd1a329 100644 --- a/packages/sdk/src/resolve/voucher.ts +++ b/packages/sdk/src/resolve/voucher.ts @@ -1,5 +1,5 @@ import {withPrefix} from "@onflow/util-address" -import {IVoucher, encodeTxIdFromVoucher} from "../encode/encode" +import {Voucher, encodeTxIdFromVoucher} from "../encode/encode" import { Interaction } from "@onflow/typedefs" export function findInsideSigners(ix: Interaction) { @@ -67,6 +67,6 @@ export const createSignableVoucher = (ix: Interaction) => { } } -export const voucherToTxId = (voucher: IVoucher) => { +export const voucherToTxId = (voucher: Voucher) => { return encodeTxIdFromVoucher(voucher) } From ba1dd47b33e25411ca9d2652384a7efad21b1a88 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:43:56 -0500 Subject: [PATCH 43/45] PKG -- [typedefs] fix merge conflict --- packages/typedefs/src/interaction.ts | 94 ++++++++++++++-------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index bf3ef6736..4f0dfb0e4 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -24,62 +24,62 @@ export const PAYER /* */ = "payer" export const PROPOSER /* */ = "proposer" export interface InteractionAccount { - "kind": typeof ACCOUNT, - "tempId": string, - "addr": string | null, - "keyId": number | string | null, - "sequenceNum": number | null, - "signature": string | null, - "signingFunction": any | null, - "resolve": any | null, - "role": { - "proposer": boolean, - "authorizer": boolean, - "payer": boolean, - "param"?: boolean, + kind: typeof ACCOUNT, + tempId: string, + addr: string | null, + keyId: number | string | null, + sequenceNum: number | null, + signature: string | null, + signingFunction: any | null, + resolve: any | null, + role: { + proposer: boolean, + authorizer: boolean, + payer: boolean, + param?: boolean, }, authorization: any, } export interface Interaction { - "tag": string, - "assigns": Record, - "status": string, - "reason": string | null, - "accounts": Record, - "params": Record, - "arguments": Record, - "message": { - "cadence": string | null, - "refBlock": string | null, - "computeLimit": string | null, - "proposer": string | null, - "payer": string | null, - "authorizations": string[], - "params": Record[], - "arguments": string[] + tag: string, + assigns: Record, + status: string, + reason: string | null, + accounts: Record, + params: Record, + arguments: Record, + message: { + cadence: string | null, + refBlock: string | null, + computeLimit: string | null, + proposer: string | null, + payer: string | null, + authorizations: string[], + params: Record[], + arguments: string[] }, - "proposer": string | null, - "authorizations": string[], - "payer": string[], - "events": { - "eventType": string | null, - "start": string | null, - "end": string | null, - "blockIds": string[] + proposer: string | null, + authorizations: string[], + payer: string[], + events: { + eventType: string | null, + start: string | null, + end: string | null, + blockIds: string[] }, - "transaction": { - "id": string | null + transaction: { + id: string | null }, - "block": { - "id": string | null, - "height": string | null, - "isSealed": boolean | null + block: { + id: string | null, + height: string | null, + isSealed: boolean | null }, - "account": { - "addr": string | null + account: { + addr: string | null }, - "collection": { - "id": string | null + collection: { + id: string | null } } \ No newline at end of file From 7fb02aa521a64822ee8f8d3a47e814332dab1989 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:48:16 -0500 Subject: [PATCH 44/45] PKG -- [typedefs] fix merge conflicts --- packages/typedefs/src/interaction.ts | 82 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/typedefs/src/interaction.ts b/packages/typedefs/src/interaction.ts index 4f0dfb0e4..ca8ea4c40 100644 --- a/packages/typedefs/src/interaction.ts +++ b/packages/typedefs/src/interaction.ts @@ -24,61 +24,61 @@ export const PAYER /* */ = "payer" export const PROPOSER /* */ = "proposer" export interface InteractionAccount { - kind: typeof ACCOUNT, - tempId: string, - addr: string | null, - keyId: number | string | null, - sequenceNum: number | null, - signature: string | null, - signingFunction: any | null, - resolve: any | null, + kind: typeof ACCOUNT + tempId: string + addr: string | null + keyId: number | string | null + sequenceNum: number | null + signature: string | null + signingFunction: any | null + resolve: any | null role: { - proposer: boolean, - authorizer: boolean, - payer: boolean, - param?: boolean, - }, - authorization: any, + proposer: boolean + authorizer: boolean + payer: boolean + param?: boolean + } + authorization: any } export interface Interaction { - tag: string, - assigns: Record, - status: string, - reason: string | null, - accounts: Record, - params: Record, - arguments: Record, + tag: string + assigns: Record + status: string + reason: string | null + accounts: Record + params: Record + arguments: Record message: { - cadence: string | null, - refBlock: string | null, - computeLimit: string | null, - proposer: string | null, - payer: string | null, - authorizations: string[], - params: Record[], + cadence: string | null + refBlock: string | null + computeLimit: string | null + proposer: string | null + payer: string | null + authorizations: string[] + params: Record[] arguments: string[] - }, - proposer: string | null, - authorizations: string[], - payer: string[], + } + proposer: string | null + authorizations: string[] + payer: string[] events: { - eventType: string | null, - start: string | null, - end: string | null, + eventType: string | null + start: string | null + end: string | null blockIds: string[] - }, + } transaction: { id: string | null - }, + } block: { - id: string | null, - height: string | null, + id: string | null + height: string | null isSealed: boolean | null - }, + } account: { addr: string | null - }, + } collection: { id: string | null } From cbd92f2d7af576b361ab631b302d36df3c508de3 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:58:44 -0500 Subject: [PATCH 45/45] PKG -- [sdk] fix interface imports --- packages/sdk/src/resolve/resolve-accounts.ts | 3 ++- packages/sdk/src/resolve/resolve-signatures.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/resolve/resolve-accounts.ts b/packages/sdk/src/resolve/resolve-accounts.ts index 87046c301..1617bbdcd 100644 --- a/packages/sdk/src/resolve/resolve-accounts.ts +++ b/packages/sdk/src/resolve/resolve-accounts.ts @@ -1,7 +1,8 @@ import {sansPrefix, withPrefix} from "@onflow/util-address" import {invariant} from "@onflow/util-invariant" import {log} from "@onflow/util-logger" -import {InteractionAccount, Interaction, isTransaction} from "../interaction/interaction" +import {isTransaction} from "../interaction/interaction" +import { Interaction, InteractionAccount } from "@onflow/typedefs"; import {createSignableVoucher} from "./voucher" import {v4 as uuidv4} from "uuid" diff --git a/packages/sdk/src/resolve/resolve-signatures.ts b/packages/sdk/src/resolve/resolve-signatures.ts index 9eb56fd64..70c2464af 100644 --- a/packages/sdk/src/resolve/resolve-signatures.ts +++ b/packages/sdk/src/resolve/resolve-signatures.ts @@ -1,4 +1,5 @@ -import {InteractionAccount, Interaction, isTransaction} from "../interaction/interaction" +import {isTransaction} from "../interaction/interaction" +import { Interaction, InteractionAccount } from "@onflow/typedefs"; import {sansPrefix} from "@onflow/util-address" import { Transaction,