From 67c04797689fea30c6769e1e242f074f7cb60ad1 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 24 Jun 2022 15:29:15 -0700 Subject: [PATCH 01/14] Release 1.1.0 --- .changeset/pre.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 7ad813ab2..0a8966476 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "pre", + "mode": "exit", "tag": "alpha", "initialVersions": { "@onflow/config": "1.0.1", From d588044a08d6cbe1c63ef974e77dec9cf187c779 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 10 Aug 2023 10:21:49 -0700 Subject: [PATCH 02/14] Fix types --- package-lock.json | 872 ++++++++++++++---- packages/fcl-bundle/package.json | 4 +- .../fcl-bundle/src/build/get-input-options.js | 16 +- packages/fcl-bundle/src/get-package-json.js | 3 +- packages/fcl-bundle/src/util.js | 5 + packages/sdk/package.json | 2 +- packages/sdk/tsconfig.json | 4 +- packages/util-actor/src/index.ts | 50 +- packages/util-address/.babelrc | 6 +- packages/util-address/.eslintrc.json | 18 +- packages/util-address/package.json | 8 +- .../src/{index.test.js => index.test.ts} | 0 packages/util-address/src/index.ts | 18 +- .../src/{index.test.js => index.test.ts} | 0 packages/util-invariant/src/index.ts | 15 +- packages/util-logger/package.json | 1 + packages/util-logger/src/util-logger.ts | 117 +-- packages/util-template/package.json | 1 + .../{template.test.js => template.test.ts} | 2 +- .../src/{template.js => template.ts} | 18 +- tsconfig.json | 10 +- 21 files changed, 848 insertions(+), 322 deletions(-) rename packages/util-address/src/{index.test.js => index.test.ts} (100%) rename packages/util-invariant/src/{index.test.js => index.test.ts} (100%) rename packages/util-template/src/{template.test.js => template.test.ts} (98%) rename packages/util-template/src/{template.js => template.ts} (77%) diff --git a/package-lock.json b/package-lock.json index 2e8a8253e..1e31f3d45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,14 @@ "ts-jest": "^29.1.1" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "license": "Apache-2.0", @@ -1997,13 +2005,36 @@ "node": "^14 || ^16 || ^17 || ^18 || ^19" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", + "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.0.0", - "license": "MIT", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.1.tgz", + "integrity": "sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -2020,11 +2051,13 @@ }, "node_modules/@eslint/eslintrc/node_modules/argparse": { "version": "2.0.1", - "license": "Python-2.0" + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dependencies": { "argparse": "^2.0.1" }, @@ -2033,8 +2066,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", - "license": "MIT", + "version": "8.46.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.46.0.tgz", + "integrity": "sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -2045,8 +2079,9 @@ "license": "MIT" }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "license": "Apache-2.0", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", @@ -2069,7 +2104,8 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", - "license": "BSD-3-Clause" + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, "node_modules/@hutson/parse-repository-url": { "version": "3.0.2", @@ -4835,31 +4871,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", @@ -5315,6 +5326,277 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.3.0.tgz", + "integrity": "sha512-IZYjYZ0ifGSLZbwMqIip/nOamFiWJ9AH+T/GYNZBWkVcyNQOFGtSMoWV7RvY4poYCMZ/4lHzNl796WOSNxmk8A==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.3.0", + "@typescript-eslint/type-utils": "6.3.0", + "@typescript-eslint/utils": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "natural-compare-lite": "^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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.3.0.tgz", + "integrity": "sha512-ibP+y2Gr6p0qsUkhs7InMdXrwldjxZw66wpcQq9/PzAroM45wdwyu81T+7RibNCh8oc0AgrsyCwJByncY0Ongg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.3.0", + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.3.0.tgz", + "integrity": "sha512-WlNFgBEuGu74ahrXzgefiz/QlVb+qg8KDTpknKwR7hMH+lQygWyx0CQFoUmMn1zDkQjTBBIn75IxtWss77iBIQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0" + }, + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.3.0.tgz", + "integrity": "sha512-7Oj+1ox1T2Yc8PKpBvOKWhoI/4rWFd1j7FA/rPE0lbBPXTKjdbtC+7Ev0SeBjEKkIhKWVeZSP+mR7y1Db1CdfQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/utils": "6.3.0", + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.3.0.tgz", + "integrity": "sha512-K6TZOvfVyc7MO9j60MkRNWyFSf86IbOatTKGrpTQnzarDZPYPVy0oe3myTMq7VjhfsUAbNUW8I5s+2lZvtx1gg==", + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.3.0.tgz", + "integrity": "sha512-Xh4NVDaC4eYKY4O3QGPuQNp5NxBAlEvNQYOqJquR2MePNxO11E5K3t5x4M4Mx53IZvtpW+mBxIT0s274fLUocg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.3.0.tgz", + "integrity": "sha512-hLLg3BZE07XHnpzglNBG8P/IXq/ZVXraEbgY7FM0Cnc1ehM8RMdn9mat3LubJ3KBeYXXPxV1nugWbQPjGeJk6Q==", + "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.3.0", + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/typescript-estree": "6.3.0", + "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.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.3.0.tgz", + "integrity": "sha512-kEhRRj7HnvaSjux1J9+7dBen15CdWmDnwrpyiHsFX6Qx2iW5LOBUgNefOFeh2PjWPlNwN8TOn6+4eBU3J/gupw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "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", @@ -5826,8 +6108,9 @@ } }, "node_modules/acorn": { - "version": "8.8.2", - "license": "MIT", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "bin": { "acorn": "bin/acorn" }, @@ -5854,7 +6137,8 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -5997,6 +6281,15 @@ "dev": true, "license": "ISC" }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", + "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/are-we-there-yet": { "version": "3.0.1", "dev": true, @@ -8375,24 +8668,26 @@ } }, "node_modules/eslint": { - "version": "8.35.0", - "license": "MIT", - "dependencies": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", - "@humanwhocodes/config-array": "^0.11.8", + "version": "8.46.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.46.0.tgz", + "integrity": "sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.1", + "@eslint/js": "^8.46.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.2", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -8400,23 +8695,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -8486,42 +8777,24 @@ } }, "node_modules/eslint-scope": { - "version": "7.1.1", - "license": "BSD-2-Clause", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "license": "Apache-2.0", - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "license": "Apache-2.0", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz", + "integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -8675,12 +8948,13 @@ } }, "node_modules/espree": { - "version": "9.4.1", - "license": "BSD-2-Clause", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -8973,6 +9247,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", @@ -9782,7 +10072,8 @@ }, "node_modules/globals": { "version": "13.20.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dependencies": { "type-fest": "^0.20.2" }, @@ -9843,13 +10134,18 @@ }, "node_modules/graceful-fs": { "version": "4.2.10", - "dev": true, "license": "ISC" }, "node_modules/grapheme-splitter": { "version": "1.0.4", + "dev": true, "license": "MIT" }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" + }, "node_modules/growly": { "version": "1.3.0", "dev": true, @@ -12551,14 +12847,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sdsl": { - "version": "4.3.0", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "license": "MIT" @@ -13182,7 +13470,8 @@ }, "node_modules/levn": { "version": "0.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -13760,7 +14049,6 @@ }, "node_modules/make-dir": { "version": "3.1.0", - "dev": true, "license": "MIT", "dependencies": { "semver": "^6.0.0" @@ -13774,7 +14062,6 @@ }, "node_modules/make-dir/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -14319,6 +14606,12 @@ "version": "1.4.0", "license": "MIT" }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "dev": true, @@ -15343,15 +15636,16 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "license": "MIT", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -16019,7 +16313,6 @@ }, "node_modules/pkg-dir": { "version": "4.2.0", - "dev": true, "license": "MIT", "dependencies": { "find-up": "^4.0.0" @@ -16138,7 +16431,8 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "engines": { "node": ">= 0.8.0" } @@ -16841,16 +17135,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/regexpu-core": { "version": "5.3.1", "license": "MIT", @@ -17012,6 +17296,91 @@ "fsevents": "~2.3.2" } }, + "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/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": { + "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.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/run-async": { "version": "2.4.1", "dev": true, @@ -18069,6 +18438,18 @@ "node": ">=8" } }, + "node_modules/ts-api-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.1.tgz", + "integrity": "sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==", + "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", @@ -18394,7 +18775,8 @@ }, "node_modules/type-check": { "version": "0.4.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dependencies": { "prelude-ls": "^1.2.1" }, @@ -18412,7 +18794,8 @@ }, "node_modules/type-fest": { "version": "0.20.2", - "license": "(MIT OR CC0-1.0)", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "engines": { "node": ">=10" }, @@ -18877,6 +19260,7 @@ }, "node_modules/word-wrap": { "version": "1.2.3", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -19178,16 +19562,16 @@ }, "packages/config": { "name": "@onflow/config", - "version": "1.1.1", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-actor": "^1.2.0", + "@onflow/util-actor": "^1.3.0-alpha.0", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/estree": "^1.0.1", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -19247,26 +19631,26 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.5.0", + "version": "1.6.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1", + "@onflow/config": "^1.2.0-alpha.0", "@onflow/interaction": "0.0.11", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.1", - "@onflow/types": "^1.1.0", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", - "@onflow/util-template": "^1.1.0", - "@onflow/util-uid": "^1.1.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", + "@onflow/util-actor": "^1.3.0-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0", + "@onflow/util-uid": "^1.2.0-alpha.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/typedefs": "^1.2.0-alpha.0", "@types/node": "^18.13.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", @@ -19301,7 +19685,7 @@ }, "packages/fcl-bundle": { "name": "@onflow/fcl-bundle", - "version": "1.3.1", + "version": "1.4.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", @@ -19311,11 +19695,11 @@ "@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" @@ -19330,25 +19714,25 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "3.0.0", + "version": "4.0.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.1", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", + "@onflow/config": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.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-alpha.0", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl": "^1.5.0" + "@onflow/fcl": "^1.6.0-alpha.0" } }, "packages/fcl/node_modules/eslint-plugin-jsdoc": { @@ -19875,37 +20259,37 @@ }, "packages/rlp": { "name": "@onflow/rlp", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "MPL-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "buffer": "^6.0.3" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.2.1", + "version": "1.3.0-alpha.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.0", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", - "@onflow/util-template": "^1.1.0", + "@onflow/config": "^1.2.0-alpha.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/transport-http": "^1.8.0-alpha.0", + "@onflow/util-actor": "^1.3.0-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/typedefs": "^1.2.0-alpha.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", @@ -19970,21 +20354,21 @@ }, "packages/transport-grpc": { "name": "@onflow/transport-grpc", - "version": "1.2.1", + "version": "1.3.0-alpha.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-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", "jest": "^29.5.0" } }, @@ -20012,34 +20396,34 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.7.0", + "version": "1.8.0-alpha.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.1", - "@onflow/util-template": "^1.1.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.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.1", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", "jest": "^29.5.0" } }, "packages/typedefs": { "name": "@onflow/typedefs", - "version": "1.1.1", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", @@ -20050,58 +20434,156 @@ }, "packages/types": { "name": "@onflow/types", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } }, "packages/util-actor": { "name": "@onflow/util-actor", - "version": "1.2.0", + "version": "1.3.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "queue-microtask": "1.2.3" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } }, "packages/util-address": { "name": "@onflow/util-address", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.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.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" } }, + "packages/util-address/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-address/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-address/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-address/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/util-address/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-address/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-address/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-encode-key": { "name": "@onflow/util-encode-key", - "version": "1.1.0", + "version": "1.2.0-alpha.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-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.8.0", @@ -20111,51 +20593,51 @@ }, "packages/util-invariant": { "name": "@onflow/util-invariant", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", "jest": "^29.5.0" } }, "packages/util-logger": { "name": "@onflow/util-logger", - "version": "1.2.1", + "version": "1.3.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1" + "@onflow/config": "^1.2.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } }, "packages/util-template": { "name": "@onflow/util-template", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } }, "packages/util-uid": { "name": "@onflow/util-uid", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "jest": "^29.5.0" } } diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 9f3b3f1ca..0685ea460 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -20,11 +20,11 @@ "@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..451eb8447 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -4,10 +4,12 @@ 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 builtinModules = require("builtin-modules") +const path = require("path") +const {getPackageRoot} = require("../util") const SUPPRESSED_WARNING_CODES = [ "MISSING_GLOBAL_NAME", @@ -44,7 +46,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,7 +60,9 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - typescript(), + typescript({ + tsconfig: path.resolve(getPackageRoot(), "tsconfig.json"), + }), replace({ preventAssignment: true, PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), diff --git a/packages/fcl-bundle/src/get-package-json.js b/packages/fcl-bundle/src/get-package-json.js index e62e11be9..a2e9de146 100644 --- a/packages/fcl-bundle/src/get-package-json.js +++ b/packages/fcl-bundle/src/get-package-json.js @@ -1,7 +1,8 @@ const {existsSync, readFileSync} = require("fs") const {resolve} = require("path") +const {getPackageRoot} = require("./util") -module.exports = function getPackageJSON(cwd = process.cwd()) { +module.exports = function getPackageJSON(cwd = getPackageRoot()) { const pathPackageJSON = resolve(cwd, "package.json") if (existsSync(pathPackageJSON)) { return JSON.parse(readFileSync(pathPackageJSON)) diff --git a/packages/fcl-bundle/src/util.js b/packages/fcl-bundle/src/util.js index 57ca2501e..33533b319 100644 --- a/packages/fcl-bundle/src/util.js +++ b/packages/fcl-bundle/src/util.js @@ -10,8 +10,13 @@ function isString(obj) { return typeof obj === "string" || obj instanceof String } +function getPackageRoot() { + return process.cwd() +} + module.exports = { isArray, isObject, isString, + getPackageRoot, } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 86a213846..c5cb7161f 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/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/util-actor/src/index.ts b/packages/util-actor/src/index.ts index f89b9b4d2..19247e863 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -1,5 +1,5 @@ import {mailbox as createMailbox, type IMailbox} from "./mailbox" -const queueMicrotask = require("queue-microtask") +import * as queueMicrotask from "queue-microtask" export const INIT = "INIT" export const SUBSCRIBE = "SUBSCRIBE" @@ -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-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 44140f32e..e78e83e37 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": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.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.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, 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-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/package.json b/packages/util-logger/package.json index 4b6d5b767..1bc592f80 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -20,6 +20,7 @@ "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", + "types": "dist/types/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 e57cbb0e1..3f807abbd 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -2,35 +2,32 @@ import {config} from "@onflow/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 - * + * @enum */ -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 + * @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} @@ -42,26 +39,30 @@ 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}) => { +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 @@ -89,30 +90,38 @@ 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} - * + * + * @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 + * * @example * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) - * + * */ -log.deprecate = ({ - pkg, - subject, - transition, - level = LEVELS.warn, - message = "", - callback = null, +log.deprecate = (options: { + pkg?: string + subject?: string + transition?: string + level?: number + message?: string + callback?: (...args: T[]) => U }) => { - const capitalizeFirstLetter = string => { - return string.charAt(0).toUpperCase() + string.slice(1) + 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 = () => @@ -137,7 +146,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/package.json b/packages/util-template/package.json index 9ee44d304..de9015a90 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -20,6 +20,7 @@ "main": "dist/template.js", "module": "dist/template.module.js", "unpkg": "dist/template.umd.js", + "types": "dist/types/template.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-template/src/template.test.js b/packages/util-template/src/template.test.ts similarity index 98% rename from packages/util-template/src/template.test.js rename to packages/util-template/src/template.test.ts index 6014f676c..65527b8c9 100644 --- a/packages/util-template/src/template.test.js +++ b/packages/util-template/src/template.test.ts @@ -23,7 +23,7 @@ describe("interleave", () => { }) }) -const _ = (msg, a, b) => { +const _ = (msg, a, b?) => { if (b == null) { test(msg, () => expect(a).toMatchSnapshot()) } else { diff --git a/packages/util-template/src/template.js b/packages/util-template/src/template.ts similarity index 77% rename from packages/util-template/src/template.js rename to packages/util-template/src/template.ts index e064dab37..1e2a83910 100644 --- a/packages/util-template/src/template.js +++ b/packages/util-template/src/template.ts @@ -1,6 +1,10 @@ import {log} from "@onflow/util-logger" -export function interleave(a = [], b = [], c = []) { +export function interleave( + a: unknown[] = [], + b: unknown[] = [], + c: unknown[] = [] +) { if (!a.length && !b.length) return c if (!a.length) return c if (!b.length) return [...c, a[0]] @@ -14,7 +18,7 @@ export function interleave(a = [], b = [], c = []) { return interleave(aRest, bRest, c) } -function recApply(d) { +function recApply(d: unknown): (x: unknown) => string { return function (arg1) { if (typeof arg1 === "function") { log.deprecate({ @@ -29,12 +33,10 @@ function recApply(d) { } } -/** - * @param {(string|Array.<*>)} head - * @param {Array.<*>} rest - * @returns {{function(): string}} - */ -export function template(head, ...rest) { +export function template( + head: string | TemplateStringsArray, + ...rest: unknown[] +): (x: unknown) => string | string { if (typeof head === "string") return () => head if (Array.isArray(head)) { return d => 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 6f2de996a138f5b4460078be27f857d420d5a4c0 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 10 Aug 2023 15:50:06 -0700 Subject: [PATCH 03/14] stash --- package-lock.json | 200 ++++++++++++++++++ packages/util-template/.babelrc | 6 +- .../__snapshots__/template.test.js.snap | 0 .../{src => foo}/template.test.ts | 0 packages/util-template/package.json | 8 +- packages/util-template/src/template.ts | 49 +---- packages/util-template/tsconfig.json | 7 +- packages/util-uid/.babelrc | 6 +- packages/util-uid/package.json | 9 +- packages/util-uid/src/util-uid.test.js | 5 - packages/util-uid/src/util-uid.test.ts | 12 ++ .../util-uid/src/{util-uid.js => util-uid.ts} | 9 +- 12 files changed, 238 insertions(+), 73 deletions(-) rename packages/util-template/{src => foo}/__snapshots__/template.test.js.snap (100%) rename packages/util-template/{src => foo}/template.test.ts (100%) delete mode 100644 packages/util-uid/src/util-uid.test.js create mode 100644 packages/util-uid/src/util-uid.test.ts rename packages/util-uid/src/{util-uid.js => util-uid.ts} (69%) diff --git a/package-lock.json b/package-lock.json index 1e31f3d45..3ae6e3ca1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20625,10 +20625,110 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.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/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.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/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.2.0-alpha.0", @@ -20637,9 +20737,109 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.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.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/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/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/src/__snapshots__/template.test.js.snap b/packages/util-template/foo/__snapshots__/template.test.js.snap similarity index 100% rename from packages/util-template/src/__snapshots__/template.test.js.snap rename to packages/util-template/foo/__snapshots__/template.test.js.snap diff --git a/packages/util-template/src/template.test.ts b/packages/util-template/foo/template.test.ts similarity index 100% rename from packages/util-template/src/template.test.ts rename to packages/util-template/foo/template.test.ts diff --git a/packages/util-template/package.json b/packages/util-template/package.json index de9015a90..b0063462f 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -13,10 +13,16 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.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", diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts index 1e2a83910..55b453fe5 100644 --- a/packages/util-template/src/template.ts +++ b/packages/util-template/src/template.ts @@ -1,48 +1 @@ -import {log} from "@onflow/util-logger" - -export function interleave( - a: unknown[] = [], - b: unknown[] = [], - c: unknown[] = [] -) { - 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: unknown): (x: unknown) => 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) - } -} - -export function template( - head: string | TemplateStringsArray, - ...rest: unknown[] -): (x: unknown) => string | string { - if (typeof head === "string") return () => head - if (Array.isArray(head)) { - return d => - interleave(head, rest.map(recApply(d))) - .join("") - .trim() - } - return head -} +function foobar() {} 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/package.json b/packages/util-uid/package.json index ce821c34d..72fa3f78d 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": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.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.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..242ff6ea5 --- /dev/null +++ b/packages/util-uid/src/util-uid.test.ts @@ -0,0 +1,12 @@ +import {uid} from "./util-uid.js" + +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.js b/packages/util-uid/src/util-uid.ts similarity index 69% rename from packages/util-uid/src/util-uid.js rename to packages/util-uid/src/util-uid.ts index 878d61dd8..467e769ae 100644 --- a/packages/util-uid/src/util-uid.js +++ b/packages/util-uid/src/util-uid.ts @@ -1,11 +1,10 @@ -/** - * Generates a unique identifier - * @returns {string} - */ var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" var T = HEX.length -export function uid() { +/** + * Generates a unique 32 character alphanumeric string + */ +export function uid(): string { var str = "", num = 32 while (num--) str += HEX[(Math.random() * T) | 0] From 70ccd14839b80ff5faa31b658a57f9bbdd17c6f3 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Thu, 10 Aug 2023 23:30:07 -0700 Subject: [PATCH 04/14] stash --- package-lock.json | 107 +++- packages/fcl-bundle/package.json | 1 + .../fcl-bundle/src/build/get-input-options.js | 12 +- packages/fcl-bundle/src/get-package-json.js | 3 +- packages/fcl-bundle/src/util.js | 5 - .../exec-service/strategies/http-rpc.js | 0 .../exec-service/strategies/index.js | 0 packages/fcl/src/current-user/index.js | 351 +++++------ packages/fcl/src/exec/mutate.js | 43 +- packages/fcl/src/fcl.ts | 5 +- packages/rlp/.babelrc | 6 +- packages/rlp/src/index.ts | 37 +- packages/sdk/src/sdk.ts | 6 +- packages/typedefs/src/index.ts | 554 +++++++++--------- packages/util-actor/package.json | 1 + packages/util-actor/tsconfig.json | 3 +- packages/util-address/package.json | 2 +- packages/util-encode-key/.eslintrc.json | 18 +- packages/util-encode-key/package.json | 10 +- packages/util-encode-key/src/index.test.ts | 16 +- packages/util-encode-key/src/index.ts | 44 +- packages/util-invariant/package.json | 2 +- packages/util-logger/package.json | 2 +- packages/util-template/package.json | 2 +- .../__snapshots__/template.test.js.snap | 0 .../{foo => src}/template.test.ts | 1 + packages/util-template/src/template.ts | 47 +- 27 files changed, 707 insertions(+), 571 deletions(-) delete mode 100644 packages/fcl/src/current-user/exec-service/strategies/http-rpc.js delete mode 100644 packages/fcl/src/current-user/exec-service/strategies/index.js rename packages/util-template/{foo => src}/__snapshots__/template.test.js.snap (100%) rename packages/util-template/{foo => src}/template.test.ts (99%) diff --git a/package-lock.json b/package-lock.json index 3ae6e3ca1..2bbc7a64b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -808,7 +808,6 @@ }, "node_modules/@babel/plugin-syntax-jsx": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -908,7 +907,6 @@ }, "node_modules/@babel/plugin-syntax-typescript": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -1372,7 +1370,6 @@ "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", @@ -1525,7 +1522,6 @@ "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", @@ -19690,6 +19686,7 @@ "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", @@ -20582,15 +20579,113 @@ "@onflow/util-invariant": "^1.2.0-alpha.0" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.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.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" } }, + "packages/util-encode-key/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-encode-key/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-encode-key/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-encode-key/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/util-encode-key/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-encode-key/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-encode-key/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-invariant": { "name": "@onflow/util-invariant", "version": "1.2.0-alpha.0", diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 0685ea460..f0acd1629 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -15,6 +15,7 @@ "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", diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index 451eb8447..50f85394c 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -6,10 +6,9 @@ const {nodeResolve} = require("@rollup/plugin-node-resolve") const {babel} = require("@rollup/plugin-babel") const terser = require("@rollup/plugin-terser") const typescript = require("rollup-plugin-typescript2") +const {DEFAULT_EXTENSIONS} = require("@babel/core") const builtinModules = require("builtin-modules") -const path = require("path") -const {getPackageRoot} = require("../util") const SUPPRESSED_WARNING_CODES = [ "MISSING_GLOBAL_NAME", @@ -60,9 +59,6 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - typescript({ - tsconfig: path.resolve(getPackageRoot(), "tsconfig.json"), - }), replace({ preventAssignment: true, PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), @@ -73,9 +69,12 @@ module.exports = function getInputOptions(package, build) { preferBuiltins: build.type !== "umd", resolveOnly, }), + typescript({ + clean: true, + }), babel({ babelHelpers: "runtime", - presets: [["@babel/preset-env"]], + presets: ["@babel/preset-env", "@babel/preset-typescript"], plugins: [ [ "@babel/plugin-transform-runtime", @@ -85,6 +84,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-bundle/src/get-package-json.js b/packages/fcl-bundle/src/get-package-json.js index a2e9de146..e62e11be9 100644 --- a/packages/fcl-bundle/src/get-package-json.js +++ b/packages/fcl-bundle/src/get-package-json.js @@ -1,8 +1,7 @@ const {existsSync, readFileSync} = require("fs") const {resolve} = require("path") -const {getPackageRoot} = require("./util") -module.exports = function getPackageJSON(cwd = getPackageRoot()) { +module.exports = function getPackageJSON(cwd = process.cwd()) { const pathPackageJSON = resolve(cwd, "package.json") if (existsSync(pathPackageJSON)) { return JSON.parse(readFileSync(pathPackageJSON)) diff --git a/packages/fcl-bundle/src/util.js b/packages/fcl-bundle/src/util.js index 33533b319..57ca2501e 100644 --- a/packages/fcl-bundle/src/util.js +++ b/packages/fcl-bundle/src/util.js @@ -10,13 +10,8 @@ function isString(obj) { return typeof obj === "string" || obj instanceof String } -function getPackageRoot() { - return process.cwd() -} - module.exports = { isArray, isObject, isString, - getPackageRoot, } diff --git a/packages/fcl/src/current-user/exec-service/strategies/http-rpc.js b/packages/fcl/src/current-user/exec-service/strategies/http-rpc.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/fcl/src/current-user/exec-service/strategies/index.js b/packages/fcl/src/current-user/exec-service/strategies/index.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/fcl/src/current-user/index.js b/packages/fcl/src/current-user/index.js index a33dff0eb..3a7e74edd 100644 --- a/packages/fcl/src/current-user/index.js +++ b/packages/fcl/src/current-user/index.js @@ -149,81 +149,83 @@ const makeConfig = async ({discoveryAuthnInclude}) => { * @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 @@ -242,98 +244,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 */ @@ -372,15 +378,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") @@ -395,33 +403,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/exec/mutate.js b/packages/fcl/src/exec/mutate.js index 4238194a8..8763bf106 100644 --- a/packages/fcl/src/exec/mutate.js +++ b/packages/fcl/src/exec/mutate.js @@ -6,6 +6,8 @@ import {preMutate} from "./utils/pre.js" import {isNumber} from "./utils/is" /** + * @typedef {function(*)Promise} MutateFn + * * @description * Allows you to submit transactions to the blockchain to potentially mutate the state. * @@ -49,19 +51,28 @@ import {isNumber} from "./utils/is" * authorizations: [AuthzFn], // an array of authorization functions used as authorizations signatory roles * } */ -export const getMutate = ({platform}) => async (opts = {}) => { - var txid - try { - await preMutate(opts) - opts = await prepTemplateOpts(opts) - const currentUser = getCurrentUser({platform}) - // Allow for a config to overwrite the authorization function. - // prettier-ignore - const authz = await sdk.config().get("fcl.authz", currentUser().authorization) - txid = sdk.config().overload(opts.dependencies || {}, async () => +/** + * Gets a function that allows you to submit transactions to the blockchain to potentially mutate the state. + * @param {object} opts - Mutation Options and configuration + * @param {string} opts.platform - platform that runs the function + * @returns {MutateFn} + */ +export const getMutate = + ({platform}) => + async (opts = {}) => { + var txid + try { + await preMutate(opts) + opts = await prepTemplateOpts(opts) + const currentUser = getCurrentUser({platform}) + // Allow for a config to overwrite the authorization function. // prettier-ignore - sdk.send([ + const authz = await sdk.config().get("fcl.authz", currentUser().authorization) + + txid = sdk.config().overload(opts.dependencies || {}, async () => + // prettier-ignore + sdk.send([ sdk.transaction(opts.cadence), sdk.args(normalizeArgs(opts.args || [])), @@ -77,10 +88,10 @@ export const getMutate = ({platform}) => async (opts = {}) => { // opts.authorizations > [opts.authz > authz] sdk.authorizations(opts.authorizations || [opts.authz || authz]), ]).then(sdk.decode) - ) + ) - return txid - } catch (error) { - throw error + return txid + } catch (error) { + throw error + } } -} 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/src/index.ts b/packages/rlp/src/index.ts index 3bd3a4d29..4ff6ad9e5 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -16,7 +16,9 @@ export {Buffer} * @param input - will be converted to buffer * @returns returns buffer of encoded data **/ -export function encode(input) { +export function encode( + input: Buffer | string | number | Uint8Array | null | undefined +): Buffer { if (Array.isArray(input)) { var output = [] for (var i = 0; i < input.length; i++) { @@ -37,13 +39,13 @@ 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 { @@ -69,7 +71,7 @@ function encodeLength(len, offset) { * @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 } @@ -92,11 +94,14 @@ 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 { var inputBuffer = toBuffer(input) + if (inputBuffer.length === 0) { + return 0 + } + var firstByte = inputBuffer[0] if (firstByte <= 0x7f) { return inputBuffer.length @@ -116,7 +121,7 @@ export function getLength(input) { } /** Decode an input with RLP */ -function _decode(input) { +function _decode(input: Buffer | Uint8Array): any { var length, llength, data, innerRemainder, d var decoded = [] var firstByte = input[0] @@ -191,18 +196,18 @@ 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!") } @@ -210,17 +215,19 @@ function intToHex(integer) { 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) { +function intToBuffer(integer: number) { var 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/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/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 94d119325..3f7071b5b 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/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/package.json b/packages/util-address/package.json index e78e83e37..a135af192 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -29,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-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 1545de05a..5ea036fd9 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": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.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.3.0", + "@typescript-eslint/parser": "^6.3.0", + "eslint": "^8.46.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, @@ -25,7 +29,7 @@ "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", 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/package.json b/packages/util-invariant/package.json index aebc2c44b..e2d1213ab 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -21,7 +21,7 @@ "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-logger/package.json b/packages/util-logger/package.json index 1bc592f80..1227c8399 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -20,7 +20,7 @@ "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", - "types": "dist/types/util-logger.d.ts", + "types": "dist/util-logger.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-template/package.json b/packages/util-template/package.json index b0063462f..d447789bd 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -26,7 +26,7 @@ "main": "dist/template.js", "module": "dist/template.module.js", "unpkg": "dist/template.umd.js", - "types": "dist/types/template.d.ts", + "types": "dist/template.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-template/foo/__snapshots__/template.test.js.snap b/packages/util-template/src/__snapshots__/template.test.js.snap similarity index 100% rename from packages/util-template/foo/__snapshots__/template.test.js.snap rename to packages/util-template/src/__snapshots__/template.test.js.snap diff --git a/packages/util-template/foo/template.test.ts b/packages/util-template/src/template.test.ts similarity index 99% rename from packages/util-template/foo/template.test.ts rename to packages/util-template/src/template.test.ts index 65527b8c9..e2247dc86 100644 --- a/packages/util-template/foo/template.test.ts +++ b/packages/util-template/src/template.test.ts @@ -1,3 +1,4 @@ +//@ts-nocheck import {template, interleave} from "./template" describe("interleave", () => { diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts index 55b453fe5..e534fc5b4 100644 --- a/packages/util-template/src/template.ts +++ b/packages/util-template/src/template.ts @@ -1 +1,46 @@ -function foobar() {} +import {log} from "@onflow/util-logger" + +export function interleave( + a: unknown[] = [], + b: unknown[] = [], + c: unknown[] = [] +): unknown[] { + 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: unknown): (x: unknown) => 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) + } +} + +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 d => + interleave([...head], rest.map(recApply(d))) + .join("") + .trim() +} From 7776f8b07de11821e8a5c0885c64605114c0d30e Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 11 Aug 2023 08:10:18 -0700 Subject: [PATCH 05/14] fix tests --- package-lock.json | 3 ++- packages/sdk/.babelrc | 3 ++- packages/util-actor/src/index.ts | 2 +- packages/util-encode-key/.babelrc | 6 +----- packages/util-logger/.babelrc | 6 +----- packages/util-template/package.json | 3 ++- .../{template.test.js.snap => template.test.ts.snap} | 0 packages/util-uid/src/util-uid.test.ts | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-) rename packages/util-template/src/__snapshots__/{template.test.js.snap => template.test.ts.snap} (100%) diff --git a/package-lock.json b/package-lock.json index 2bbc7a64b..5aa7f1dd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20717,7 +20717,8 @@ "version": "1.2.0-alpha.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": { "@babel/preset-typescript": "^7.22.5", 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/util-actor/src/index.ts b/packages/util-actor/src/index.ts index 19247e863..73f40a08f 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -1,5 +1,5 @@ import {mailbox as createMailbox, type IMailbox} from "./mailbox" -import * as queueMicrotask from "queue-microtask" +const queueMicrotask = require("queue-microtask") export const INIT = "INIT" export const SUBSCRIBE = "SUBSCRIBE" 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-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-template/package.json b/packages/util-template/package.json index d447789bd..01ee6ae99 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -35,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 100% rename from packages/util-template/src/__snapshots__/template.test.js.snap rename to packages/util-template/src/__snapshots__/template.test.ts.snap diff --git a/packages/util-uid/src/util-uid.test.ts b/packages/util-uid/src/util-uid.test.ts index 242ff6ea5..637cbe4f6 100644 --- a/packages/util-uid/src/util-uid.test.ts +++ b/packages/util-uid/src/util-uid.test.ts @@ -1,4 +1,4 @@ -import {uid} from "./util-uid.js" +import {uid} from "./util-uid" test("it should generate a unique 32 character alphanumeric string", () => { const set = new Set() From 7219f2d68b6bc0b35c2f8f3b12a45338879606a0 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 11 Aug 2023 08:22:33 -0700 Subject: [PATCH 06/14] fx tests --- packages/rlp/package.json | 2 +- packages/rlp/src/index.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 449276d5e..bf57bc287 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -20,7 +20,7 @@ "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 4ff6ad9e5..612bb07f8 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 @@ -16,9 +25,7 @@ export {Buffer} * @param input - will be converted to buffer * @returns returns buffer of encoded data **/ -export function encode( - input: Buffer | string | number | Uint8Array | null | undefined -): Buffer { +export function encode(input: EncodeInput): Buffer { if (Array.isArray(input)) { var output = [] for (var i = 0; i < input.length; i++) { From 852a60451d1eecec56d745d3e8615186d760366d Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 11 Aug 2023 12:03:29 -0700 Subject: [PATCH 07/14] stash --- packages/config/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 88be905eb..d68cbf263 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -7,5 +7,6 @@ // Removing this would place the .d.ts files // next to the .js files "outDir": "types", + "strict": true } -} \ No newline at end of file +} From e39c14ea2a13e424b66820fd32e40c66ec134489 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 14 Aug 2023 14:10:32 -0700 Subject: [PATCH 08/14] add eslint --- package-lock.json | 351 ++++++++++++++---- packages/util-address/package.json | 6 +- packages/util-encode-key/.eslintrc copy.json | 20 + packages/util-encode-key/package.json | 8 +- packages/util-invariant/.eslintrc.json | 20 + packages/util-invariant/package.json | 6 + packages/util-logger/.eslintrc.json | 20 + packages/util-logger/package.json | 6 + packages/util-logger/src/util-logger.ts | 21 +- packages/util-template/.eslintrc.json | 20 + packages/util-template/package.json | 6 +- .../src/__snapshots__/template.test.ts.snap | 2 +- packages/util-template/src/template.test.ts | 25 +- packages/util-template/src/template.ts | 41 +- packages/util-uid/.eslintrc.json | 20 + packages/util-uid/package.json | 6 +- packages/util-uid/src/util-uid.ts | 9 +- 17 files changed, 456 insertions(+), 131 deletions(-) create mode 100644 packages/util-encode-key/.eslintrc copy.json create mode 100644 packages/util-invariant/.eslintrc.json create mode 100644 packages/util-logger/.eslintrc.json create mode 100644 packages/util-template/.eslintrc.json create mode 100644 packages/util-uid/.eslintrc.json diff --git a/package-lock.json b/package-lock.json index 5aa7f1dd9..d7ec15b1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2024,9 +2024,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.1.tgz", - "integrity": "sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -2062,9 +2062,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.46.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.46.0.tgz", - "integrity": "sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", + "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -5323,21 +5323,20 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.3.0.tgz", - "integrity": "sha512-IZYjYZ0ifGSLZbwMqIip/nOamFiWJ9AH+T/GYNZBWkVcyNQOFGtSMoWV7RvY4poYCMZ/4lHzNl796WOSNxmk8A==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", + "integrity": "sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.3.0", - "@typescript-eslint/type-utils": "6.3.0", - "@typescript-eslint/utils": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/type-utils": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", "natural-compare": "^1.4.0", - "natural-compare-lite": "^1.4.0", "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, @@ -5386,15 +5385,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.3.0.tgz", - "integrity": "sha512-ibP+y2Gr6p0qsUkhs7InMdXrwldjxZw66wpcQq9/PzAroM45wdwyu81T+7RibNCh8oc0AgrsyCwJByncY0Ongg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.0.tgz", + "integrity": "sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.3.0", - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/typescript-estree": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4" }, "engines": { @@ -5414,13 +5413,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.3.0.tgz", - "integrity": "sha512-WlNFgBEuGu74ahrXzgefiz/QlVb+qg8KDTpknKwR7hMH+lQygWyx0CQFoUmMn1zDkQjTBBIn75IxtWss77iBIQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz", + "integrity": "sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0" + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -5431,13 +5430,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.3.0.tgz", - "integrity": "sha512-7Oj+1ox1T2Yc8PKpBvOKWhoI/4rWFd1j7FA/rPE0lbBPXTKjdbtC+7Ev0SeBjEKkIhKWVeZSP+mR7y1Db1CdfQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz", + "integrity": "sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.3.0", - "@typescript-eslint/utils": "6.3.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/utils": "6.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -5458,9 +5457,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.3.0.tgz", - "integrity": "sha512-K6TZOvfVyc7MO9j60MkRNWyFSf86IbOatTKGrpTQnzarDZPYPVy0oe3myTMq7VjhfsUAbNUW8I5s+2lZvtx1gg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.0.tgz", + "integrity": "sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -5471,13 +5470,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.3.0.tgz", - "integrity": "sha512-Xh4NVDaC4eYKY4O3QGPuQNp5NxBAlEvNQYOqJquR2MePNxO11E5K3t5x4M4Mx53IZvtpW+mBxIT0s274fLUocg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz", + "integrity": "sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/visitor-keys": "6.3.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -5525,17 +5524,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.3.0.tgz", - "integrity": "sha512-hLLg3BZE07XHnpzglNBG8P/IXq/ZVXraEbgY7FM0Cnc1ehM8RMdn9mat3LubJ3KBeYXXPxV1nugWbQPjGeJk6Q==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.0.tgz", + "integrity": "sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==", "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.3.0", - "@typescript-eslint/types": "6.3.0", - "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", "semver": "^7.5.4" }, "engines": { @@ -5577,12 +5576,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.3.0.tgz", - "integrity": "sha512-kEhRRj7HnvaSjux1J9+7dBen15CdWmDnwrpyiHsFX6Qx2iW5LOBUgNefOFeh2PjWPlNwN8TOn6+4eBU3J/gupw==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz", + "integrity": "sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/types": "6.4.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -8664,14 +8663,14 @@ } }, "node_modules/eslint": { - "version": "8.46.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.46.0.tgz", - "integrity": "sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", + "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.1", - "@eslint/js": "^8.46.0", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -8682,7 +8681,7 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.2", + "eslint-visitor-keys": "^3.4.3", "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", @@ -8788,9 +8787,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz", - "integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -10067,9 +10066,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", "dependencies": { "type-fest": "^0.20.2" }, @@ -14602,12 +14601,6 @@ "version": "1.4.0", "license": "MIT" }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/negotiator": { "version": "0.6.3", "dev": true, @@ -20467,9 +20460,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" @@ -20584,9 +20577,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" @@ -20694,11 +20687,111 @@ "@babel/runtime": "^7.18.6" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.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-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": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=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, + "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, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-invariant/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/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.3.0-alpha.0", @@ -20708,10 +20801,110 @@ "@onflow/config": "^1.2.0-alpha.0" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.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/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.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/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-template": { "name": "@onflow/util-template", "version": "1.2.0-alpha.0", @@ -20724,9 +20917,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" } @@ -20836,9 +21029,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" } diff --git a/packages/util-address/package.json b/packages/util-address/package.json index a135af192..25a74c83a 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -18,9 +18,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" diff --git a/packages/util-encode-key/.eslintrc copy.json b/packages/util-encode-key/.eslintrc copy.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-encode-key/.eslintrc copy.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-encode-key/package.json b/packages/util-encode-key/package.json index 5ea036fd9..48aad3d78 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -18,9 +18,9 @@ "@onflow/types": "^1.2.0-alpha.0", "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" @@ -36,7 +36,7 @@ "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-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 e2d1213ab..c7dcc3cc7 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -13,8 +13,14 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@onflow/types": "^1.2.0-alpha.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", 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 1227c8399..4aae5e268 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -13,7 +13,13 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.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/util-logger.ts", diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts index 3f807abbd..bf036556f 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -2,7 +2,6 @@ import {config} from "@onflow/config" /** * The levels of the logger - * @enum */ export enum LEVELS { debug = 5, @@ -14,12 +13,10 @@ export enum LEVELS { /** * Builds a message formatted for the logger - * - * @param options + * @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" }) */ @@ -45,16 +42,13 @@ const buildLoggerMessageArgs = (options: { /** * Logs messages based on the level of the message and the level set in the config - * * @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 (options: { title: string @@ -89,8 +83,7 @@ export const log = async (options: { } /** - * Logs a deprecation notice - * + * 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 @@ -98,10 +91,14 @@ export const log = async (options: { * @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 = (options: { pkg?: string @@ -110,7 +107,7 @@ log.deprecate = (options: { level?: number message?: string callback?: (...args: T[]) => U -}) => { +}): ((...args: T[]) => Promise) | Promise => { const { pkg, subject, 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 01ee6ae99..6a0356c28 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -16,9 +16,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" }, diff --git a/packages/util-template/src/__snapshots__/template.test.ts.snap b/packages/util-template/src/__snapshots__/template.test.ts.snap index 5a768939f..614f991a9 100644 --- a/packages/util-template/src/__snapshots__/template.test.ts.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.test.ts b/packages/util-template/src/template.test.ts index e2247dc86..dac1be6cb 100644 --- a/packages/util-template/src/template.test.ts +++ b/packages/util-template/src/template.test.ts @@ -1,4 +1,3 @@ -//@ts-nocheck import {template, interleave} from "./template" describe("interleave", () => { @@ -24,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", () => { @@ -53,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) ) }) @@ -64,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)) }) @@ -89,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 index e534fc5b4..e2a68ae2e 100644 --- a/packages/util-template/src/template.ts +++ b/packages/util-template/src/template.ts @@ -1,13 +1,23 @@ import {log} from "@onflow/util-logger" -export function interleave( - a: unknown[] = [], - b: unknown[] = [], - c: unknown[] = [] -): unknown[] { +/** + * 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) return [...c, a[0]] + if (!b.length) { + c.push(...a) + return c + } const [aHead, ...aRest] = a const [bHead, ...bRest] = b @@ -18,7 +28,12 @@ export function interleave( return interleave(aRest, bRest, c) } -function recApply(d: unknown): (x: unknown) => string { +/** + * 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({ @@ -33,14 +48,20 @@ function recApply(d: unknown): (x: unknown) => string { } } +/** + * 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), + head: string | TemplateStringsArray | ((x?: unknown) => string), ...rest: unknown[] ): (x?: unknown) => string { if (typeof head === "string") return () => head if (typeof head === "function") return head - return d => - interleave([...head], rest.map(recApply(d))) + return (x: unknown) => + interleave([...head], rest.map(recApply(x))) .join("") .trim() } 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 72fa3f78d..ef1bb0b6e 100644 --- a/packages/util-uid/package.json +++ b/packages/util-uid/package.json @@ -16,9 +16,9 @@ "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/jest": "^29.5.3", - "@typescript-eslint/eslint-plugin": "^6.3.0", - "@typescript-eslint/parser": "^6.3.0", - "eslint": "^8.46.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" }, diff --git a/packages/util-uid/src/util-uid.ts b/packages/util-uid/src/util-uid.ts index 467e769ae..651251ef7 100644 --- a/packages/util-uid/src/util-uid.ts +++ b/packages/util-uid/src/util-uid.ts @@ -1,11 +1,12 @@ -var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -var T = HEX.length +const HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +const T = HEX.length /** - * Generates a unique 32 character alphanumeric string + * Generates a random unique identifier + * @returns 32 character alphanumeric string */ export function uid(): string { - var str = "", + let str = "", num = 32 while (num--) str += HEX[(Math.random() * T) | 0] return str From 05b4cce8ccd3a33449821d735e4367a3830c812e Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 14 Aug 2023 22:42:06 -0700 Subject: [PATCH 09/14] Update RLP --- package-lock.json | 100 ++++++++++++++++++ .../.eslintrc.json} | 10 ++ packages/rlp/package.json | 6 ++ packages/rlp/src/index.ts | 49 +++++---- packages/rlp/tsconfig.json | 4 +- 5 files changed, 144 insertions(+), 25 deletions(-) rename packages/{util-encode-key/.eslintrc copy.json => rlp/.eslintrc.json} (60%) diff --git a/package-lock.json b/package-lock.json index d7ec15b1c..d61a35f48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20256,10 +20256,110 @@ "buffer": "^6.0.3" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.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/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.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/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.3.0-alpha.0", diff --git a/packages/util-encode-key/.eslintrc copy.json b/packages/rlp/.eslintrc.json similarity index 60% rename from packages/util-encode-key/.eslintrc copy.json rename to packages/rlp/.eslintrc.json index e80c057f5..815f845bc 100644 --- a/packages/util-encode-key/.eslintrc copy.json +++ b/packages/rlp/.eslintrc.json @@ -16,5 +16,15 @@ "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 bf57bc287..1950f1f6c 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -13,7 +13,13 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.4.0-alpha.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", diff --git a/packages/rlp/src/index.ts b/packages/rlp/src/index.ts index 612bb07f8..1ed6933f2 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -19,22 +19,22 @@ type EncodeInput = * 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: 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]) @@ -56,9 +56,9 @@ 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") } } @@ -71,13 +71,13 @@ function encodeLength(len: number, offset: number): 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 * @param stream Is the input a stream (false by default) * @returns returns buffer of encoded data - **/ + */ export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { if (stream === void 0) { stream = false @@ -85,8 +85,8 @@ export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { 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 } @@ -104,12 +104,12 @@ export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { export function getLength( input: Buffer | Uint8Array | null | undefined | string | number ): number { - var inputBuffer = toBuffer(input) + const inputBuffer = toBuffer(input) if (inputBuffer.length === 0) { return 0 } - var firstByte = inputBuffer[0] + const firstByte = inputBuffer[0] if (firstByte <= 0x7f) { return inputBuffer.length } else if (firstByte <= 0xb7) { @@ -121,17 +121,20 @@ export function getLength( 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: Buffer | Uint8Array): any { - var length, llength, data, innerRemainder, d - var decoded = [] - var firstByte = input[0] + 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 { @@ -183,7 +186,7 @@ function _decode(input: Buffer | Uint8Array): any { // 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") } @@ -218,7 +221,7 @@ 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 */ @@ -227,7 +230,7 @@ function padToEven(a: string) { } /** Transform an integer into a Buffer */ function intToBuffer(integer: number) { - var hex = intToHex(integer) + const hex = intToHex(integer) return Buffer.from(hex, "hex") } 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 +} From 21732cadff7acf3b34b9adc8666714cdd0daec37 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 14 Aug 2023 22:47:29 -0700 Subject: [PATCH 10/14] changeset --- .changeset/giant-ducks-tickle.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/giant-ducks-tickle.md 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 From 256a0fe50dcec9d1c1c52a56acbac210c6527027 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 15 Aug 2023 08:47:57 -0700 Subject: [PATCH 11/14] fix config --- packages/config/tsconfig.json | 3 +-- packages/fcl-bundle/src/build/get-input-options.js | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index d68cbf263..ac6917898 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/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": true + "outDir": "types" } } diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index 50f85394c..1a693cf67 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -59,19 +59,19 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - replace({ - preventAssignment: true, - PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), - }), - commonjs(), nodeResolve({ browser: true, preferBuiltins: build.type !== "umd", resolveOnly, }), + commonjs(), typescript({ clean: true, }), + replace({ + preventAssignment: true, + PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), + }), babel({ babelHelpers: "runtime", presets: ["@babel/preset-env", "@babel/preset-typescript"], From 37d3d1712116d45ce77182824a03cb6e4a6bede6 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 15 Aug 2023 12:27:02 -0700 Subject: [PATCH 12/14] add fclbundle change --- .changeset/fifty-buttons-serve.md | 5 +++++ packages/config/package.json | 2 +- packages/fcl-bundle/src/build/get-input-options.js | 12 +++++++++--- packages/typedefs/package.json | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changeset/fifty-buttons-serve.md 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/packages/config/package.json b/packages/config/package.json index 97bee62b7..fad240181 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -22,7 +22,7 @@ "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", diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index 1a693cf67..b84ffe284 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -17,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]*/, "" @@ -65,9 +70,10 @@ module.exports = function getInputOptions(package, build) { resolveOnly, }), commonjs(), - typescript({ - clean: true, - }), + isTypeScript && + typescript({ + clean: true, + }), replace({ preventAssignment: true, PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index e2174088b..ea20e22b3 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", From e16b346b6cb682f43630126843bd43716929e036 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 15 Aug 2023 12:49:21 -0700 Subject: [PATCH 13/14] fix config types --- packages/config/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/package.json b/packages/config/package.json index fad240181..97bee62b7 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -22,7 +22,7 @@ "main": "dist/config.js", "module": "dist/config.module.js", "unpkg": "dist/config.umd.js", - "types": "dist/config.d.ts", + "types": "types/src/config.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", From 90abe42985d8202c891adde4faa00b6a598dedf6 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 15 Aug 2023 13:00:46 -0700 Subject: [PATCH 14/14] reset pre.json --- .changeset/pre.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index c6ac090f7..349594157 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "exit", + "mode": "pre", "tag": "alpha", "initialVersions": { "@onflow/config": "1.1.1",