diff --git a/.changeset/fifty-buttons-serve.md b/.changeset/fifty-buttons-serve.md new file mode 100644 index 000000000..31966c74d --- /dev/null +++ b/.changeset/fifty-buttons-serve.md @@ -0,0 +1,5 @@ +--- +"@onflow/fcl-bundle": minor +--- + +Switched to rollup-plugin-typescript2 diff --git a/.changeset/giant-ducks-tickle.md b/.changeset/giant-ducks-tickle.md new file mode 100644 index 000000000..c93bc0d3f --- /dev/null +++ b/.changeset/giant-ducks-tickle.md @@ -0,0 +1,11 @@ +--- +"@onflow/util-encode-key": minor +"@onflow/util-invariant": minor +"@onflow/util-template": minor +"@onflow/util-address": minor +"@onflow/util-logger": minor +"@onflow/util-uid": minor +"@onflow/rlp": minor +--- + +Convert to Typescript diff --git a/package-lock.json b/package-lock.json index 2e8a8253e..d61a35f48 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", @@ -800,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" @@ -900,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" @@ -1364,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", @@ -1517,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", @@ -1997,13 +2001,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.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", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -2020,11 +2047,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 +2062,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", - "license": "MIT", + "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" } @@ -2045,8 +2075,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 +2100,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 +4867,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 +5322,276 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "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.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", + "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.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.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": { + "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.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.4.0", + "@typescript-eslint/visitor-keys": "6.4.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.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.4.0", + "@typescript-eslint/utils": "6.4.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.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" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "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.4.0", + "@typescript-eslint/visitor-keys": "6.4.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.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.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.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.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.4.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 +6103,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 +6132,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 +6276,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 +8663,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.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.2", + "@eslint/js": "^8.47.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -8400,23 +8690,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,57 +8772,39 @@ } }, "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" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "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" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-utils": { - "version": "3.0.0", + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^2.0.0" + "color-convert": "^2.0.1" }, "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" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" + "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" @@ -8675,12 +8943,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 +9242,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", @@ -9781,8 +10066,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "license": "MIT", + "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" }, @@ -9843,13 +10129,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 +12842,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 +13465,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 +14044,6 @@ }, "node_modules/make-dir": { "version": "3.1.0", - "dev": true, "license": "MIT", "dependencies": { "semver": "^6.0.0" @@ -13774,7 +14057,6 @@ }, "node_modules/make-dir/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -15343,15 +15625,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 +16302,6 @@ }, "node_modules/pkg-dir": { "version": "4.2.0", - "dev": true, "license": "MIT", "dependencies": { "find-up": "^4.0.0" @@ -16138,7 +16420,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 +17124,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 +17285,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 +18427,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 +18764,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 +18783,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 +19249,7 @@ }, "node_modules/word-wrap": { "version": "1.2.3", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -19178,16 +19551,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 +19620,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,21 +19674,22 @@ }, "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", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", - "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" @@ -19330,25 +19704,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 +20249,137 @@ }, "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", + "@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.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 +20444,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 +20486,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,114 +20524,711 @@ }, "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.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" } }, - "packages/util-encode-key": { - "name": "@onflow/util-encode-key", - "version": "1.1.0", - "license": "Apache-2.0", + "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": { - "@babel/runtime": "^7.18.6", - "@onflow/rlp": "^1.1.0", - "@onflow/util-invariant": "^1.1.0" + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", - "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.8.0", - "jest": "^29.5.0", - "typescript": "^4.9.5" + "engines": { + "node": ">=16" } }, - "packages/util-invariant": { - "name": "@onflow/util-invariant", - "version": "1.1.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", - "jest": "^29.5.0" + "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-logger": { - "name": "@onflow/util-logger", - "version": "1.2.1", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1" + "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.2.0-alpha.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6", + "@onflow/rlp": "^1.2.0-alpha.0", + "@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", + "@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" + } + }, + "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", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@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", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6", + "@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.1.0", + "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": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@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-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.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", + "@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-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/config/tsconfig.json b/packages/config/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 9f3b3f1ca..f0acd1629 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -15,16 +15,17 @@ "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-terser": "^0.4.3", - "@rollup/plugin-typescript": "^11.1.2", "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index e867fb0a9..b84ffe284 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -4,8 +4,9 @@ const commonjs = require("@rollup/plugin-commonjs") const replace = require("@rollup/plugin-replace") const {nodeResolve} = require("@rollup/plugin-node-resolve") const {babel} = require("@rollup/plugin-babel") -const terser = require('@rollup/plugin-terser') -const typescript = require('@rollup/plugin-typescript') +const terser = require("@rollup/plugin-terser") +const typescript = require("rollup-plugin-typescript2") +const {DEFAULT_EXTENSIONS} = require("@babel/core") const builtinModules = require("builtin-modules") @@ -16,12 +17,17 @@ const SUPPRESSED_WARNING_CODES = [ ] module.exports = function getInputOptions(package, build) { + // ensure that that package has the required dependencies if (!package.dependencies["@babel/runtime"]) { throw new Error( `${package.name} is missing required @babel/runtime dependency. Please add this to the package.json and try again.` ) } + // determine if we are building typescript + const source = build.source + const isTypeScript = source.endsWith(".ts") + const babelRuntimeVersion = package.dependencies["@babel/runtime"].replace( /^[^0-9]*/, "" @@ -44,7 +50,11 @@ module.exports = function getInputOptions(package, build) { }, false)) // exclude peer dependencies - const resolveOnly = [new RegExp(`^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*`)] + const resolveOnly = [ + new RegExp( + `^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*` + ), + ] let options = { input: build.source, @@ -54,20 +64,23 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - typescript(), - replace({ - preventAssignment: true, - PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), - }), - commonjs(), nodeResolve({ browser: true, preferBuiltins: build.type !== "umd", resolveOnly, }), + commonjs(), + isTypeScript && + typescript({ + clean: true, + }), + replace({ + preventAssignment: true, + PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), + }), babel({ babelHelpers: "runtime", - presets: [["@babel/preset-env"]], + presets: ["@babel/preset-env", "@babel/preset-typescript"], plugins: [ [ "@babel/plugin-transform-runtime", @@ -77,6 +90,7 @@ module.exports = function getInputOptions(package, build) { ], ], sourceMaps: true, + extensions: [...DEFAULT_EXTENSIONS, ".ts", ".tsx"], }), /\.min\.js$/.test(build.entry) && terser({ diff --git a/packages/fcl/src/current-user/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/fcl.ts b/packages/fcl/src/fcl.ts index 2b3677330..aad1d821a 100644 --- a/packages/fcl/src/fcl.ts +++ b/packages/fcl/src/fcl.ts @@ -1,10 +1,11 @@ -export * from './shared-exports'; +export * from "./shared-exports" import {getMutate} from "./exec/mutate" + export const mutate = getMutate({platform: "web"}) import {getCurrentUser} from "./current-user" -const currentUser = getCurrentUser({platform:"web"}) +const currentUser = getCurrentUser({platform: "web"}) export {currentUser} diff --git a/packages/rlp/.babelrc b/packages/rlp/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/rlp/.babelrc +++ b/packages/rlp/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/rlp/.eslintrc.json b/packages/rlp/.eslintrc.json new file mode 100644 index 000000000..815f845bc --- /dev/null +++ b/packages/rlp/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "jsdoc/require-jsdoc": 0, + "jsdoc/tag-lines": 0, + "jsdoc/require-param-description": 0, + "jsdoc/require-param": 0, + "jsdoc/valid-types": 0, + "jsdoc/require-returns-description": 0, + "jsdoc/require-returns": 0, + "@typescript-eslint/no-explicit-any": "off" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 449276d5e..1950f1f6c 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -13,14 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@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", "main": "dist/rlp.js", "module": "dist/rlp.module.js", "unpkg": "dist/rlp.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/rlp/src/index.ts b/packages/rlp/src/index.ts index 3bd3a4d29..1ed6933f2 100644 --- a/packages/rlp/src/index.ts +++ b/packages/rlp/src/index.ts @@ -2,6 +2,15 @@ import {Buffer} from "buffer" export {Buffer} +type EncodeInput = + | Buffer + | string + | number + | Uint8Array + | null + | undefined + | EncodeInput[] + /** * Built on top of rlp library, removing the BN dependency for the flow. * Package : https://github.com/ethereumjs/rlp @@ -10,22 +19,22 @@ export {Buffer} * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @returns returns buffer of encoded data - **/ -export function encode(input) { + */ +export function encode(input: EncodeInput): Buffer { if (Array.isArray(input)) { - var output = [] - for (var i = 0; i < input.length; i++) { + const output = [] + for (let i = 0; i < input.length; i++) { output.push(encode(input[i])) } - var buf = Buffer.concat(output) + const buf = Buffer.concat(output) return Buffer.concat([encodeLength(buf.length, 192), buf]) } else { - var inputBuf = toBuffer(input) + const inputBuf = toBuffer(input) return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]) @@ -37,19 +46,19 @@ export function encode(input) { * @param v The value to parse * @param base The base to parse the integer into */ -function safeParseInt(v, base) { +function safeParseInt(v: string, base: number): number { if (v.slice(0, 2) === "00") { throw new Error("invalid RLP: extra zeros") } return parseInt(v, base) } -function encodeLength(len, offset) { +function encodeLength(len: number, offset: number): Buffer { if (len < 56) { return Buffer.from([len + offset]) } else { - var hexLength = intToHex(len) - var lLength = hexLength.length / 2 - var firstByte = intToHex(offset + 55 + lLength) + const hexLength = intToHex(len) + const lLength = hexLength.length / 2 + const firstByte = intToHex(offset + 55 + lLength) return Buffer.from(firstByte + hexLength, "hex") } } @@ -62,22 +71,22 @@ function encodeLength(len, offset) { * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @param stream Is the input a stream (false by default) * @returns returns buffer of encoded data - **/ -export function decode(input, stream) { + */ +export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { if (stream === void 0) { stream = false } if (!input || input.length === 0) { return Buffer.from([]) } - var inputBuffer = toBuffer(input) - var decoded = _decode(inputBuffer) + const inputBuffer = toBuffer(input) + const decoded = _decode(inputBuffer) if (stream) { return decoded } @@ -92,12 +101,15 @@ export function decode(input, stream) { * @param input * @returns The length of the input or an empty Buffer if no input */ -export function getLength(input) { - if (!input || input.length === 0) { - return Buffer.from([]) +export function getLength( + input: Buffer | Uint8Array | null | undefined | string | number +): number { + const inputBuffer = toBuffer(input) + if (inputBuffer.length === 0) { + return 0 } - var inputBuffer = toBuffer(input) - var firstByte = inputBuffer[0] + + const firstByte = inputBuffer[0] if (firstByte <= 0x7f) { return inputBuffer.length } else if (firstByte <= 0xb7) { @@ -109,17 +121,20 @@ export function getLength(input) { return firstByte - 0xbf } else { // a list over 55 bytes long - var llength = firstByte - 0xf6 - var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16) + const llength = firstByte - 0xf6 + const length = safeParseInt( + inputBuffer.slice(1, llength).toString("hex"), + 16 + ) return llength + length } } /** Decode an input with RLP */ -function _decode(input) { - var length, llength, data, innerRemainder, d - var decoded = [] - var firstByte = input[0] +function _decode(input: Buffer | Uint8Array): any { + let length, llength, data, innerRemainder, d + const decoded = [] + const firstByte = input[0] if (firstByte <= 0x7f) { // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. return { @@ -171,7 +186,7 @@ function _decode(input) { // a list over 55 bytes long llength = firstByte - 0xf6 length = safeParseInt(input.slice(1, llength).toString("hex"), 16) - var totalLength = llength + length + const totalLength = llength + length if (totalLength > input.length) { throw new Error("invalid rlp: total length is larger than the data") } @@ -191,36 +206,38 @@ function _decode(input) { } } /** Check if a string is prefixed by 0x */ -function isHexPrefixed(str) { +function isHexPrefixed(str: string) { return str.slice(0, 2) === "0x" } /** Removes 0x from a given String */ -function stripHexPrefix(str) { +function stripHexPrefix(str: string) { if (typeof str !== "string") { return str } return isHexPrefixed(str) ? str.slice(2) : str } /** Transform an integer into its hexadecimal value */ -function intToHex(integer) { +function intToHex(integer: number) { if (integer < 0) { throw new Error("Invalid integer as argument, must be unsigned!") } - var hex = integer.toString(16) + const hex = integer.toString(16) return hex.length % 2 ? "0" + hex : hex } /** Pad a string to be even */ -function padToEven(a) { +function padToEven(a: string) { return a.length % 2 ? "0" + a : a } /** Transform an integer into a Buffer */ -function intToBuffer(integer) { - var hex = intToHex(integer) +function intToBuffer(integer: number) { + const hex = intToHex(integer) return Buffer.from(hex, "hex") } /** Transform anything into a Buffer */ -export function toBuffer(v) { +export function toBuffer( + v: Buffer | string | number | Uint8Array | null | undefined +) { if (!Buffer.isBuffer(v)) { if (typeof v === "string") { if (isHexPrefixed(v)) { diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/rlp/tsconfig.json +++ b/packages/rlp/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/sdk/.babelrc b/packages/sdk/.babelrc index 779f5464f..1e3225d50 100644 --- a/packages/sdk/.babelrc +++ b/packages/sdk/.babelrc @@ -5,6 +5,7 @@ { "useBuiltIns": false } - ] + ], + "@babel/preset-typescript" ] } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 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/src/sdk.ts b/packages/sdk/src/sdk.ts index 6e0f2adc9..9a4decc99 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -83,7 +83,7 @@ export {resolveVoucherIntercept} from "./resolve/resolve-voucher-intercept.js" export {config} from "@onflow/config" // Deprecated -export const params = params => +export const params = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The params builder has been removed from the Flow JS-SDK/FCL.`, @@ -91,7 +91,7 @@ export const params = params => "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", level: logger.LEVELS.error, }) -export const param = params => +export const param = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The param builder has been removed from the Flow JS-SDK/FCL.`, @@ -103,4 +103,4 @@ export const param = params => import * as TestUtils from "./test-utils" export {TestUtils} -export {VERSION} from "./VERSION" \ No newline at end of file +export {VERSION} from "./VERSION" diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 88be905eb..ac6917898 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -6,6 +6,6 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index 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", 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/src/index.ts b/packages/util-actor/src/index.ts index f89b9b4d2..73f40a08f 100644 --- a/packages/util-actor/src/index.ts +++ b/packages/util-actor/src/index.ts @@ -23,11 +23,15 @@ interface IRoot { FCL_REGISTRY: Record | null } -const root: IRoot = - (typeof self === "object" && self.self === self && (self as unknown) as IRoot) || - (typeof global === "object" && global.global === global && (global as unknown) as IRoot) || - (typeof window === "object" && window.window === window && (window as unknown) as IRoot) || - {FCL_REGISTRY: null} +const root: IRoot = (typeof self === "object" && + self.self === self && + (self as unknown as IRoot)) || + (typeof global === "object" && + global.global === global && + (global as unknown as IRoot)) || + (typeof window === "object" && + window.window === window && + (window as unknown as IRoot)) || {FCL_REGISTRY: null} root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY @@ -37,9 +41,25 @@ var pid = 0b0 const DEFAULT_TIMEOUT = 5000 const DEFAULT_TAG = "---" -type Tag = typeof INIT | typeof SUBSCRIBE | typeof UNSUBSCRIBE | typeof UPDATED | typeof SNAPSHOT | typeof EXIT | typeof TERMINATE | "@EXIT" | typeof DUMP | typeof INC | typeof KEYS; +type Tag = + | typeof INIT + | typeof SUBSCRIBE + | typeof UNSUBSCRIBE + | typeof UPDATED + | typeof SNAPSHOT + | typeof EXIT + | typeof TERMINATE + | "@EXIT" + | typeof DUMP + | typeof INC + | typeof KEYS -export const send = (addr: string, tag: Tag, data?: Record | null, opts: Record = {}) => +export const send = ( + addr: string, + tag: Tag, + data?: Record | null, + opts: Record = {} +) => new Promise((reply, reject) => { const expectReply = opts.expectReply || false const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT @@ -63,8 +83,7 @@ export const send = (addr: string, tag: Tag, data?: Record | null, } try { - FCL_REGISTRY[addr] && - FCL_REGISTRY[addr].mailbox.deliver(payload) + FCL_REGISTRY[addr] && FCL_REGISTRY[addr].mailbox.deliver(payload) if (!expectReply) reply(true) } catch (error) { console.error( @@ -81,7 +100,7 @@ export const kill = addr => { } const fromHandlers = - (handlers = {}) => + (handlers: Record = {}) => async ctx => { if (typeof handlers[INIT] === "function") await handlers[INIT](ctx) __loop: while (1) { @@ -107,7 +126,7 @@ const parseAddr = (addr): string => { return String(++pid) } return String(addr) -} +} export const spawn = (fn, rawAddr: number | null = null) => { const addr = parseAddr(rawAddr) @@ -124,7 +143,12 @@ export const spawn = (fn, rawAddr: number | null = null) => { const ctx = { self: () => addr, receive: () => FCL_REGISTRY[addr].mailbox.receive(), - send: (to: string, tag: Tag, data: Record | null, opts: Record = {}) => { + send: ( + to: string, + tag: Tag, + data: Record | null, + opts: Record = {} + ) => { opts.from = addr return send(to, tag, data, opts) }, diff --git a/packages/util-actor/tsconfig.json b/packages/util-actor/tsconfig.json index 88be905eb..e8262cfd4 100644 --- a/packages/util-actor/tsconfig.json +++ b/packages/util-actor/tsconfig.json @@ -7,5 +7,6 @@ // Removing this would place the .d.ts files // next to the .js files "outDir": "types", + "strict": false } -} \ No newline at end of file +} diff --git a/packages/util-address/.babelrc b/packages/util-address/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-address/.babelrc +++ b/packages/util-address/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-address/.eslintrc.json b/packages/util-address/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-address/.eslintrc.json +++ b/packages/util-address/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-address/package.json b/packages/util-address/package.json index 44140f32e..25a74c83a 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.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, @@ -25,7 +29,7 @@ "main": "dist/util-address.js", "module": "dist/util-address.module.js", "unpkg": "dist/util-address.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-address/src/index.test.js b/packages/util-address/src/index.test.ts similarity index 100% rename from packages/util-address/src/index.test.js rename to packages/util-address/src/index.test.ts diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts index 63ea0705a..33e05de1a 100644 --- a/packages/util-address/src/index.ts +++ b/packages/util-address/src/index.ts @@ -1,28 +1,28 @@ /** * @description Removes 0x from address if present - * @param {string} address - Flow address - * @returns {string} - Flow address without 0x prefix + * @param address - Flow address + * @returns Flow address without 0x prefix */ - export function sansPrefix(address: string | null): string { +export function sansPrefix(address: string | null): string | null { if (address == null) return null return address.replace(/^0x/, "").replace(/^Fx/, "") } /** * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix + * @param address - Flow address + * @returns Flow address with 0x prefix */ -export function withPrefix(address: string): string | null { +export function withPrefix(address: string | null): string | null { if (address == null) return null return "0x" + sansPrefix(address) } /** * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix + * @param address - Flow address + * @returns Flow address with 0x prefix */ -export function display(address: string | null): string { +export function display(address: string | null): string | null { return withPrefix(address) } diff --git a/packages/util-encode-key/.babelrc b/packages/util-encode-key/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-encode-key/.babelrc +++ b/packages/util-encode-key/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-encode-key/.eslintrc.json b/packages/util-encode-key/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-encode-key/.eslintrc.json +++ b/packages/util-encode-key/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 1545de05a..48aad3d78 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.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, @@ -25,14 +29,14 @@ "main": "dist/util-encode-key.js", "module": "dist/util-encode-key.module.js", "unpkg": "dist/util-encode-key.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", - "lint": "eslint src/*.ts" + "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", diff --git a/packages/util-encode-key/src/index.test.ts b/packages/util-encode-key/src/index.test.ts index 1caee139f..220e69b7b 100644 --- a/packages/util-encode-key/src/index.test.ts +++ b/packages/util-encode-key/src/index.test.ts @@ -1,10 +1,4 @@ -import { - encodeKey, - ECDSA_P256, - ECDSA_secp256k1, - SHA2_256, - SHA3_256, -} from "./" +import {encodeKey, ECDSA_P256, ECDSA_secp256k1, SHA2_256, SHA3_256} from "./" const PUBLIC_KEYS = [ "0bfcd8790c3ce88f3fac9d4bd23514f48bf0cdd1f6c3c8bdf87b11489b1bbeca1ef805ec2ee76451e9bdb265284f78febaeacbc8b0827e0a7baafee4e655d0b5", @@ -18,10 +12,10 @@ const HASHINGS = [SHA2_256, SHA3_256] const WEIGHTS = [0, 32, 512, 1000] -for (let [key_index, key] of PUBLIC_KEYS.entries()) { - for (let [curve_index, curve] of CURVES.entries()) { - for (let [hash_index, hash] of HASHINGS.entries()) { - for (let [weight_index, weight] of WEIGHTS.entries()) { +for (const [key_index, key] of PUBLIC_KEYS.entries()) { + for (const [curve_index, curve] of CURVES.entries()) { + for (const [hash_index, hash] of HASHINGS.entries()) { + for (const [weight_index, weight] of WEIGHTS.entries()) { test(`key:${key_index} curve:${curve_index} hash:${hash_index} weight:${weight_index}`, () => { expect(encodeKey(key, curve, hash, weight)).toMatchSnapshot() }) diff --git a/packages/util-encode-key/src/index.ts b/packages/util-encode-key/src/index.ts index 6c6b98b5b..9ba359091 100644 --- a/packages/util-encode-key/src/index.ts +++ b/packages/util-encode-key/src/index.ts @@ -3,48 +3,23 @@ import {encode} from "@onflow/rlp" // Curves -/** - * @type {number} - */ export const ECDSA_P256 = 2 - -/** - * @type {number} - */ export const ECDSA_secp256k1 = 3 - -/** - * @type {Set} - * @private - */ const VALID_CURVES = new Set([ECDSA_P256, ECDSA_secp256k1]) // Hashing -/** - * @type {number} - */ export const SHA2_256 = 1 - -/** - * @type {number} - */ export const SHA3_256 = 3 - -/** - * @type {Set} - * @private - */ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) /** * Encodes a key into a hex string - * - * @param {string} key - The key to encode (DER Hex) - * @param {number} curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] - * @param {number} hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] - * @param {number} weight - The weight you want this key to have [Range: 0..1000] - * @returns {string} - The encoded key + * @param key - The key to encode (DER Hex) + * @param curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] + * @param hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] + * @param weight - The weight you want this key to have [Range: 0..1000] + * @returns The encoded key * @throws {Error} - Throws if the key is not a string * @throws {Error} - Throws if the key is not in the correct format * @throws {Error} - Throws if the curve is not a number @@ -56,7 +31,12 @@ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) * import {encodeKey, ECDSA_P256, SHA3_256} from "@onflow/util-encode-key" * encodeKey("aabbccdd", ECDSA_P256, SHA3_256, 1000) // => "aabbccdd0201000" */ -export function encodeKey(key, curve, hash, weight = 1000) { +export function encodeKey( + key: string, + curve: number, + hash: number, + weight = 1000 +): string { invariant( typeof key === "string", "encodeKey(key, curve, hash, weight) -- invalid key (expecting type of string)" @@ -87,4 +67,4 @@ export function encodeKey(key, curve, hash, weight = 1000) { ) return encode([Buffer.from(key, "hex"), curve, hash, weight]).toString("hex") -} \ No newline at end of file +} diff --git a/packages/util-invariant/.eslintrc.json b/packages/util-invariant/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-invariant/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index aebc2c44b..c7dcc3cc7 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -13,15 +13,21 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@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", "main": "dist/util-invariant.js", "module": "dist/util-invariant.module.js", "unpkg": "dist/util-invariant.umd.js", - "types": "dist/types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-invariant/src/index.test.js b/packages/util-invariant/src/index.test.ts similarity index 100% rename from packages/util-invariant/src/index.test.js rename to packages/util-invariant/src/index.test.ts diff --git a/packages/util-invariant/src/index.ts b/packages/util-invariant/src/index.ts index d453e9406..0fedc85b2 100644 --- a/packages/util-invariant/src/index.ts +++ b/packages/util-invariant/src/index.ts @@ -1,17 +1,16 @@ /** * Asserts fact is true, otherwise throw an error with invariant message - * @param {boolean} fact - * @param {string} msg - * @param {Array} rest - * @returns {void} + * @param fact + * @param msg + * @param rest */ -export function invariant(fact, msg, ...rest) { +export function invariant(fact: boolean, msg: string, ...rest: any[]) { if (!fact) { const error = new Error(`INVARIANT ${msg}`) error.stack = error.stack - .split("\n") - .filter(d => !/at invariant/.test(d)) - .join("\n") + ?.split("\n") + ?.filter(d => !/at invariant/.test(d)) + ?.join("\n") console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n") throw error } diff --git a/packages/util-logger/.babelrc b/packages/util-logger/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-logger/.babelrc +++ b/packages/util-logger/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-logger/.eslintrc.json b/packages/util-logger/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-logger/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index 4b6d5b767..4aae5e268 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@babel/preset-typescript": "^7.22.5", "@onflow/fcl-bundle": "^1.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", "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", + "types": "dist/util-logger.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts index e57cbb0e1..bf036556f 100644 --- a/packages/util-logger/src/util-logger.ts +++ b/packages/util-logger/src/util-logger.ts @@ -2,35 +2,29 @@ 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 - * */ -export const LEVELS = Object.freeze({ - debug: 5, - info: 4, - log: 3, - warn: 2, - error: 1, -}) +export enum LEVELS { + debug = 5, + info = 4, + log = 3, + warn = 2, + error = 1, +} /** * Builds a message formatted for the logger - * - * @param {Object} options - The options for the log - * @param {string} options.title - The title of the log - * @param {string} options.message - The message of the log - * @returns {Array} - The message formatted for the logger - * + * @param options - The options for the log + * @param options.title - The title of the log + * @param options.message - The message of the log + * @returns The message formatted for the logger * @example * buildLoggerMessageArgs({ title: "My Title", message: "My Message" }) */ -const buildLoggerMessageArgs = ({title, message}) => { +const buildLoggerMessageArgs = (options: { + title: string + message: string +}): string[] => { + const {title, message} = options return [ ` %c${title} @@ -42,26 +36,27 @@ 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 @@ -88,31 +83,42 @@ export const log = async ({title, message, level, always = false}) => { } /** - * Logs a deprecation notice - * - * @param {Object} options - The options for the log - * @param {string} options.pkg - The package that is being deprecated - * @param {string} options.subject - The subject of the deprecation - * @param {string} options.transition - The transition path for the deprecation - * @param {number} options.level - The level of the log - * @param {string} options.message - The message of the log - * @param {Function} options.callback - A callback to run after the log - * @returns {Promise} - * + * Logs a deprecation notice. If a callback is provided this function returns a function that will call the callback and log the deprecation notice, otherwise it just logs the deprecation notice. + * @param options - The options for the log + * @param options.pkg - The package that is being deprecated + * @param options.subject - The subject of the deprecation + * @param options.transition - The transition path for the deprecation + * @param options.level - The level of the log + * @param options.message - The message of the log + * @param options.callback - A callback to run after the log + * @returns A function that will call the callback and log the deprecation notice if the callback is provided * @example + * // Logs a deprecation notice * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) - * + * @example + * function someFunction() { ... } + * const deprecatedFunction = log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/foo/bar/TRANSITIONS.md", message: "Descriptive message", level: LEVELS.warn, callback: someFunction }) + * deprecatedFunction() // Calls someFunction and logs the deprecation notice */ -log.deprecate = ({ - pkg, - subject, - transition, - level = LEVELS.warn, - message = "", - callback = null, -}) => { - const capitalizeFirstLetter = string => { - return string.charAt(0).toUpperCase() + string.slice(1) +log.deprecate = (options: { + pkg?: string + subject?: string + transition?: string + level?: number + message?: string + callback?: (...args: T[]) => U +}): ((...args: T[]) => Promise) | Promise => { + const { + pkg, + subject, + transition, + level = LEVELS.warn, + message = "", + callback = null, + } = options + + const capitalizeFirstLetter = (str: string) => { + return str.charAt(0).toUpperCase() + str.slice(1) } const logMessage = () => @@ -137,7 +143,7 @@ log.deprecate = ({ }) if (typeof callback === "function") { - return async (...args) => { + return async (...args: T[]) => { await logMessage() return await callback(...args) } diff --git a/packages/util-template/.babelrc b/packages/util-template/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-template/.babelrc +++ b/packages/util-template/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-template/.eslintrc.json b/packages/util-template/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-template/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 9ee44d304..6a0356c28 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { + "@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/template.js", + "source": "src/template.ts", "main": "dist/template.js", "module": "dist/template.module.js", "unpkg": "dist/template.umd.js", + "types": "dist/template.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", @@ -28,6 +35,7 @@ "start": "fcl-bundle --watch" }, "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" } } diff --git a/packages/util-template/src/__snapshots__/template.test.js.snap b/packages/util-template/src/__snapshots__/template.test.ts.snap similarity index 94% rename from packages/util-template/src/__snapshots__/template.test.js.snap rename to packages/util-template/src/__snapshots__/template.test.ts.snap index 5a768939f..614f991a9 100644 --- a/packages/util-template/src/__snapshots__/template.test.js.snap +++ b/packages/util-template/src/__snapshots__/template.test.ts.snap @@ -10,7 +10,7 @@ exports[`template interop function template(template\`\${o=>o.a}\`)(o) -> 'abc' exports[`template interop function template\`\${o=>o.a}\`(o) -> 'abc' 1`] = `"abc"`; -exports[`template interop more template template(template\`x\${template\`y\${o => o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; +exports[`template interop more template template(template\`x\${template\`y\${(_o: typeof o) => _o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; exports[`template interop more template template\`x\${template\`y\${o=>o.a}\`}\`(o) => 'xyabc' 1`] = `"xyabc"`; diff --git a/packages/util-template/src/template.js b/packages/util-template/src/template.js deleted file mode 100644 index e064dab37..000000000 --- a/packages/util-template/src/template.js +++ /dev/null @@ -1,46 +0,0 @@ -import {log} from "@onflow/util-logger" - -export function interleave(a = [], b = [], c = []) { - if (!a.length && !b.length) return c - if (!a.length) return c - if (!b.length) return [...c, a[0]] - - const [aHead, ...aRest] = a - const [bHead, ...bRest] = b - - if (aHead !== undefined) c.push(aHead) - if (bHead !== undefined) c.push(bHead) - - return interleave(aRest, bRest, c) -} - -function recApply(d) { - return function (arg1) { - if (typeof arg1 === "function") { - log.deprecate({ - pkg: "FCL/SDK", - subject: "Interopolation of functions into template literals", - transition: - "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", - }) - return recApply(d)(arg1(d)) - } - return String(arg1) - } -} - -/** - * @param {(string|Array.<*>)} head - * @param {Array.<*>} rest - * @returns {{function(): string}} - */ -export function template(head, ...rest) { - if (typeof head === "string") return () => head - if (Array.isArray(head)) { - return d => - interleave(head, rest.map(recApply(d))) - .join("") - .trim() - } - return head -} diff --git a/packages/util-template/src/template.test.js b/packages/util-template/src/template.test.ts similarity index 72% rename from packages/util-template/src/template.test.js rename to packages/util-template/src/template.test.ts index 6014f676c..dac1be6cb 100644 --- a/packages/util-template/src/template.test.js +++ b/packages/util-template/src/template.test.ts @@ -23,14 +23,14 @@ describe("interleave", () => { }) }) -const _ = (msg, a, b) => { +const _ = (msg: string, a: unknown, b?: unknown) => { if (b == null) { test(msg, () => expect(a).toMatchSnapshot()) } else { test(msg, () => expect(a).toBe(b)) } } -const t = v => typeof v +const t = (v: T) => typeof v describe("template", () => { describe("input type vs output type", () => { @@ -52,10 +52,10 @@ describe("template", () => { describe("interop function", () => { const o = {a: "abc"} - _("template`${o=>o.a}`(o) -> 'abc'", template`${o => o.a}`(o)) + _("template`${o=>o.a}`(o) -> 'abc'", template`${(_o: typeof o) => _o.a}`(o)) _( "template(template`${o=>o.a}`)(o) -> 'abc'", - template(template`${o => o.a}`)(o) + template(template`${(_o: typeof o) => _o.a}`)(o) ) }) @@ -63,20 +63,20 @@ describe("template", () => { const o = {a: "abc"} _( "template`x${template`y${o=>o.a}`}`(o) => 'xyabc'", - template`x${template`y${o => o.a}`}`(o) + template`x${template`y${(_o: typeof o) => _o.a}`}`(o) ) _( "template`x${template`y${template`z${o=>o.a}`}`}`(o) => 'xyabc'", - template`x${template`y${template`z${o => o.a}`}`}`(o) + template`x${template`y${template`z${(_o: typeof o) => _o.a}`}`}`(o) ) _( - "template(template`x${template`y${o => o.a}`}`)(o) -> 'xyabc'", - template(template`x${template`y${o => o.a}`}`)(o) + "template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) -> 'xyabc'", + template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) ) }) describe("interop nested functions", () => { - const fn = a => b => c => d => e => f => f.a + const fn = () => () => () => () => () => (f: typeof o) => f.a const o = {a: "abc"} _("template`${fn}`(o) -> 'abc'", template`${fn}`(o)) }) @@ -88,8 +88,10 @@ describe("template", () => { describe("object can have non string values", () => { const data = {a: 1, b: NaN, c: undefined, d: null, e: false, f: true} - const tx = template`a:${o => o.a}|b:${o => o.b}|c:${o => o.c}|d:${o => - o.d}|e:${o => o.e}|f:${o => o.f}` + const tx = template`a:${(o: typeof data) => o.a}|b:${(o: typeof data) => + o.b}|c:${(o: typeof data) => o.c}|d:${(o: typeof data) => o.d}|e:${( + o: typeof data + ) => o.e}|f:${(o: typeof data) => o.f}` _("template(data)", tx(data), "a:1|b:NaN|c:undefined|d:null|e:false|f:true") }) }) diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts new file mode 100644 index 000000000..e2a68ae2e --- /dev/null +++ b/packages/util-template/src/template.ts @@ -0,0 +1,67 @@ +import {log} from "@onflow/util-logger" + +/** + * Interleaves two arrays + * @param a - The first array + * @param b - The second array + * @param c - The target array + * @returns The interleaved array + */ +export function interleave( + a: A[] = [], + b: B[] = [], + c: (A | B)[] = [] +): (A | B)[] { + if (!a.length && !b.length) return c + if (!a.length) return c + if (!b.length) { + c.push(...a) + return c + } + + const [aHead, ...aRest] = a + const [bHead, ...bRest] = b + + if (aHead !== undefined) c.push(aHead) + if (bHead !== undefined) c.push(bHead) + + return interleave(aRest, bRest, c) +} + +/** + * Recursively apply a value to a function + * @param d - The value to apply + * @returns A function that takes a function and applies the value to it + */ +function recApply(d: T): (x: U) => string { + return function (arg1) { + if (typeof arg1 === "function") { + log.deprecate({ + pkg: "FCL/SDK", + subject: "Interopolation of functions into template literals", + transition: + "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", + }) + return recApply(d)(arg1(d)) + } + return String(arg1) + } +} + +/** + * Creates a template function + * @param head - A string, template string array, or template function + * @param rest - The rest of the arguments + * @returns A template function + */ +export function template( + head: string | TemplateStringsArray | ((x?: unknown) => string), + ...rest: unknown[] +): (x?: unknown) => string { + if (typeof head === "string") return () => head + if (typeof head === "function") return head + return (x: unknown) => + interleave([...head], rest.map(recApply(x))) + .join("") + .trim() +} diff --git a/packages/util-template/tsconfig.json b/packages/util-template/tsconfig.json index 88be905eb..4ec7af1fd 100644 --- a/packages/util-template/tsconfig.json +++ b/packages/util-template/tsconfig.json @@ -6,6 +6,7 @@ // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", - } -} \ No newline at end of file + "outDir": "types" + }, + "exclude": ["src/__snapshots__"] +} diff --git a/packages/util-uid/.babelrc b/packages/util-uid/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-uid/.babelrc +++ b/packages/util-uid/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-uid/.eslintrc.json b/packages/util-uid/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-uid/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-uid/package.json b/packages/util-uid/package.json index ce821c34d..ef1bb0b6e 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.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/util-uid.js", + "source": "src/util-uid.ts", "main": "dist/util-uid.js", "module": "dist/util-uid.module.js", "unpkg": "dist/util-uid.umd.js", + "types": "dist/util-uid.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-uid/src/util-uid.js b/packages/util-uid/src/util-uid.js deleted file mode 100644 index 878d61dd8..000000000 --- a/packages/util-uid/src/util-uid.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generates a unique identifier - * @returns {string} - */ -var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -var T = HEX.length - -export function uid() { - var str = "", - num = 32 - while (num--) str += HEX[(Math.random() * T) | 0] - return str -} diff --git a/packages/util-uid/src/util-uid.test.js b/packages/util-uid/src/util-uid.test.js deleted file mode 100644 index 0fbcb9ae6..000000000 --- a/packages/util-uid/src/util-uid.test.js +++ /dev/null @@ -1,5 +0,0 @@ -import {uid} from "./util-uid.js" - -test("placeholder", () => { - expect(uid()).not.toBe(1) -}) diff --git a/packages/util-uid/src/util-uid.test.ts b/packages/util-uid/src/util-uid.test.ts new file mode 100644 index 000000000..637cbe4f6 --- /dev/null +++ b/packages/util-uid/src/util-uid.test.ts @@ -0,0 +1,12 @@ +import {uid} from "./util-uid" + +test("it should generate a unique 32 character alphanumeric string", () => { + const set = new Set() + for (let i = 0; i < 1000; i++) { + const id = uid() + expect(id).toMatch(/^[a-zA-Z0-9]{32}$/) + expect(set.has(id)).toBe(false) + set.add(id) + } + expect(set.size).toBe(1000) +}) diff --git a/packages/util-uid/src/util-uid.ts b/packages/util-uid/src/util-uid.ts new file mode 100644 index 000000000..651251ef7 --- /dev/null +++ b/packages/util-uid/src/util-uid.ts @@ -0,0 +1,13 @@ +const HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +const T = HEX.length + +/** + * Generates a random unique identifier + * @returns 32 character alphanumeric string + */ +export function uid(): string { + let str = "", + num = 32 + while (num--) str += HEX[(Math.random() * T) | 0] + return str +} diff --git a/tsconfig.json b/tsconfig.json index ca733deed..244c48d2e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,10 @@ { // Change this to match your project - "exclude": [ - "**/*.test.ts", - "**/*.test.js" - ], + "exclude": ["**/*.test.ts", "**/*.test.js"], "compilerOptions": { "moduleResolution": "NodeNext", "target": "ES2015", - "types" : ["node", "jest"], + "types": ["node", "jest"], // Tells TypeScript to read JS files, as // normally they are ignored as source files "allowJs": true, @@ -19,5 +16,6 @@ // go to js file when using IDE functions like // "Go to Definition" in VSCode "declarationMap": false, + "strict": true } -} \ No newline at end of file +}