From 732729d900e01dc8a94a0ca070ece7226bc48454 Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Thu, 10 Aug 2023 11:06:59 +0800 Subject: [PATCH] fix more issues --- .eslintrc.js | 2 +- README.md | 1 - package-lock.json | 139 +++++++++++++++++++--------------------------- package.json | 26 ++++----- test/setup.mjs | 5 +- tsconfig.json | 3 +- webpack.config.js | 33 ----------- 7 files changed, 74 insertions(+), 135 deletions(-) delete mode 100644 webpack.config.js diff --git a/.eslintrc.js b/.eslintrc.js index 3d2d492..c4051a4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ module.exports = { ignorePatterns: ["*.config.js", ".eslintrc.js"], parserOptions: { sourceType: "module", - ecmaVersion: 11, + ecmaVersion: 2022, project: "./tsconfig.json", }, }; diff --git a/README.md b/README.md index 5f0b4d4..9bc2e4c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ This module is distributed in 4 formats - `esm` build `dist/torusUtils.esm.js` in es6 format - `commonjs` build `dist/torusUtils.cjs.js` in es5 format - `umd` build `dist/torusUtils.umd.min.js` in es5 format without polyfilling corejs minified -- `nodejs` build `dist/torusUtils-node.js` in es5 format By default, the appropriate format is used for your specified usecase You can use a different format (if you know what you're doing eg. node) by referencing the correct file diff --git a/package-lock.json b/package-lock.json index ec0bbb8..cadd17a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,22 +9,22 @@ "version": "10.0.5", "license": "MIT", "dependencies": { - "@toruslabs/constants": "^11.0.0", - "@toruslabs/eccrypto": "^3.0.0", - "@toruslabs/http-helpers": "^4.0.0", + "@toruslabs/constants": "^13.0.0", + "@toruslabs/eccrypto": "^4.0.0", + "@toruslabs/http-helpers": "^5.0.0", "bn.js": "^5.2.1", "elliptic": "^6.5.4", - "ethereum-cryptography": "^2.0.0", + "ethereum-cryptography": "^2.1.2", "json-stable-stringify": "^1.0.2", "loglevel": "^1.8.1" }, "devDependencies": { "@babel/register": "^7.22.5", - "@babel/runtime": "^7.22.6", - "@toruslabs/config": "file:../torus-cli/packages/config/toruslabs-config-1.0.0.tgz", - "@toruslabs/eslint-config-typescript": "file:../torus-cli/packages/eslint-config-typescript/toruslabs-eslint-config-typescript-2.0.0.tgz", - "@toruslabs/fetch-node-details": "^11.0.1", - "@toruslabs/torus-scripts": "file:../torus-cli/packages/torus-scripts/toruslabs-torus-scripts-4.0.0.tgz", + "@babel/runtime": "^7.22.10", + "@toruslabs/config": "^2.0.1", + "@toruslabs/eslint-config-typescript": "^3.0.0", + "@toruslabs/fetch-node-details": "^13.0.0", + "@toruslabs/torus-scripts": "^5.0.2", "@types/chai": "^4.3.5", "@types/elliptic": "^6.4.14", "@types/faker": "^5.5.3", @@ -34,18 +34,16 @@ "chai": "^4.3.7", "cross-env": "^7.0.3", "dotenv": "^16.3.1", - "eslint": "^8.44.0", + "eslint": "^8.46.0", "faker": "^5.5.3", "husky": "^8.0.3", - "jsonwebtoken": "^9.0.0", + "jsonwebtoken": "^9.0.1", "lint-staged": "^13.2.3", "mocha": "^10.2.0", - "node-fetch": "^3.3.1", "prettier": "^3.0.1", "rimraf": "^5.0.1", "ts-node": "^10.9.1", - "typescript": "^5.1.6", - "webpack-node-externals": "^3.0.0" + "typescript": "^5.1.6" }, "engines": { "node": ">=18.x", @@ -1844,11 +1842,11 @@ "dev": true }, "node_modules/@babel/runtime": { - "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz", - "integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.10.tgz", + "integrity": "sha512-21t/fkKLMZI4pqP2wlmsQAWnYW1PDyKyyUV4vCi+B25ydmdaYTKXPwCj0BzSUnZf4seIiYvSA3jcZ3gdsMFkLQ==", "dependencies": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" @@ -2841,11 +2839,10 @@ "dev": true }, "node_modules/@toruslabs/config": { - "version": "1.0.0", - "resolved": "file:../torus-cli/packages/config/toruslabs-config-1.0.0.tgz", - "integrity": "sha512-gZJchCx3vaooKBC6eDZnwDDz1QR7YfOUCt8GW0bK6t436JnIiy2LMfwlmmpwE4PWHa3PZZyZm4ROdwJ2x3o7Lw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@toruslabs/config/-/config-2.0.1.tgz", + "integrity": "sha512-QnvRz7nmGsUdakRUJi63CMzUCH3rDgT8jsm/uZc2P0rfGYT/BO8/pBKszXoxEn+Xo0nGwXLv85BuYab1XQbDqg==", "dev": true, - "license": "MIT", "engines": { "node": ">=18.x", "npm": ">=9.x" @@ -2855,35 +2852,34 @@ } }, "node_modules/@toruslabs/constants": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-11.0.0.tgz", - "integrity": "sha512-ImSw2cFMCdJH2zZ9jAR2vfK03YXpEGxBuNctx2Mq7fDyx+h0FvFSOV/VHMcjKcYCsPZyw1WjRCP0rDVY+7lHZg==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/constants/-/constants-13.0.0.tgz", + "integrity": "sha512-NQTLufn6esUeln5ZDkuc+mTkDj9aSf06+w66PhcJUlSRr0L2rjmoxNK78YwmllNHSAIE4UcBrd7nEo94aFLHKA==", "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" + "node": ">=18.x", + "npm": ">=9.x" }, "peerDependencies": { "@babel/runtime": "7.x" } }, "node_modules/@toruslabs/eccrypto": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/eccrypto/-/eccrypto-3.0.0.tgz", - "integrity": "sha512-+lFjV+0FZ3S4zH5T/Gnc795HoqpzLLDW28fSkibZRlx1Nx8uwbl3pyJSfya0C0bRHH1/+NTeBogUDijaRJ1NCw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/eccrypto/-/eccrypto-4.0.0.tgz", + "integrity": "sha512-Z3EINkbsgJx1t6jCDVIJjLSUEGUtNIeDjhMWmeDGOWcP/+v/yQ1hEvd1wfxEz4q5WqIHhevacmPiVxiJ4DljGQ==", "dependencies": { "elliptic": "^6.5.4" }, "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" + "node": ">=18.x", + "npm": ">=9.x" } }, "node_modules/@toruslabs/eslint-config-typescript": { - "version": "2.0.0", - "resolved": "file:../torus-cli/packages/eslint-config-typescript/toruslabs-eslint-config-typescript-2.0.0.tgz", - "integrity": "sha512-9lf2GtShtPgb2S9rAjRuHuR0LBZ2xQ6SBIdt98DGy978QVBC/79xKWWGljL5UXUnplWpcyd1yhndNg/8XprBhw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/eslint-config-typescript/-/eslint-config-typescript-3.0.0.tgz", + "integrity": "sha512-kJrQH+62hO52qmIz1jL1nmCv5p30kLa5t4D6WoeEr3glT7P9EKHStkJ+dRPGFPjSXm1qD8aigDZ7RPKHt00ZYA==", "dev": true, - "license": "MIT", "dependencies": { "@rushstack/eslint-patch": "^1.3.2", "@typescript-eslint/eslint-plugin": "^6.2.1", @@ -2912,51 +2908,51 @@ } }, "node_modules/@toruslabs/fetch-node-details": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/@toruslabs/fetch-node-details/-/fetch-node-details-11.0.1.tgz", - "integrity": "sha512-nkKWEDCBYinbLSWsL6ggbS4cdmis3Pk/SuVAzx29dhSaqW58QG+90KuvGqbiw42T8qaqC6kGtUmje7GOroCFgA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/fetch-node-details/-/fetch-node-details-13.0.0.tgz", + "integrity": "sha512-pl5IWAGXG+aeDxUqNcg2qn1ng2bilgtEqyEcS4KLYSyBBFPFKsIpEemDq80TCqTevVKYfallbHRIqq9cS1DTgQ==", "dev": true, "dependencies": { - "@toruslabs/constants": "^11.0.0", - "@toruslabs/fnd-base": "^11.0.1", - "@toruslabs/http-helpers": "^4.0.0", + "@toruslabs/constants": "^13.0.0", + "@toruslabs/fnd-base": "^13.0.0", + "@toruslabs/http-helpers": "^5.0.0", "loglevel": "^1.8.1" }, "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" + "node": ">=18.x", + "npm": ">=9.x" }, "peerDependencies": { "@babel/runtime": "7.x" } }, "node_modules/@toruslabs/fnd-base": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/@toruslabs/fnd-base/-/fnd-base-11.0.1.tgz", - "integrity": "sha512-Dd3r5xXeyODpSA03AuD91iZnXVS2GAQlhr8zv6WaNRoX5PCo0+7VXA8e/DnPdpEWtwL9GTKpdulr5ShksM128w==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/fnd-base/-/fnd-base-13.0.0.tgz", + "integrity": "sha512-nD4BISOw6PDGagk33wfVhI80d2xlrzaRSf/F469AT34WfAL28GaHMqufIsAQSNXBffag67IWiqi2xP14gnsmvA==", "dev": true, "dependencies": { - "@toruslabs/constants": "^11.0.0" + "@toruslabs/constants": "^13.0.0" }, "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" + "node": ">=18.x", + "npm": ">=9.x" }, "peerDependencies": { "@babel/runtime": "7.x" } }, "node_modules/@toruslabs/http-helpers": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-4.0.0.tgz", - "integrity": "sha512-ef/Svevk54JANOn3Kf6UPf8X/vZlYHrusNFt8VV/LLahhVNXCXEcO8goC1bHkecu/u20CUyo9HJa0pn8fHh1sg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", "dependencies": { "lodash.merge": "^4.6.2", "loglevel": "^1.8.1" }, "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" + "node": ">=18.x", + "npm": ">=9.x" }, "peerDependencies": { "@babel/runtime": "^7.x", @@ -2969,11 +2965,10 @@ } }, "node_modules/@toruslabs/torus-scripts": { - "version": "4.0.0", - "resolved": "file:../torus-cli/packages/torus-scripts/toruslabs-torus-scripts-4.0.0.tgz", - "integrity": "sha512-4gvaPhlF9E3KWKh/d4etsWa54mqjhny/fJuJUfgSogc94nVp/RxCZGmTkNxMFgLp2QYJe7nQTDo30stoSIdBQQ==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@toruslabs/torus-scripts/-/torus-scripts-5.0.2.tgz", + "integrity": "sha512-GBYzNmiMZISaMpAr6m+Ynv2X6Cz7hihIeP44VEtnIqPt6Zop+aloHC6eBUzA6mxA3FNGY2sCD478D9ye+/l/8w==", "dev": true, - "license": "MIT", "dependencies": { "@babel/core": "^7.22.9", "@babel/plugin-proposal-class-properties": "^7.18.6", @@ -2986,7 +2981,7 @@ "@babel/runtime": "^7.22.6", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-node-resolve": "^15.1.0", - "@toruslabs/config": "^1.0.0", + "@toruslabs/config": "^2.0.1", "assert": "^2.0.0", "babel-loader": "^9.1.3", "babel-merge": "^3.0.0", @@ -10294,24 +10289,6 @@ "node": ">=10.5.0" } }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "dev": true, - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", @@ -11445,9 +11422,9 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", + "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==" }, "node_modules/regenerator-transform": { "version": "0.15.1", diff --git a/package.json b/package.json index ee47374..3b6e4d0 100644 --- a/package.json +++ b/package.json @@ -24,22 +24,22 @@ "@babel/runtime": "7.x" }, "dependencies": { - "@toruslabs/constants": "^11.0.0", - "@toruslabs/eccrypto": "^3.0.0", - "@toruslabs/http-helpers": "^4.0.0", + "@toruslabs/constants": "^13.0.0", + "@toruslabs/eccrypto": "^4.0.0", + "@toruslabs/http-helpers": "^5.0.0", "bn.js": "^5.2.1", "elliptic": "^6.5.4", - "ethereum-cryptography": "^2.0.0", + "ethereum-cryptography": "^2.1.2", "json-stable-stringify": "^1.0.2", "loglevel": "^1.8.1" }, "devDependencies": { "@babel/register": "^7.22.5", - "@babel/runtime": "^7.22.6", - "@toruslabs/config": "file:../torus-cli/packages/config/toruslabs-config-1.0.0.tgz", - "@toruslabs/eslint-config-typescript": "file:../torus-cli/packages/eslint-config-typescript/toruslabs-eslint-config-typescript-2.0.0.tgz", - "@toruslabs/fetch-node-details": "^11.0.1", - "@toruslabs/torus-scripts": "file:../torus-cli/packages/torus-scripts/toruslabs-torus-scripts-4.0.0.tgz", + "@babel/runtime": "^7.22.10", + "@toruslabs/config": "^2.0.1", + "@toruslabs/eslint-config-typescript": "^3.0.0", + "@toruslabs/fetch-node-details": "^13.0.0", + "@toruslabs/torus-scripts": "^5.0.2", "@types/chai": "^4.3.5", "@types/elliptic": "^6.4.14", "@types/faker": "^5.5.3", @@ -49,18 +49,16 @@ "chai": "^4.3.7", "cross-env": "^7.0.3", "dotenv": "^16.3.1", - "eslint": "^8.44.0", + "eslint": "^8.46.0", "faker": "^5.5.3", "husky": "^8.0.3", - "jsonwebtoken": "^9.0.0", + "jsonwebtoken": "^9.0.1", "lint-staged": "^13.2.3", "mocha": "^10.2.0", - "node-fetch": "^3.3.1", "prettier": "^3.0.1", "rimraf": "^5.0.1", "ts-node": "^10.9.1", - "typescript": "^5.1.6", - "webpack-node-externals": "^3.0.0" + "typescript": "^5.1.6" }, "repository": { "type": "git", diff --git a/test/setup.mjs b/test/setup.mjs index 0d9b265..af4e366 100644 --- a/test/setup.mjs +++ b/test/setup.mjs @@ -1,17 +1,14 @@ import Register from "@babel/register"; -import fetch from "node-fetch"; import path from "path"; import { register } from "ts-node"; register({ project: path.resolve(".", "tsconfig.json"), transpileOnly: true, - compilerOptions: { module: "commonjs" }, + compilerOptions: { module: "esnext" }, }); Register({ extensions: [".ts", ".js"], rootMode: "upward", }); - -globalThis.fetch = fetch; diff --git a/tsconfig.json b/tsconfig.json index d6a99f4..2951c72 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,5 @@ { "extends": "@toruslabs/config/tsconfig.default.json", - "include": ["src", "test"] + "include": ["src", "test"], + "compilerOptions": {} } diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 16e71d8..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,33 +0,0 @@ -const path = require("path"); -const webpack = require("webpack"); -const nodeExternals = require("webpack-node-externals"); - -const pkg = require("./package.json"); - -const pkgName = "torusUtils"; - -exports.nodeConfig = { - optimization: { - minimize: false, - }, - output: { - filename: `${pkgName}-node.js`, - library: { - type: "commonjs2", - }, - }, - externals: [ - nodeExternals({ - allowlist: "@toruslabs/http-helpers", - }), - "node-fetch", - ...Object.keys(pkg.dependencies).filter((x) => !["@toruslabs/http-helpers"].includes(x)), - /^(@babel\/runtime)/i, - ], - target: "node", - plugins: [ - new webpack.ProvidePlugin({ - fetch: ["node-fetch", "default"], - }), - ], -};