From d8ba7242f4542b083a0cf72233028ec2a01a0dce Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Wed, 26 Jul 2023 01:18:54 +0300 Subject: [PATCH 01/11] SERVICES-1760: update typescript eslint packages Signed-off-by: Claudiu Lataretu --- .eslintrc.js | 15 +- package-lock.json | 409 +++++++++++++++++++++++++--------------------- package.json | 4 +- 3 files changed, 231 insertions(+), 197 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ddccf7e4e..378c82182 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,12 @@ module.exports = { parser: '@typescript-eslint/parser', parserOptions: { - project: 'tsconfig.json', - sourceType: 'module', + project: true, + tsconfigRootDir: __dirname, }, - plugins: ['@typescript-eslint/eslint-plugin'], + plugins: ['@typescript-eslint'], extends: [ - 'plugin:@typescript-eslint/eslint-recommended', + 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', ], @@ -14,10 +14,5 @@ module.exports = { env: { node: true, jest: true, - }, - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, + } }; diff --git a/package-lock.json b/package-lock.json index 8a15cefb3..f9b6c39d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,8 +81,8 @@ "@types/node": "^17.0.41", "@types/passport-jwt": "^3.0.6", "@types/passport-local": "^1.0.34", - "@typescript-eslint/eslint-plugin": "^5.26.0", - "@typescript-eslint/parser": "^5.26.0", + "@typescript-eslint/eslint-plugin": "^6.2.0", + "@typescript-eslint/parser": "^6.2.0", "eslint": "^8.23.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", @@ -2367,6 +2367,30 @@ "axios": "^0.27.2" } }, + "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==", + "dev": true, + "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.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.1.tgz", + "integrity": "sha512-O7x6dMstWLn2ktjcoiNLDkAGG2EjveHL+Vvc+n0fXumkJYAcSqcVYKtwDU+hDZ0uDUsnUagSYaZrOLAYE8un1A==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", @@ -4787,9 +4811,9 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, "node_modules/@types/json5": { @@ -4935,9 +4959,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/semver": { - "version": "7.3.13", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", - "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, "node_modules/@types/serve-static": { @@ -4995,32 +5019,34 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.50.0.tgz", - "integrity": "sha512-vwksQWSFZiUhgq3Kv7o1Jcj0DUNylwnIlGvKvLLYsq8pAWha6/WCnXUeaSoNNha/K7QSf2+jvmkxggC1u3pIwQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.2.0.tgz", + "integrity": "sha512-rClGrMuyS/3j0ETa1Ui7s6GkLhfZGKZL3ZrChLeAiACBE/tRc1wq8SNZESUuluxhLj9FkUefRs2l6bCIArWBiQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/type-utils": "5.50.0", - "@typescript-eslint/utils": "5.50.0", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/type-utils": "6.2.0", + "@typescript-eslint/utils": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", "natural-compare-lite": "^1.4.0", - "regexpp": "^3.2.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -5029,25 +5055,26 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.50.0.tgz", - "integrity": "sha512-KCcSyNaogUDftK2G9RXfQyOCt51uB5yqC6pkUYqhYh8Kgt+DwR5M0EwEAxGPy/+DH6hnmKeGsNhiZRQxjH71uQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.2.0.tgz", + "integrity": "sha512-igVYOqtiK/UsvKAmmloQAruAdUHihsOCvplJpplPZ+3h4aDkC/UKZZNKgB6h93ayuYLuEymU3h8nF1xMRbh37g==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/typescript-estree": "5.50.0", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -5056,16 +5083,16 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.50.0.tgz", - "integrity": "sha512-rt03kaX+iZrhssaT974BCmoUikYtZI24Vp/kwTSy841XhiYShlqoshRFDvN1FKKvU2S3gK+kcBW1EA7kNUrogg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.2.0.tgz", + "integrity": "sha512-1ZMNVgm5nnHURU8ZSJ3snsHzpFeNK84rdZjluEVBGNu7jDymfqceB3kdIZ6A4xCfEFFhRIB6rF8q/JIqJd2R0Q==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/visitor-keys": "5.50.0" + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -5073,25 +5100,25 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.50.0.tgz", - "integrity": "sha512-dcnXfZ6OGrNCO7E5UY/i0ktHb7Yx1fV6fnQGGrlnfDhilcs6n19eIRcvLBqx6OQkrPaFlDPk3OJ0WlzQfrV0bQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.2.0.tgz", + "integrity": "sha512-DnGZuNU2JN3AYwddYIqrVkYW0uUQdv0AY+kz2M25euVNlujcN2u+rJgfJsBFlUEzBB6OQkUqSZPyuTLf2bP5mw==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.50.0", - "@typescript-eslint/utils": "5.50.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "@typescript-eslint/utils": "6.2.0", "debug": "^4.3.4", - "tsutils": "^3.21.0" + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "*" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -5100,12 +5127,12 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.50.0.tgz", - "integrity": "sha512-atruOuJpir4OtyNdKahiHZobPKFvZnBnfDiyEaBf6d9vy9visE7gDjlmhl+y29uxZ2ZDgvXijcungGFjGGex7w==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.2.0.tgz", + "integrity": "sha512-1nRRaDlp/XYJQLvkQJG5F3uBTno5SHPT7XVcJ5n1/k2WfNI28nJsvLakxwZRNY5spuatEKO7d5nZWsQpkqXwBA==", "dev": true, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -5113,21 +5140,21 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.50.0.tgz", - "integrity": "sha512-Gq4zapso+OtIZlv8YNAStFtT6d05zyVCK7Fx3h5inlLBx2hWuc/0465C2mg/EQDDU2LKe52+/jN4f0g9bd+kow==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.2.0.tgz", + "integrity": "sha512-Mts6+3HQMSM+LZCglsc2yMIny37IhUgp1Qe8yJUYVyO6rHP7/vN0vajKu3JvHCBIy8TSiKddJ/Zwu80jhnGj1w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/visitor-keys": "5.50.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -5140,42 +5167,41 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.50.0.tgz", - "integrity": "sha512-v/AnUFImmh8G4PH0NDkf6wA8hujNNcrwtecqW4vtQ1UOSNBaZl49zP1SHoZ/06e+UiwzHpgb5zP5+hwlYYWYAw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.2.0.tgz", + "integrity": "sha512-RCFrC1lXiX1qEZN8LmLrxYRhOkElEsPKTVSNout8DMzf8PeWoQG7Rxz2SadpJa3VSh5oYKGwt7j7X/VRg+Y3OQ==", "dev": true, "dependencies": { - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/typescript-estree": "5.50.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0", - "semver": "^7.3.7" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "semver": "^7.5.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.50.0.tgz", - "integrity": "sha512-cdMeD9HGu6EXIeGOh2yVW6oGf9wq8asBgZx7nsR/D36gTfQ0odE5kcRYe5M81vjEFAcPeugXrHg78Imu55F6gg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.2.0.tgz", + "integrity": "sha512-QbaYUQVKKo9bgCzpjz45llCfwakyoxHetIy8CAvYCtd16Zu1KrpzNHofwF8kGkpPOxZB2o6kz+0nqH8ZkIzuoQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.50.0", - "eslint-visitor-keys": "^3.3.0" + "@typescript-eslint/types": "6.2.0", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -8659,12 +8685,15 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ajv": { @@ -9809,6 +9838,12 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -16528,9 +16563,9 @@ "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==" }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "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" }, @@ -18049,6 +18084,18 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "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-graphviz": { "version": "0.16.0", "resolved": "https://registry.npmjs.org/ts-graphviz/-/ts-graphviz-0.16.0.tgz", @@ -18321,27 +18368,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -21463,6 +21489,21 @@ "axios": "^0.27.2" } }, + "@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==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + } + }, + "@eslint-community/regexpp": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.1.tgz", + "integrity": "sha512-O7x6dMstWLn2ktjcoiNLDkAGG2EjveHL+Vvc+n0fXumkJYAcSqcVYKtwDU+hDZ0uDUsnUagSYaZrOLAYE8un1A==", + "dev": true + }, "@eslint/eslintrc": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", @@ -23326,9 +23367,9 @@ } }, "@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, "@types/json5": { @@ -23474,9 +23515,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "@types/semver": { - "version": "7.3.13", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", - "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, "@types/serve-static": { @@ -23534,102 +23575,104 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.50.0.tgz", - "integrity": "sha512-vwksQWSFZiUhgq3Kv7o1Jcj0DUNylwnIlGvKvLLYsq8pAWha6/WCnXUeaSoNNha/K7QSf2+jvmkxggC1u3pIwQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.2.0.tgz", + "integrity": "sha512-rClGrMuyS/3j0ETa1Ui7s6GkLhfZGKZL3ZrChLeAiACBE/tRc1wq8SNZESUuluxhLj9FkUefRs2l6bCIArWBiQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/type-utils": "5.50.0", - "@typescript-eslint/utils": "5.50.0", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/type-utils": "6.2.0", + "@typescript-eslint/utils": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", "natural-compare-lite": "^1.4.0", - "regexpp": "^3.2.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/parser": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.50.0.tgz", - "integrity": "sha512-KCcSyNaogUDftK2G9RXfQyOCt51uB5yqC6pkUYqhYh8Kgt+DwR5M0EwEAxGPy/+DH6hnmKeGsNhiZRQxjH71uQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.2.0.tgz", + "integrity": "sha512-igVYOqtiK/UsvKAmmloQAruAdUHihsOCvplJpplPZ+3h4aDkC/UKZZNKgB6h93ayuYLuEymU3h8nF1xMRbh37g==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/typescript-estree": "5.50.0", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.50.0.tgz", - "integrity": "sha512-rt03kaX+iZrhssaT974BCmoUikYtZI24Vp/kwTSy841XhiYShlqoshRFDvN1FKKvU2S3gK+kcBW1EA7kNUrogg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.2.0.tgz", + "integrity": "sha512-1ZMNVgm5nnHURU8ZSJ3snsHzpFeNK84rdZjluEVBGNu7jDymfqceB3kdIZ6A4xCfEFFhRIB6rF8q/JIqJd2R0Q==", "dev": true, "requires": { - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/visitor-keys": "5.50.0" + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0" } }, "@typescript-eslint/type-utils": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.50.0.tgz", - "integrity": "sha512-dcnXfZ6OGrNCO7E5UY/i0ktHb7Yx1fV6fnQGGrlnfDhilcs6n19eIRcvLBqx6OQkrPaFlDPk3OJ0WlzQfrV0bQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.2.0.tgz", + "integrity": "sha512-DnGZuNU2JN3AYwddYIqrVkYW0uUQdv0AY+kz2M25euVNlujcN2u+rJgfJsBFlUEzBB6OQkUqSZPyuTLf2bP5mw==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "5.50.0", - "@typescript-eslint/utils": "5.50.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "@typescript-eslint/utils": "6.2.0", "debug": "^4.3.4", - "tsutils": "^3.21.0" + "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/types": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.50.0.tgz", - "integrity": "sha512-atruOuJpir4OtyNdKahiHZobPKFvZnBnfDiyEaBf6d9vy9visE7gDjlmhl+y29uxZ2ZDgvXijcungGFjGGex7w==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.2.0.tgz", + "integrity": "sha512-1nRRaDlp/XYJQLvkQJG5F3uBTno5SHPT7XVcJ5n1/k2WfNI28nJsvLakxwZRNY5spuatEKO7d5nZWsQpkqXwBA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.50.0.tgz", - "integrity": "sha512-Gq4zapso+OtIZlv8YNAStFtT6d05zyVCK7Fx3h5inlLBx2hWuc/0465C2mg/EQDDU2LKe52+/jN4f0g9bd+kow==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.2.0.tgz", + "integrity": "sha512-Mts6+3HQMSM+LZCglsc2yMIny37IhUgp1Qe8yJUYVyO6rHP7/vN0vajKu3JvHCBIy8TSiKddJ/Zwu80jhnGj1w==", "dev": true, "requires": { - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/visitor-keys": "5.50.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/visitor-keys": "6.2.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/utils": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.50.0.tgz", - "integrity": "sha512-v/AnUFImmh8G4PH0NDkf6wA8hujNNcrwtecqW4vtQ1UOSNBaZl49zP1SHoZ/06e+UiwzHpgb5zP5+hwlYYWYAw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.2.0.tgz", + "integrity": "sha512-RCFrC1lXiX1qEZN8LmLrxYRhOkElEsPKTVSNout8DMzf8PeWoQG7Rxz2SadpJa3VSh5oYKGwt7j7X/VRg+Y3OQ==", "dev": true, "requires": { - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.50.0", - "@typescript-eslint/types": "5.50.0", - "@typescript-eslint/typescript-estree": "5.50.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0", - "semver": "^7.3.7" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.2.0", + "@typescript-eslint/types": "6.2.0", + "@typescript-eslint/typescript-estree": "6.2.0", + "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "5.50.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.50.0.tgz", - "integrity": "sha512-cdMeD9HGu6EXIeGOh2yVW6oGf9wq8asBgZx7nsR/D36gTfQ0odE5kcRYe5M81vjEFAcPeugXrHg78Imu55F6gg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.2.0.tgz", + "integrity": "sha512-QbaYUQVKKo9bgCzpjz45llCfwakyoxHetIy8CAvYCtd16Zu1KrpzNHofwF8kGkpPOxZB2o6kz+0nqH8ZkIzuoQ==", "dev": true, "requires": { - "@typescript-eslint/types": "5.50.0", - "eslint-visitor-keys": "^3.3.0" + "@typescript-eslint/types": "6.2.0", + "eslint-visitor-keys": "^3.4.1" } }, "@webassemblyjs/ast": { @@ -26427,9 +26470,9 @@ } }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "dev": true }, "espree": { @@ -27250,6 +27293,12 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "graphql": { "version": "16.6.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", @@ -32420,9 +32469,9 @@ "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==" }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" }, @@ -33626,6 +33675,13 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "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, + "requires": {} + }, "ts-graphviz": { "version": "0.16.0", "resolved": "https://registry.npmjs.org/ts-graphviz/-/ts-graphviz-0.16.0.tgz", @@ -33834,23 +33890,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" }, - "tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } - } - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 4293c9f44..95006bf85 100644 --- a/package.json +++ b/package.json @@ -98,8 +98,8 @@ "@types/node": "^17.0.41", "@types/passport-jwt": "^3.0.6", "@types/passport-local": "^1.0.34", - "@typescript-eslint/eslint-plugin": "^5.26.0", - "@typescript-eslint/parser": "^5.26.0", + "@typescript-eslint/eslint-plugin": "^6.2.0", + "@typescript-eslint/parser": "^6.2.0", "eslint": "^8.23.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", From 3476ceb13720d3de82cfbe8e67cf5fe4222969aa Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Wed, 26 Jul 2023 01:19:30 +0300 Subject: [PATCH 02/11] SERVICES-1760: fix eslint error: no-unused-vars Signed-off-by: Claudiu Lataretu --- src/common.app.module.ts | 4 +- src/helpers/elastic.queries.ts | 2 - src/helpers/elastic.service.ts | 2 +- src/helpers/validators/metric.validator.ts | 2 +- src/helpers/validators/series.validator.ts | 2 +- src/helpers/validators/unix.time.validator.ts | 2 +- src/modules/analytics/analytics.resolver.ts | 8 +-- .../mocks/analytics.compute.service.mock.ts | 6 +- .../services/auto-router.compute.service.ts | 4 +- .../services/auto-router.service.ts | 20 +++++-- .../energy/mocks/energy.abi.service.mock.ts | 11 +--- src/modules/farm/base-module/farm.resolver.ts | 1 - .../farm/mocks/farm.compute.service.mock.ts | 8 +-- .../farm/mocks/farm.v1.2.abi.service.mock.ts | 12 ++-- .../farm/mocks/farm.v1.3.abi.service.mock.ts | 6 +- .../farm/mocks/farm.v2.abi.service.mock.ts | 24 +++----- .../specs/farm.transactions.service.spec.ts | 2 +- .../farm/v2/services/farm.v2.abi.service.ts | 9 +-- .../services/farm.v2.transaction.service.ts | 6 +- .../mocks/fees.collector.abi.service.mock.ts | 2 +- .../locked.token.wrapper.abi.service.mock.ts | 4 +- .../pair/mocks/pair.abi.service.mock.ts | 43 ++++++-------- .../pair/mocks/pair.compute.service.mock.ts | 12 ++-- .../mocks/price.discovery.abi.service.mock.ts | 42 +++++++------- .../price.discovery.compute.service.mock.ts | 12 ++-- .../mocks/price.discovery.service.mock.ts | 4 +- .../proxy/mocks/proxy.abi.service.mock.ts | 10 ++-- .../wrappedFarmTokenAttributes.model.ts | 1 - .../proxy/wrappedFarmToken.resolver.ts | 1 - .../handlers/feesCollector.handler.service.ts | 1 - .../mocks/simple.lock.abi.service.mock.ts | 10 ++-- .../simple.lock.transactions.service.ts | 1 + .../mocks/staking.proxy.abi.service.mock.ts | 14 ++--- .../staking.proxy.getter.service.mock.ts | 14 ++--- .../staking.proxy.transaction.service.spec.ts | 2 - .../staking/mocks/staking.abi.service.mock.ts | 46 +++++++-------- .../mocks/token.unstake.abi.service.mock.ts | 4 +- src/modules/tokens/nftToken.resolver.ts | 4 +- src/modules/tokens/token.resolver.ts | 1 - .../mocks/analytics.query.service.mock.ts | 30 +++------- src/services/caching/cache.service.ts | 3 +- .../context/context.setter.service.ts | 4 +- .../mocks/context.getter.service.mock.ts | 2 +- src/services/crons/logs.processor.service.ts | 3 +- .../mx.api.service.mock.ts | 6 +- .../mx.data.api.service.mock.ts | 2 +- .../mx.gateway.service.mock.ts | 4 +- .../mx.proxy.service.mock.ts | 2 +- .../week.timekeeping.abi.service.mock.ts | 4 +- .../weekly.rewards.splitting.abi.mock.ts | 30 +++------- src/utils/analytics.utils.ts | 1 - src/utils/ddTrace.ts | 56 +++++++++++-------- src/utils/performance.profiler.ts | 1 + 53 files changed, 220 insertions(+), 287 deletions(-) diff --git a/src/common.app.module.ts b/src/common.app.module.ts index 35f3297f2..1a982d98e 100644 --- a/src/common.app.module.ts +++ b/src/common.app.module.ts @@ -9,7 +9,7 @@ import * as Transport from 'winston-transport'; import { ApiConfigService } from './helpers/api.config.service'; import { RedisPubSubModule } from './services/redis.pubSub.module'; -const loglevel = !!process.env.LOG_LEVEL ? process.env.LOG_LEVEL : 'error'; +const loglevel = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : 'error'; const logTransports: Transport[] = [ new winston.transports.Console({ @@ -24,7 +24,7 @@ const logTransports: Transport[] = [ }), ]; -if (!!process.env.LOG_FILE) { +if (process.env.LOG_FILE) { logTransports.push( new winston.transports.File({ filename: process.env.LOG_FILE, diff --git a/src/helpers/elastic.queries.ts b/src/helpers/elastic.queries.ts index 0482cca6d..5ed13c530 100644 --- a/src/helpers/elastic.queries.ts +++ b/src/helpers/elastic.queries.ts @@ -43,10 +43,8 @@ export function buildElasticQuery(query: ElasticQuery) { }; if (Object.keys(elasticQuery.query.bool).length === 0) { - //@ts-ignore delete elasticQuery.query.bool; - //@ts-ignore elasticQuery.query['match_all'] = {}; } diff --git a/src/helpers/elastic.service.ts b/src/helpers/elastic.service.ts index a1c65a7f1..6697b4e8a 100644 --- a/src/helpers/elastic.service.ts +++ b/src/helpers/elastic.service.ts @@ -52,7 +52,7 @@ export class ElasticService { let response = await this.elasticClient.search(params); const hits = []; let scroll = 1; - while (true) { + for (;;) { const sourceHits = response.body.hits.hits; if (sourceHits.length === 0) { diff --git a/src/helpers/validators/metric.validator.ts b/src/helpers/validators/metric.validator.ts index 11889c7a4..00f77a83a 100644 --- a/src/helpers/validators/metric.validator.ts +++ b/src/helpers/validators/metric.validator.ts @@ -46,7 +46,7 @@ export class IsValidMetricConstraint implements ValidatorConstraintInterface { } export function IsValidMetric(validationOptions?: ValidationOptions) { - return (object: Object, propertyName: string) => { + return (object: object, propertyName: string) => { registerDecorator({ target: object.constructor, propertyName: propertyName, diff --git a/src/helpers/validators/series.validator.ts b/src/helpers/validators/series.validator.ts index d32484c86..0eb36dee9 100644 --- a/src/helpers/validators/series.validator.ts +++ b/src/helpers/validators/series.validator.ts @@ -31,7 +31,7 @@ export class IsValidSeriesConstraint implements ValidatorConstraintInterface { } export function IsValidSeries(validationOptions?: ValidationOptions) { - return (object: Object, propertyName: string) => { + return (object: object, propertyName: string) => { registerDecorator({ target: object.constructor, propertyName: propertyName, diff --git a/src/helpers/validators/unix.time.validator.ts b/src/helpers/validators/unix.time.validator.ts index 129882cd2..2e8411ef7 100644 --- a/src/helpers/validators/unix.time.validator.ts +++ b/src/helpers/validators/unix.time.validator.ts @@ -21,7 +21,7 @@ export class IsValidUnixTimeConstraint implements ValidatorConstraintInterface { } export function IsValidUnixTime(validationOptions?: ValidationOptions) { - return (object: Object, propertyName: string) => { + return (object: object, propertyName: string) => { registerDecorator({ target: object.constructor, propertyName: propertyName, diff --git a/src/modules/analytics/analytics.resolver.ts b/src/modules/analytics/analytics.resolver.ts index ff6e54ca8..9938b1d6b 100644 --- a/src/modules/analytics/analytics.resolver.ts +++ b/src/modules/analytics/analytics.resolver.ts @@ -147,9 +147,7 @@ export class AnalyticsResolver { skipUndefinedProperties: true, }), ) - async latestHistoricData( - @Args() args: AnalyticsQueryArgs, - ): Promise { + async latestHistoricData(): Promise { return []; } @@ -163,9 +161,7 @@ export class AnalyticsResolver { skipUndefinedProperties: true, }), ) - async latestBinnedHistoricData( - @Args() args: AnalyticsQueryArgs, - ): Promise { + async latestBinnedHistoricData(): Promise { return []; } } diff --git a/src/modules/analytics/mocks/analytics.compute.service.mock.ts b/src/modules/analytics/mocks/analytics.compute.service.mock.ts index 83c8dfdcc..67a7588e4 100644 --- a/src/modules/analytics/mocks/analytics.compute.service.mock.ts +++ b/src/modules/analytics/mocks/analytics.compute.service.mock.ts @@ -11,16 +11,16 @@ export class AnalyticsComputeServiceMock implements IAnalyticsComputeService { totalValueStakedUSD(): Promise { throw new Error('Method not implemented.'); } - totalAggregatedRewards(days: number): Promise { + totalAggregatedRewards(): Promise { throw new Error('Method not implemented.'); } totalLockedMexStakedUSD(): Promise { throw new Error('Method not implemented.'); } - feeTokenBurned(tokenID: string, time: string): Promise { + feeTokenBurned(): Promise { throw new Error('Method not implemented.'); } - penaltyTokenBurned(tokenID: string, time: string): Promise { + penaltyTokenBurned(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/auto-router/services/auto-router.compute.service.ts b/src/modules/auto-router/services/auto-router.compute.service.ts index 63a030f36..8ba4eb457 100644 --- a/src/modules/auto-router/services/auto-router.compute.service.ts +++ b/src/modules/auto-router/services/auto-router.compute.service.ts @@ -97,7 +97,7 @@ export class AutoRouterComputeService { pairs: PairModel[], initialAmountIn: string, ): Array { - const intermediaryAmounts: Array = new Array(); + const intermediaryAmounts: Array = []; for (const path of paths) { const pathAmounts: string[] = []; @@ -132,7 +132,7 @@ export class AutoRouterComputeService { pairs: PairModel[], fixedAmountOut: string, ): Array { - const intermediaryAmounts: Array = new Array(); + const intermediaryAmounts: Array = []; for (const path of paths) { const pathAmounts: string[] = []; diff --git a/src/modules/auto-router/services/auto-router.service.ts b/src/modules/auto-router/services/auto-router.service.ts index 5b41bda11..a36cf0b06 100644 --- a/src/modules/auto-router/services/auto-router.service.ts +++ b/src/modules/auto-router/services/auto-router.service.ts @@ -63,7 +63,9 @@ export class AutoRouterService { ), oneMinute() * 10, ); - } catch (error) {} + } catch (error) { + this.logger.error('Error when getting all paths', error); + } } async swap(args: AutoRouterArgs): Promise { @@ -146,9 +148,19 @@ export class AutoRouterService { this.pairCompute.tokenPriceUSD(tokenOutID), ]); - let [amountIn, amountOut] = this.isFixedInput(swapType) - ? [args.amountIn, result] - : [result, args.amountOut]; + // let [amountIn, amountOut] = this.isFixedInput(swapType) + // ? [args.amountIn, result] + // : [result, args.amountOut]; + + let amountIn: string; + let amountOut: string; + if (this.isFixedInput(swapType)) { + amountIn = args.amountIn; + amountOut = result; + } else { + amountIn = result; + amountOut = args.amountOut; + } const [tokenInExchangeRate, tokenOutExchangeRate] = this.calculateExchangeRate( diff --git a/src/modules/energy/mocks/energy.abi.service.mock.ts b/src/modules/energy/mocks/energy.abi.service.mock.ts index 5398ce0ba..2226f464c 100644 --- a/src/modules/energy/mocks/energy.abi.service.mock.ts +++ b/src/modules/energy/mocks/energy.abi.service.mock.ts @@ -1,5 +1,4 @@ import { EnergyType } from '@multiversx/sdk-exchange'; -import BigNumber from 'bignumber.js'; import { LockOption } from '../models/simple.lock.energy.model'; import { IEnergyAbiService } from '../services/interfaces'; import { EnergyAbiService } from '../services/energy.abi.service'; @@ -23,17 +22,13 @@ export class EnergyAbiServiceMock implements IEnergyAbiService { async ownerAddress(): Promise { throw new Error('Method not implemented.'); } - async energyEntryForUser(userAddress: string): Promise { + async energyEntryForUser(): Promise { throw new Error('Method not implemented.'); } - async energyAmountForUser(userAddress: string): Promise { + async energyAmountForUser(): Promise { throw new Error('Method not implemented.'); } - async getPenaltyAmount( - tokenAmount: BigNumber, - prevLockEpochs: number, - epochsToReduce: number, - ): Promise { + async getPenaltyAmount(): Promise { throw new Error('Method not implemented.'); } async isPaused(): Promise { diff --git a/src/modules/farm/base-module/farm.resolver.ts b/src/modules/farm/base-module/farm.resolver.ts index 25a75b12d..fae636ea4 100644 --- a/src/modules/farm/base-module/farm.resolver.ts +++ b/src/modules/farm/base-module/farm.resolver.ts @@ -1,7 +1,6 @@ import { Resolver, ResolveField, Parent } from '@nestjs/graphql'; import { BaseFarmModel } from '../models/farm.model'; import { PairModel } from '../../pair/models/pair.model'; -import { LockedAssetModel } from '../../locked-asset-factory/models/locked-asset.model'; import { EsdtToken } from '../../tokens/models/esdtToken.model'; import { NftCollection } from '../../tokens/models/nftCollection.model'; import { Address } from '@multiversx/sdk-core'; diff --git a/src/modules/farm/mocks/farm.compute.service.mock.ts b/src/modules/farm/mocks/farm.compute.service.mock.ts index 36b4ec362..6bde65c37 100644 --- a/src/modules/farm/mocks/farm.compute.service.mock.ts +++ b/src/modules/farm/mocks/farm.compute.service.mock.ts @@ -2,16 +2,16 @@ import { FarmComputeService } from '../base-module/services/farm.compute.service import { IFarmComputeService } from '../base-module/services/interfaces'; export class FarmComputeServiceMock implements IFarmComputeService { - farmLockedValueUSD(farmAddress: string): Promise { + farmLockedValueUSD(): Promise { throw new Error('Method not implemented.'); } - async farmedTokenPriceUSD(farmAddress: string): Promise { + async farmedTokenPriceUSD(): Promise { return '100'; } - async farmTokenPriceUSD(farmAddress: string): Promise { + async farmTokenPriceUSD(): Promise { return '200'; } - async farmingTokenPriceUSD(farmAddress: string): Promise { + async farmingTokenPriceUSD(): Promise { return '200'; } } diff --git a/src/modules/farm/mocks/farm.v1.2.abi.service.mock.ts b/src/modules/farm/mocks/farm.v1.2.abi.service.mock.ts index bfb02991a..d3611935f 100644 --- a/src/modules/farm/mocks/farm.v1.2.abi.service.mock.ts +++ b/src/modules/farm/mocks/farm.v1.2.abi.service.mock.ts @@ -8,7 +8,7 @@ export class FarmAbiServiceMockV1_2 extends FarmAbiServiceMock implements IFarmAbiServiceV1_2 { - lockedAssetFactoryAddress(farmAddress: string): Promise { + lockedAssetFactoryAddress(): Promise { throw new Error('Method not implemented.'); } async farmingTokenReserve(farmAddress: string): Promise { @@ -18,18 +18,16 @@ export class FarmAbiServiceMockV1_2 } return farm.farmingTokenReserve; } - async undistributedFees(farmAddress: string): Promise { + async undistributedFees(): Promise { return '100'; } - async currentBlockFee(farmAddress: string): Promise { + async currentBlockFee(): Promise { return '0'; } - async lockedRewardAprMuliplier(farmAddress: string): Promise { + async lockedRewardAprMuliplier(): Promise { return 2; } - farmMigrationConfiguration( - farmAddress: string, - ): Promise { + farmMigrationConfiguration(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/farm/mocks/farm.v1.3.abi.service.mock.ts b/src/modules/farm/mocks/farm.v1.3.abi.service.mock.ts index 15d3d88f7..c47a46452 100644 --- a/src/modules/farm/mocks/farm.v1.3.abi.service.mock.ts +++ b/src/modules/farm/mocks/farm.v1.3.abi.service.mock.ts @@ -7,12 +7,10 @@ export class FarmAbiServiceMockV1_3 extends FarmAbiServiceMock implements IFarmAbiServiceV1_3 { - lockedAssetFactoryAddress(farmAddress: string): Promise { + lockedAssetFactoryAddress(): Promise { throw new Error('Method not implemented.'); } - farmMigrationConfiguration( - farmAddress: string, - ): Promise { + farmMigrationConfiguration(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/farm/mocks/farm.v2.abi.service.mock.ts b/src/modules/farm/mocks/farm.v2.abi.service.mock.ts index c4b3e89ff..4ea84e73b 100644 --- a/src/modules/farm/mocks/farm.v2.abi.service.mock.ts +++ b/src/modules/farm/mocks/farm.v2.abi.service.mock.ts @@ -7,47 +7,41 @@ export class FarmAbiServiceMockV2 extends FarmAbiServiceMock implements IFarmAbiServiceV2 { - async lastUndistributedBoostedRewardsCollectWeek( - farmAddress: string, - ): Promise { + async lastUndistributedBoostedRewardsCollectWeek(): Promise { return 1; } - async undistributedBoostedRewards(farmAddress: string): Promise { + async undistributedBoostedRewards(): Promise { return '5000'; } - async remainingBoostedRewardsToDistribute( - farmAddress: string, - week: number, - ): Promise { + async remainingBoostedRewardsToDistribute(): Promise { return '1000'; } - accumulatedRewardsForWeek(scAddress: string, week: number): Promise { + accumulatedRewardsForWeek(): Promise { throw new Error('Method not implemented.'); } - boostedYieldsFactors(farmAddress: string): Promise { + boostedYieldsFactors(): Promise { throw new Error('Method not implemented.'); } - boostedYieldsRewardsPercenatage(farmAddress: string): Promise { + boostedYieldsRewardsPercenatage(): Promise { throw new Error('Method not implemented.'); } - energyFactoryAddress(farmAddress: string): Promise { + energyFactoryAddress(): Promise { throw new Error('Method not implemented.'); } - lockEpochs(farmAddress: string): Promise { + lockEpochs(): Promise { throw new Error('Method not implemented.'); } - lockingScAddress(farmAddress: string): Promise { + lockingScAddress(): Promise { throw new Error('Method not implemented.'); } } - export const FarmAbiServiceProviderV2 = { provide: FarmAbiServiceV2, useClass: FarmAbiServiceMockV2, diff --git a/src/modules/farm/specs/farm.transactions.service.spec.ts b/src/modules/farm/specs/farm.transactions.service.spec.ts index 57ffcb2ef..a4e9a860f 100644 --- a/src/modules/farm/specs/farm.transactions.service.spec.ts +++ b/src/modules/farm/specs/farm.transactions.service.spec.ts @@ -167,7 +167,7 @@ describe('FarmService', () => { FarmTransactionServiceV1_2, ); - let error: any; + let error: Error; try { await transactionV1_2.compoundRewards(Address.Zero().bech32(), { farmAddress: diff --git a/src/modules/farm/v2/services/farm.v2.abi.service.ts b/src/modules/farm/v2/services/farm.v2.abi.service.ts index 80b467036..ec0078082 100644 --- a/src/modules/farm/v2/services/farm.v2.abi.service.ts +++ b/src/modules/farm/v2/services/farm.v2.abi.service.ts @@ -42,11 +42,11 @@ export class FarmAbiServiceV2 super(mxProxy, gatewayService, mxApi); } - async getLastErrorMessageRaw(farmAddress: string): Promise { + async getLastErrorMessageRaw(): Promise { return undefined; } - async getTransferExecGasLimitRaw(farmAddress: string): Promise { + async getTransferExecGasLimitRaw(): Promise { return undefined; } @@ -196,8 +196,9 @@ export class FarmAbiServiceV2 async lastUndistributedBoostedRewardsCollectWeek( farmAddress: string, ): Promise { - return this.gatewayService.getSCStorageKey(farmAddress, - 'lastUndistributedBoostedRewardsCollectWeek' + return this.gatewayService.getSCStorageKey( + farmAddress, + 'lastUndistributedBoostedRewardsCollectWeek', ); } diff --git a/src/modules/farm/v2/services/farm.v2.transaction.service.ts b/src/modules/farm/v2/services/farm.v2.transaction.service.ts index f4ea2743c..63705a9f4 100644 --- a/src/modules/farm/v2/services/farm.v2.transaction.service.ts +++ b/src/modules/farm/v2/services/farm.v2.transaction.service.ts @@ -9,7 +9,6 @@ import { EnterFarmArgs, ExitFarmArgs, ClaimRewardsArgs, - CompoundRewardsArgs, } from '../../models/farm.args'; import { FarmRewardType, FarmVersion } from '../../models/farm.model'; import { ErrorLoggerAsync } from 'src/helpers/decorators/error.logger'; @@ -133,10 +132,7 @@ export class FarmTransactionServiceV2 extends TransactionsFarmService { .toPlainObject(); } - compoundRewards( - sender: string, - args: CompoundRewardsArgs, - ): Promise { + compoundRewards(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/fees-collector/mocks/fees.collector.abi.service.mock.ts b/src/modules/fees-collector/mocks/fees.collector.abi.service.mock.ts index 8484cbbd7..adacbd711 100644 --- a/src/modules/fees-collector/mocks/fees.collector.abi.service.mock.ts +++ b/src/modules/fees-collector/mocks/fees.collector.abi.service.mock.ts @@ -2,7 +2,7 @@ import { FeesCollectorAbiService } from '../services/fees-collector.abi.service' import { IFeesCollectorAbiService } from '../services/interfaces'; export class FeesCollectorAbiServiceMock implements IFeesCollectorAbiService { - async accumulatedFees(week: number, token: string): Promise { + async accumulatedFees(): Promise { return '0'; } async lockedTokenID(): Promise { diff --git a/src/modules/locked-token-wrapper/mocks/locked.token.wrapper.abi.service.mock.ts b/src/modules/locked-token-wrapper/mocks/locked.token.wrapper.abi.service.mock.ts index 7f8e1bb41..f1144514a 100644 --- a/src/modules/locked-token-wrapper/mocks/locked.token.wrapper.abi.service.mock.ts +++ b/src/modules/locked-token-wrapper/mocks/locked.token.wrapper.abi.service.mock.ts @@ -5,11 +5,11 @@ import { LockedTokenWrapperAbiService } from '../services/locked-token-wrapper.a export class LockedTokenWrapperAbiServiceMock implements ILockedTokenWrapperAbiService { - async wrappedTokenId(address: string): Promise { + async wrappedTokenId(): Promise { return 'WXMEX-123456'; } - energyFactoryAddress(address: string): Promise { + energyFactoryAddress(): Promise { return scAddress.simpleLockEnergy; } } diff --git a/src/modules/pair/mocks/pair.abi.service.mock.ts b/src/modules/pair/mocks/pair.abi.service.mock.ts index 859bafd48..9823f49b3 100644 --- a/src/modules/pair/mocks/pair.abi.service.mock.ts +++ b/src/modules/pair/mocks/pair.abi.service.mock.ts @@ -17,7 +17,7 @@ export class PairAbiServiceMock implements IPairAbiService { async lpTokenID(pairAddress: string): Promise { return PairsData(pairAddress)?.liquidityPoolToken.identifier; } - tokenReserve(pairAddress: string, tokenID: string): Promise { + tokenReserve(): Promise { throw new Error('Method not implemented.'); } async firstTokenReserve(pairAddress: string): Promise { @@ -35,65 +35,58 @@ export class PairAbiServiceMock implements IPairAbiService { async totalFeePercent(pairAddress: string): Promise { return PairsData(pairAddress).totalFeePercent; } - specialFeePercent(pairAddress: string): Promise { + specialFeePercent(): Promise { throw new Error('Method not implemented.'); } - async trustedSwapPairs(pairAddress: string): Promise { + async trustedSwapPairs(): Promise { return []; } - async initialLiquidityAdder(pairAddress: string): Promise { + async initialLiquidityAdder(): Promise { return Address.Zero().bech32(); } async state(pairAddress: string): Promise { return PairsData(pairAddress).state; } - feeState(pairAddress: string): Promise { + feeState(): Promise { throw new Error('Method not implemented.'); } - async lockingScAddress(pairAddress: string): Promise { + async lockingScAddress(): Promise { return Address.Zero().bech32(); } - async unlockEpoch(pairAddress: string): Promise { + async unlockEpoch(): Promise { return 1; } - async lockingDeadlineEpoch(pairAddress: string): Promise { + async lockingDeadlineEpoch(): Promise { return 1; } - feeDestinations(pairAddress: string): Promise { + feeDestinations(): Promise { throw new Error('Method not implemented.'); } - whitelistedAddresses(pairAddress: string): Promise { + whitelistedAddresses(): Promise { throw new Error('Method not implemented.'); } - routerAddress(pairAddress: string): Promise { + routerAddress(): Promise { throw new Error('Method not implemented.'); } - routerOwnerAddress(pairAddress: string): Promise { + routerOwnerAddress(): Promise { throw new Error('Method not implemented.'); } - externSwapGasLimit(pairAddress: string): Promise { + externSwapGasLimit(): Promise { throw new Error('Method not implemented.'); } - transferExecGasLimit(pairAddress: string): Promise { + transferExecGasLimit(): Promise { throw new Error('Method not implemented.'); } - safePrice( - pairAddress: string, - esdtTokenPayment: EsdtTokenPayment, - ): Promise { + safePrice(): Promise { throw new Error('Method not implemented.'); } - numSwapsByAddress(pairAddress: string, address: string): Promise { + numSwapsByAddress(): Promise { throw new Error('Method not implemented.'); } - numAddsByAddress(pairAddress: string, address: string): Promise { + numAddsByAddress(): Promise { throw new Error('Method not implemented.'); } - async getTemporaryFunds( - pairAddress: string, - callerAddress: string, - tokenID: string, - ): Promise { + async getTemporaryFunds(): Promise { return new BigNumber(100); } } diff --git a/src/modules/pair/mocks/pair.compute.service.mock.ts b/src/modules/pair/mocks/pair.compute.service.mock.ts index 3e7cefe1f..52d82896c 100644 --- a/src/modules/pair/mocks/pair.compute.service.mock.ts +++ b/src/modules/pair/mocks/pair.compute.service.mock.ts @@ -63,22 +63,22 @@ export class PairComputeServiceMock implements IPairComputeService { async lockedValueUSD(pairAddress: string): Promise { return PairsData(pairAddress).lockedValueUSD; } - firstTokenVolume(pairAddress: string, time: string): Promise { + firstTokenVolume(): Promise { throw new Error('Method not implemented.'); } - secondTokenVolume(pairAddress: string, time: string): Promise { + secondTokenVolume(): Promise { throw new Error('Method not implemented.'); } - volumeUSD(pairAddress: string, time: string): Promise { + volumeUSD(): Promise { throw new Error('Method not implemented.'); } - feesUSD(pairAddress: string, time: string): Promise { + feesUSD(): Promise { throw new Error('Method not implemented.'); } - async feesAPR(pairAddress: string): Promise { + async feesAPR(): Promise { return '10'; } - type(pairAddress: string): Promise { + type(): Promise { throw new Error('Method not implemented.'); } diff --git a/src/modules/price-discovery/mocks/price.discovery.abi.service.mock.ts b/src/modules/price-discovery/mocks/price.discovery.abi.service.mock.ts index 37477e966..225569d1b 100644 --- a/src/modules/price-discovery/mocks/price.discovery.abi.service.mock.ts +++ b/src/modules/price-discovery/mocks/price.discovery.abi.service.mock.ts @@ -3,68 +3,64 @@ import { IPriceDiscoveryAbiService } from '../services/interfaces'; import { PriceDiscoveryAbiService } from '../services/price.discovery.abi.service'; export class PriceDiscoveryAbiServiceMock implements IPriceDiscoveryAbiService { - async launchedTokenID(priceDiscoveryAddress: string): Promise { + async launchedTokenID(): Promise { return 'LTOK-123456'; } - async acceptedTokenID(priceDiscoveryAddress: string): Promise { + async acceptedTokenID(): Promise { return 'ATOK-123456'; } - async redeemTokenID(priceDiscoveryAddress: string): Promise { + async redeemTokenID(): Promise { return 'RTOK-123456'; } - launchedTokenAmount(priceDiscoveryAddress: string): Promise { + launchedTokenAmount(): Promise { throw new Error('Method not implemented.'); } - acceptedTokenAmount(priceDiscoveryAddress: string): Promise { + acceptedTokenAmount(): Promise { throw new Error('Method not implemented.'); } - launchedTokenRedeemAmount(priceDiscoveryAddress: string): Promise { + launchedTokenRedeemAmount(): Promise { throw new Error('Method not implemented.'); } - acceptedTokenRedeemAmount(priceDiscoveryAddress: string): Promise { + acceptedTokenRedeemAmount(): Promise { throw new Error('Method not implemented.'); } - async startBlock(priceDiscoveryAddress: string): Promise { + async startBlock(): Promise { return 1; } - async endBlock(priceDiscoveryAddress: string): Promise { + async endBlock(): Promise { return 10; } - currentPhase(priceDiscoveryAddress: string): Promise { + currentPhase(): Promise { throw new Error('Method not implemented.'); } - minLaunchedTokenPrice(priceDiscoveryAddress: string): Promise { + minLaunchedTokenPrice(): Promise { throw new Error('Method not implemented.'); } - noLimitPhaseDurationBlocks(priceDiscoveryAddress: string): Promise { + noLimitPhaseDurationBlocks(): Promise { throw new Error('Method not implemented.'); } - linearPenaltyPhaseDurationBlocks( - priceDiscoveryAddress: string, - ): Promise { + linearPenaltyPhaseDurationBlocks(): Promise { throw new Error('Method not implemented.'); } - fixedPenaltyPhaseDurationBlocks( - priceDiscoveryAddress: string, - ): Promise { + fixedPenaltyPhaseDurationBlocks(): Promise { throw new Error('Method not implemented.'); } - lockingScAddress(priceDiscoveryAddress: string): Promise { + lockingScAddress(): Promise { throw new Error('Method not implemented.'); } - unlockEpoch(priceDiscoveryAddress: string): Promise { + unlockEpoch(): Promise { throw new Error('Method not implemented.'); } - penaltyMinPercentage(priceDiscoveryAddress: string): Promise { + penaltyMinPercentage(): Promise { throw new Error('Method not implemented.'); } - penaltyMaxPercentage(priceDiscoveryAddress: string): Promise { + penaltyMaxPercentage(): Promise { throw new Error('Method not implemented.'); } - fixedPenaltyPercentage(priceDiscoveryAddress: string): Promise { + fixedPenaltyPercentage(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/price-discovery/mocks/price.discovery.compute.service.mock.ts b/src/modules/price-discovery/mocks/price.discovery.compute.service.mock.ts index b80d39e0a..4848b867c 100644 --- a/src/modules/price-discovery/mocks/price.discovery.compute.service.mock.ts +++ b/src/modules/price-discovery/mocks/price.discovery.compute.service.mock.ts @@ -4,20 +4,16 @@ import { PriceDiscoveryComputeService } from '../services/price.discovery.comput export class PriceDiscoveryComputeServiceMock implements IPriceDiscoveryComputeService { - launchedTokenPrice(priceDiscoveryAddress: string): Promise { + launchedTokenPrice(): Promise { throw new Error('Method not implemented.'); } - acceptedTokenPrice(priceDiscoveryAddress: string): Promise { + acceptedTokenPrice(): Promise { throw new Error('Method not implemented.'); } - async launchedTokenPriceUSD( - priceDiscoveryAddress: string, - ): Promise { + async launchedTokenPriceUSD(): Promise { return '1'; } - async acceptedTokenPriceUSD( - priceDiscoveryAddress: string, - ): Promise { + async acceptedTokenPriceUSD(): Promise { return '100'; } } diff --git a/src/modules/price-discovery/mocks/price.discovery.service.mock.ts b/src/modules/price-discovery/mocks/price.discovery.service.mock.ts index 13d4b869b..fb63ae882 100644 --- a/src/modules/price-discovery/mocks/price.discovery.service.mock.ts +++ b/src/modules/price-discovery/mocks/price.discovery.service.mock.ts @@ -1,9 +1,7 @@ import { PriceDiscoveryService } from '../services/price.discovery.service'; class PriceDiscoveryServiceMock { - async getPriceDiscoveryAddresByRedeemToken( - tokenID: string, - ): Promise { + async getPriceDiscoveryAddresByRedeemToken(): Promise { return 'price_discovery_sc'; } } diff --git a/src/modules/proxy/mocks/proxy.abi.service.mock.ts b/src/modules/proxy/mocks/proxy.abi.service.mock.ts index c54984dd6..927673d7a 100644 --- a/src/modules/proxy/mocks/proxy.abi.service.mock.ts +++ b/src/modules/proxy/mocks/proxy.abi.service.mock.ts @@ -8,25 +8,25 @@ import { ProxyAbiService } from '../services/proxy.abi.service'; import { ProxyFarmAbiService } from '../services/proxy-farm/proxy.farm.abi.service'; export class ProxyAbiServiceMock implements IProxyAbiService { - async lockedAssetTokenID(proxyAddress: string): Promise { + async lockedAssetTokenID(): Promise { return ['LKMEX-1234']; } } export class ProxyPairAbiServiceMock implements IProxyPairAbiService { - async wrappedLpTokenID(proxyAddress: string): Promise { + async wrappedLpTokenID(): Promise { return 'LKLP-abcd'; } - intermediatedPairs(proxyAddress: string): Promise { + intermediatedPairs(): Promise { throw new Error('Method not implemented.'); } } export class ProxyFarmAbiServiceMock implements IProxyFarmAbiService { - async wrappedFarmTokenID(proxyAddress: string): Promise { + async wrappedFarmTokenID(): Promise { return 'LKFARM-1234'; } - intermediatedFarms(proxyAddress: string): Promise { + intermediatedFarms(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/proxy/models/wrappedFarmTokenAttributes.model.ts b/src/modules/proxy/models/wrappedFarmTokenAttributes.model.ts index e9236463b..52ed9a3dd 100644 --- a/src/modules/proxy/models/wrappedFarmTokenAttributes.model.ts +++ b/src/modules/proxy/models/wrappedFarmTokenAttributes.model.ts @@ -2,7 +2,6 @@ import { Field, Int, ObjectType } from '@nestjs/graphql'; import { LockedAssetAttributesModel } from 'src/modules/locked-asset-factory/models/locked-asset.model'; import { EsdtTokenPaymentModel } from 'src/modules/tokens/models/esdt.token.payment.model'; import { FarmTokenAttributesUnion } from '../../farm/models/farmTokenAttributes.model'; -import { LockedAssetAttributesUnion } from './locked.assets.attributes.union'; import { WrappedLpTokenAttributesModel, WrappedLpTokenAttributesModelV2, diff --git a/src/modules/proxy/wrappedFarmToken.resolver.ts b/src/modules/proxy/wrappedFarmToken.resolver.ts index 58e8fa690..d940506ef 100644 --- a/src/modules/proxy/wrappedFarmToken.resolver.ts +++ b/src/modules/proxy/wrappedFarmToken.resolver.ts @@ -1,6 +1,5 @@ import { UseGuards } from '@nestjs/common'; import { Args, Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; -import { ApolloError } from 'apollo-server-express'; import { MXApiService } from 'src/services/multiversx-communication/mx.api.service'; import { tokenCollection, tokenIdentifier } from 'src/utils/token.converters'; import { JwtOrNativeAuthGuard } from '../auth/jwt.or.native.auth.guard'; diff --git a/src/modules/rabbitmq/handlers/feesCollector.handler.service.ts b/src/modules/rabbitmq/handlers/feesCollector.handler.service.ts index 89d7efa90..97efc6218 100644 --- a/src/modules/rabbitmq/handlers/feesCollector.handler.service.ts +++ b/src/modules/rabbitmq/handlers/feesCollector.handler.service.ts @@ -4,7 +4,6 @@ import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { PUB_SUB } from 'src/services/redis.pubSub.module'; import { Logger } from 'winston'; import { FeesCollectorSetterService } from '../../fees-collector/services/fees-collector.setter.service'; -import { scAddress } from '../../../config'; import BigNumber from 'bignumber.js'; import { DepositSwapFeesEvent, diff --git a/src/modules/simple-lock/mocks/simple.lock.abi.service.mock.ts b/src/modules/simple-lock/mocks/simple.lock.abi.service.mock.ts index 787b311ac..a2ea43383 100644 --- a/src/modules/simple-lock/mocks/simple.lock.abi.service.mock.ts +++ b/src/modules/simple-lock/mocks/simple.lock.abi.service.mock.ts @@ -2,23 +2,23 @@ import { ISimpleLockAbiService } from '../services/interfaces'; import { SimpleLockAbiService } from '../services/simple.lock.abi.service'; export class SimpleLockAbiServiceMock implements ISimpleLockAbiService { - async lockedTokenID(simpleLockAddress: string): Promise { + async lockedTokenID(): Promise { return 'LKESDT-1234'; } - async lpProxyTokenID(simpleLockAddress: string): Promise { + async lpProxyTokenID(): Promise { return 'LKPL-abcd'; } - async farmProxyTokenID(simpleLockAddress: string): Promise { + async farmProxyTokenID(): Promise { return 'LKFARM-abcd'; } - async intermediatedPairs(simpleLockAddress: string): Promise { + async intermediatedPairs(): Promise { throw new Error('Method not implemented.'); } - async intermediatedFarms(simpleLockAddress: string): Promise { + async intermediatedFarms(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/simple-lock/services/simple.lock.transactions.service.ts b/src/modules/simple-lock/services/simple.lock.transactions.service.ts index 562a99565..b3db71d1e 100644 --- a/src/modules/simple-lock/services/simple.lock.transactions.service.ts +++ b/src/modules/simple-lock/services/simple.lock.transactions.service.ts @@ -127,6 +127,7 @@ export class SimpleLockTransactionService { secondTokenInput.amount, ), ); + break; default: break; } diff --git a/src/modules/staking-proxy/mocks/staking.proxy.abi.service.mock.ts b/src/modules/staking-proxy/mocks/staking.proxy.abi.service.mock.ts index 818bcce1a..848ee5224 100644 --- a/src/modules/staking-proxy/mocks/staking.proxy.abi.service.mock.ts +++ b/src/modules/staking-proxy/mocks/staking.proxy.abi.service.mock.ts @@ -3,25 +3,25 @@ import { IStakingProxyAbiService } from '../services/interfaces'; import { StakingProxyAbiService } from '../services/staking.proxy.abi.service'; export class StakingProxyAbiServiceMock implements IStakingProxyAbiService { - async lpFarmAddress(stakingProxyAddress: string): Promise { + async lpFarmAddress(): Promise { return Address.Zero().bech32(); } - async stakingFarmAddress(stakingProxyAddress: string): Promise { + async stakingFarmAddress(): Promise { return Address.Zero().bech32(); } - async pairAddress(stakingProxyAddress: string): Promise { + async pairAddress(): Promise { return Address.Zero().bech32(); } - async stakingTokenID(stakingProxyAddress: string): Promise { + async stakingTokenID(): Promise { return 'WEGLD-123456'; } - async farmTokenID(stakingProxyAddress: string): Promise { + async farmTokenID(): Promise { return 'STAKETOK-1111'; } - async dualYieldTokenID(stakingProxyAddress: string): Promise { + async dualYieldTokenID(): Promise { return 'METASTAKE-1234'; } - async lpFarmTokenID(stakingProxyAddress: string): Promise { + async lpFarmTokenID(): Promise { return 'EGLDTOK4FL-abcdef'; } } diff --git a/src/modules/staking-proxy/mocks/staking.proxy.getter.service.mock.ts b/src/modules/staking-proxy/mocks/staking.proxy.getter.service.mock.ts index 45ae9a382..120dda9be 100644 --- a/src/modules/staking-proxy/mocks/staking.proxy.getter.service.mock.ts +++ b/src/modules/staking-proxy/mocks/staking.proxy.getter.service.mock.ts @@ -1,31 +1,31 @@ import { Address } from '@multiversx/sdk-core'; export class StakingProxyGetterServiceMock { - async getLpFarmAddress(stakingProxyAddress: string): Promise { + async getLpFarmAddress(): Promise { return Address.Zero().bech32(); } - async getStakingFarmAddress(stakingProxyAddress: string): Promise { + async getStakingFarmAddress(): Promise { return Address.Zero().bech32(); } - async getPairAddress(stakingProxyAddress: string): Promise { + async getPairAddress(): Promise { return Address.Zero().bech32(); } - async getStakingTokenID(stakingProxyAddress: string): Promise { + async getStakingTokenID(): Promise { return 'WEGLD-123456'; } - async getFarmTokenID(stakingProxyAddress: string): Promise { + async getFarmTokenID(): Promise { return 'STAKETOK-1111'; } - async getDualYieldTokenID(stakingProxyAddress: string): Promise { + async getDualYieldTokenID(): Promise { return 'METASTAKE-1234'; } - async getLpFarmTokenID(stakingProxyAddress: string): Promise { + async getLpFarmTokenID(): Promise { return 'EGLDTOK4FL-abcdef'; } } diff --git a/src/modules/staking-proxy/specs/staking.proxy.transaction.service.spec.ts b/src/modules/staking-proxy/specs/staking.proxy.transaction.service.spec.ts index 47c10cd5b..2660e554d 100644 --- a/src/modules/staking-proxy/specs/staking.proxy.transaction.service.spec.ts +++ b/src/modules/staking-proxy/specs/staking.proxy.transaction.service.spec.ts @@ -17,8 +17,6 @@ import { FarmComputeServiceV1_3 } from 'src/modules/farm/v1.3/services/farm.v1.3 import { FarmAbiServiceV2 } from 'src/modules/farm/v2/services/farm.v2.abi.service'; import { FarmAbiServiceMock } from 'src/modules/farm/mocks/farm.abi.service.mock'; import { FarmComputeServiceV2 } from 'src/modules/farm/v2/services/farm.v2.compute.service'; -import { FarmAbiServiceV1_3 } from 'src/modules/farm/v1.3/services/farm.v1.3.abi.service'; -import { FarmAbiServiceV1_2 } from 'src/modules/farm/v1.2/services/farm.v1.2.abi.service'; import { ContextGetterServiceProvider } from 'src/services/context/mocks/context.getter.service.mock'; import { WeekTimekeepingAbiServiceProvider } from 'src/submodules/week-timekeeping/mocks/week.timekeeping.abi.service.mock'; import { WeeklyRewardsSplittingAbiServiceProvider } from 'src/submodules/weekly-rewards-splitting/mocks/weekly.rewards.splitting.abi.mock'; diff --git a/src/modules/staking/mocks/staking.abi.service.mock.ts b/src/modules/staking/mocks/staking.abi.service.mock.ts index bf42b16d3..97f65800b 100644 --- a/src/modules/staking/mocks/staking.abi.service.mock.ts +++ b/src/modules/staking/mocks/staking.abi.service.mock.ts @@ -4,71 +4,67 @@ import { StakingAbiService } from '../services/staking.abi.service'; import { Address } from '@multiversx/sdk-core/out'; export class StakingAbiServiceMock implements IStakingAbiService { - async pairContractAddress(stakeAddress: string): Promise { + async pairContractAddress(): Promise { return Address.Zero().bech32(); } - async farmTokenID(stakeAddress: string): Promise { + async farmTokenID(): Promise { return 'STAKETOK-1111'; } - async farmingTokenID(stakeAddress: string): Promise { + async farmingTokenID(): Promise { return 'WEGLD-123456'; } - async rewardTokenID(stakeAddress: string): Promise { + async rewardTokenID(): Promise { return 'WEGLD-123456'; } - async farmTokenSupply(stakeAddress: string): Promise { + async farmTokenSupply(): Promise { return '5256000000000000000'; } - async rewardPerShare(stakeAddress: string): Promise { + async rewardPerShare(): Promise { return '150000000000000000000'; } - async accumulatedRewards(stakeAddress: string): Promise { + async accumulatedRewards(): Promise { return '10000000000000000000'; } - async rewardCapacity(stakeAddress: string): Promise { + async rewardCapacity(): Promise { return '10000000000000000000000'; } - async annualPercentageRewards(stakeAddress: string): Promise { + async annualPercentageRewards(): Promise { return new BigNumber(1000).toFixed(); } - minUnbondEpochs(stakeAddress: string): Promise { + minUnbondEpochs(): Promise { throw new Error('Method not implemented.'); } - async perBlockRewardsAmount(stakeAddress: string): Promise { + async perBlockRewardsAmount(): Promise { return new BigNumber(500000000).toFixed(); } - async lastRewardBlockNonce(stakeAddress: string): Promise { + async lastRewardBlockNonce(): Promise { return new BigNumber(100).toNumber(); } - async divisionSafetyConstant(stakeAddress: string): Promise { + async divisionSafetyConstant(): Promise { return new BigNumber(1000000000000).toNumber(); } - async produceRewardsEnabled(stakeAddress: string): Promise { + async produceRewardsEnabled(): Promise { return true; } - burnGasLimit(stakeAddress: string): Promise { + burnGasLimit(): Promise { throw new Error('Method not implemented.'); } - transferExecGasLimit(stakeAddress: string): Promise { + transferExecGasLimit(): Promise { throw new Error('Method not implemented.'); } - state(stakeAddress: string): Promise { + state(): Promise { throw new Error('Method not implemented.'); } - calculateRewardsForGivenPosition( - stakeAddress: string, - amount: string, - attributes: string, - ): Promise { + calculateRewardsForGivenPosition(): Promise { throw new Error('Method not implemented.'); } - lockedAssetFactoryAddress(stakeAddress: string): Promise { + lockedAssetFactoryAddress(): Promise { throw new Error('Method not implemented.'); } - isWhitelisted(stakeAddress: string, scAddress: string): Promise { + isWhitelisted(): Promise { throw new Error('Method not implemented.'); } - lastErrorMessage(stakeAddress: string): Promise { + lastErrorMessage(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/modules/token-unstake/mocks/token.unstake.abi.service.mock.ts b/src/modules/token-unstake/mocks/token.unstake.abi.service.mock.ts index 60f8cae62..592d0deb6 100644 --- a/src/modules/token-unstake/mocks/token.unstake.abi.service.mock.ts +++ b/src/modules/token-unstake/mocks/token.unstake.abi.service.mock.ts @@ -17,9 +17,7 @@ export class TokenUnstakeAbiServiceMock implements ITokenUnstakeAbiService { throw new Error('Method not implemented.'); } - async unlockedTokensForUser( - userAddress: string, - ): Promise { + async unlockedTokensForUser(): Promise { return [ new UnstakePairModel({ lockedTokens: new EsdtTokenPaymentModel({ diff --git a/src/modules/tokens/nftToken.resolver.ts b/src/modules/tokens/nftToken.resolver.ts index a810a76ff..30f20c431 100644 --- a/src/modules/tokens/nftToken.resolver.ts +++ b/src/modules/tokens/nftToken.resolver.ts @@ -1,4 +1,4 @@ -import { Args, Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; +import { Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; import { ApolloError } from 'apollo-server-express'; import { GenericResolver } from 'src/services/generics/generic.resolver'; import { AssetsModel } from './models/assets.model'; @@ -12,7 +12,7 @@ export class NftTokenResolver extends GenericResolver { } @Query(() => NftToken) - async nftToken(@Args('identifier') identifier: string): Promise { + async nftToken(): Promise { throw new ApolloError('Query not implemented'); } } diff --git a/src/modules/tokens/token.resolver.ts b/src/modules/tokens/token.resolver.ts index 1c80d150a..e8a017598 100644 --- a/src/modules/tokens/token.resolver.ts +++ b/src/modules/tokens/token.resolver.ts @@ -1,6 +1,5 @@ import { Args, Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; import { ApolloError } from 'apollo-server-express'; -import { constantsConfig } from 'src/config'; import { AssetsModel } from './models/assets.model'; import { EsdtToken } from './models/esdtToken.model'; import { RolesModel } from './models/roles.model'; diff --git a/src/services/analytics/mocks/analytics.query.service.mock.ts b/src/services/analytics/mocks/analytics.query.service.mock.ts index 93e9d9d41..c1bcdc783 100644 --- a/src/services/analytics/mocks/analytics.query.service.mock.ts +++ b/src/services/analytics/mocks/analytics.query.service.mock.ts @@ -1,43 +1,27 @@ import { HistoricDataModel } from 'src/modules/analytics/models/analytics.model'; -import { AnalyticsQueryArgs } from '../entities/analytics.query.args'; import { AnalyticsQueryInterface } from '../interfaces/analytics.query.interface'; import { AnalyticsQueryService } from '../services/analytics.query.service'; export class AnalyticsQueryServiceMock implements AnalyticsQueryInterface { - getPDlatestValue({ - series, - metric, - }: AnalyticsQueryArgs): Promise { + getPDlatestValue(): Promise { throw new Error('Method not implemented.'); } - getPDCloseValues({ - series, - metric, - timeBucket, - }: { - series: any; - metric: any; - timeBucket: any; - }): Promise { + getPDCloseValues(): Promise { throw new Error('Method not implemented.'); } - getAggregatedValue(args: AnalyticsQueryArgs): Promise { + getAggregatedValue(): Promise { throw new Error('Method not implemented.'); } - getLatestCompleteValues( - args: AnalyticsQueryArgs, - ): Promise { + getLatestCompleteValues(): Promise { throw new Error('Method not implemented.'); } - getSumCompleteValues( - args: AnalyticsQueryArgs, - ): Promise { + getSumCompleteValues(): Promise { throw new Error('Method not implemented.'); } - getValues24h(args: AnalyticsQueryArgs): Promise { + getValues24h(): Promise { throw new Error('Method not implemented.'); } - getValues24hSum(args: AnalyticsQueryArgs): Promise { + getValues24hSum(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/services/caching/cache.service.ts b/src/services/caching/cache.service.ts index 265b4a589..aa6f301ec 100644 --- a/src/services/caching/cache.service.ts +++ b/src/services/caching/cache.service.ts @@ -1,7 +1,6 @@ import { Injectable, Inject, CACHE_MANAGER } from '@nestjs/common'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { Logger } from 'winston'; -import { generateSetLogMessage } from '../../utils/generate-log-message'; import { Cache } from 'cache-manager'; import { cacheConfig } from '../../config'; import { PerformanceProfiler } from '../../utils/performance.profiler'; @@ -128,7 +127,7 @@ export class CachingService { } getCacheLocal(key: string): T | undefined { - const cachedValue: any = localCache.get(key) as T; + const cachedValue: any = localCache.get(key); if (!cachedValue) { return undefined; diff --git a/src/services/context/context.setter.service.ts b/src/services/context/context.setter.service.ts index 07c39986e..b7c2dce16 100644 --- a/src/services/context/context.setter.service.ts +++ b/src/services/context/context.setter.service.ts @@ -1,8 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; -import { oneHour, oneSecond } from 'src/helpers/helpers'; -import { EsdtToken } from 'src/modules/tokens/models/esdtToken.model'; -import { NftCollection } from 'src/modules/tokens/models/nftCollection.model'; +import { oneSecond } from 'src/helpers/helpers'; import { generateCacheKeyFromParams } from 'src/utils/generate-cache-key'; import { Logger } from 'winston'; import { CachingService } from '../caching/cache.service'; diff --git a/src/services/context/mocks/context.getter.service.mock.ts b/src/services/context/mocks/context.getter.service.mock.ts index 3c054d84b..bb7660e4b 100644 --- a/src/services/context/mocks/context.getter.service.mock.ts +++ b/src/services/context/mocks/context.getter.service.mock.ts @@ -5,7 +5,7 @@ export class ContextGetterServiceMock { return 1; } - async getShardCurrentBlockNonce(shardID: number): Promise { + async getShardCurrentBlockNonce(): Promise { return 111; } } diff --git a/src/services/crons/logs.processor.service.ts b/src/services/crons/logs.processor.service.ts index e3de8a86c..d3092ffea 100644 --- a/src/services/crons/logs.processor.service.ts +++ b/src/services/crons/logs.processor.service.ts @@ -295,7 +295,7 @@ export class LogsProcessorService { for (const event of events) { switch (event.identifier) { - case 'exitFarm': + case 'exitFarm': { if (event.data === '') { break; } @@ -309,6 +309,7 @@ export class LogsProcessorService { break; } break; + } case 'ESDTLocalBurn': esdtLocalBurnEvents.push(new EsdtLocalBurnEvent(event)); break; diff --git a/src/services/multiversx-communication/mx.api.service.mock.ts b/src/services/multiversx-communication/mx.api.service.mock.ts index 8a42bdb83..28a74fdac 100644 --- a/src/services/multiversx-communication/mx.api.service.mock.ts +++ b/src/services/multiversx-communication/mx.api.service.mock.ts @@ -9,7 +9,7 @@ export class MXApiServiceMock { return 1; } - async getAccountStats(address: string): Promise { + async getAccountStats(): Promise { return { address: 'user_address_1', nonce: 1, @@ -20,7 +20,7 @@ export class MXApiServiceMock { }; } - async getTokensForUser(address: string): Promise { + async getTokensForUser(): Promise { return [ new EsdtToken({ ...Tokens('MEX-123456'), @@ -29,7 +29,7 @@ export class MXApiServiceMock { ]; } - async getNftsForUser(address: string): Promise { + async getNftsForUser(): Promise { return [ { collection: 'EGLDMEXFL-abcdef', diff --git a/src/services/multiversx-communication/mx.data.api.service.mock.ts b/src/services/multiversx-communication/mx.data.api.service.mock.ts index e10a90542..9ffe7540b 100644 --- a/src/services/multiversx-communication/mx.data.api.service.mock.ts +++ b/src/services/multiversx-communication/mx.data.api.service.mock.ts @@ -1,7 +1,7 @@ import { MXDataApiService } from './mx.data.api.service'; export class MXDataApiServiceMock { - async getTokenPrice(tokenTicker: string): Promise { + async getTokenPrice(): Promise { return 1; } } diff --git a/src/services/multiversx-communication/mx.gateway.service.mock.ts b/src/services/multiversx-communication/mx.gateway.service.mock.ts index 5c8a0e231..fd0fee9a7 100644 --- a/src/services/multiversx-communication/mx.gateway.service.mock.ts +++ b/src/services/multiversx-communication/mx.gateway.service.mock.ts @@ -1,11 +1,11 @@ import { MXGatewayService } from './mx.gateway.service'; export class MXGatewayServiceMock { - async getSCStorageKey(address: string, key: string): Promise { + async getSCStorageKey(): Promise { throw new Error('Method not implemented.'); } - async getSCStorageKeys(address: string, keys: any[]): Promise { + async getSCStorageKeys(): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/services/multiversx-communication/mx.proxy.service.mock.ts b/src/services/multiversx-communication/mx.proxy.service.mock.ts index 170be4a6f..90a7c2136 100644 --- a/src/services/multiversx-communication/mx.proxy.service.mock.ts +++ b/src/services/multiversx-communication/mx.proxy.service.mock.ts @@ -8,7 +8,7 @@ import { promises } from 'fs'; import { MXProxyService } from './mx.proxy.service'; export class MXProxyServiceMock extends MXProxyService { - async getAddressShardID(address: string): Promise { + async getAddressShardID(): Promise { return 0; } diff --git a/src/submodules/week-timekeeping/mocks/week.timekeeping.abi.service.mock.ts b/src/submodules/week-timekeeping/mocks/week.timekeeping.abi.service.mock.ts index 931a614e1..16e488451 100644 --- a/src/submodules/week-timekeeping/mocks/week.timekeeping.abi.service.mock.ts +++ b/src/submodules/week-timekeeping/mocks/week.timekeeping.abi.service.mock.ts @@ -4,10 +4,10 @@ import { WeekTimekeepingAbiService } from '../services/week-timekeeping.abi.serv export class WeekTimekeepingAbiServiceMock implements IWeekTimekeepingAbiService { - async currentWeek(scAddress: string): Promise { + async currentWeek(): Promise { return 250; } - async firstWeekStartEpoch(scAddress: string): Promise { + async firstWeekStartEpoch(): Promise { return 250; } } diff --git a/src/submodules/weekly-rewards-splitting/mocks/weekly.rewards.splitting.abi.mock.ts b/src/submodules/weekly-rewards-splitting/mocks/weekly.rewards.splitting.abi.mock.ts index 8c0d9ce63..3f962158c 100644 --- a/src/submodules/weekly-rewards-splitting/mocks/weekly.rewards.splitting.abi.mock.ts +++ b/src/submodules/weekly-rewards-splitting/mocks/weekly.rewards.splitting.abi.mock.ts @@ -7,34 +7,21 @@ import { WeeklyRewardsSplittingAbiService } from '../services/weekly-rewards-spl export class WeeklyRewardsSplittingAbiServiceMock implements IWeeklyRewardsSplittingAbiService { - currentClaimProgress( - scAddress: string, - user: string, - ): Promise { + currentClaimProgress(): Promise { throw new Error('Method not implemented.'); } - userEnergyForWeek( - scAddress: string, - userAddress: string, - week: number, - ): Promise { + userEnergyForWeek(): Promise { throw new Error('Method not implemented.'); } - async lastActiveWeekForUser( - scAddress: string, - userAddress: string, - ): Promise { + async lastActiveWeekForUser(): Promise { return 0; } - lastGlobalUpdateWeek(scAddress: string): Promise { + lastGlobalUpdateWeek(): Promise { throw new Error('Method not implemented.'); } - async totalRewardsForWeek( - scAddress: string, - week: number, - ): Promise { + async totalRewardsForWeek(): Promise { return [ new EsdtTokenPayment({ amount: '100000000000000000000', @@ -50,13 +37,10 @@ export class WeeklyRewardsSplittingAbiServiceMock }), ]; } - async totalEnergyForWeek(scAddress: string, week: number): Promise { + async totalEnergyForWeek(): Promise { return '1000'; } - async totalLockedTokensForWeek( - scAddress: string, - week: number, - ): Promise { + async totalLockedTokensForWeek(): Promise { return '1000'; } } diff --git a/src/utils/analytics.utils.ts b/src/utils/analytics.utils.ts index a01a5f359..7644f13fe 100644 --- a/src/utils/analytics.utils.ts +++ b/src/utils/analytics.utils.ts @@ -29,7 +29,6 @@ export const convertBinToTimeResolution = (bin: string): TimeResolution => { switch (bin) { case '30s': return TimeResolution.INTERVAL_30_SECONDS; - case '30s': case '1m': return TimeResolution.INTERVAL_1_MINUTE; case '10m': diff --git a/src/utils/ddTrace.ts b/src/utils/ddTrace.ts index 212e5ffc0..aa4295649 100644 --- a/src/utils/ddTrace.ts +++ b/src/utils/ddTrace.ts @@ -1,35 +1,43 @@ import tracer from 'dd-trace'; export function AsyncDDTrace() { - return (_target: Object, _key: string | symbol, descriptor: PropertyDescriptor) => { - const childMethod = descriptor.value; - - descriptor.value = async function (...args: any[]) { - const traceName = childMethod.name; - const activeSpan = tracer.scope().active(); - const span = tracer.startSpan(traceName, { - childOf: activeSpan - }); - - const result = await childMethod.apply(this, args); - span.finish(); - return result; + return ( + _target: object, + _key: string | symbol, + descriptor: PropertyDescriptor, + ) => { + const childMethod = descriptor.value; + + descriptor.value = async function (...args: any[]) { + const traceName = childMethod.name; + const activeSpan = tracer.scope().active(); + const span = tracer.startSpan(traceName, { + childOf: activeSpan, + }); + + const result = await childMethod.apply(this, args); + span.finish(); + return result; + }; + + return descriptor; }; - - return descriptor; - }; } export function SyncDDTrace() { - return (_target: Object, _key: string | symbol, descriptor: PropertyDescriptor) => { - const childMethod = descriptor.value; + return ( + _target: object, + _key: string | symbol, + descriptor: PropertyDescriptor, + ) => { + const childMethod = descriptor.value; - descriptor.value = function (...args: any[]) { - const traceName = childMethod.name; + descriptor.value = function (...args: any[]) { + const traceName = childMethod.name; - return tracer.wrap(traceName, childMethod.apply(this, args)); - }; + return tracer.wrap(traceName, childMethod.apply(this, args)); + }; - return descriptor; - }; + return descriptor; + }; } diff --git a/src/utils/performance.profiler.ts b/src/utils/performance.profiler.ts index cc5c44d96..06910acc0 100644 --- a/src/utils/performance.profiler.ts +++ b/src/utils/performance.profiler.ts @@ -16,5 +16,6 @@ export class PerformanceProfiler { stop(description: string | null = null) { this.stopped = Date.now(); this.duration = this.stopped - this.started; + this.description = description || this.description; } } From 5dbaf5693efd0a7b76e0b16fdc9d752a16333410 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 17:16:39 +0300 Subject: [PATCH 03/11] SERVICES-1760: resolve remaining eslint warnings Signed-off-by: Claudiu Lataretu --- .eslintrc.js | 3 +++ .../energy/validators/locked.tokens.validator.ts | 4 ++-- src/modules/escrow/escrow.resolver.ts | 2 +- src/modules/escrow/validators/admin.validator.ts | 4 ++-- .../escrow/validators/sender.cooldown.validator.ts | 4 ++-- .../escrow/validators/transfer.tokens.validator.ts | 4 ++-- .../farm/custom/services/farm.custom.service.ts | 10 ++-------- src/modules/farm/mocks/farm.service.mock.ts | 2 +- .../governance/models/governance.contract.model.ts | 2 +- .../metabonding/mocks/metabonding.abi.service.mock.ts | 4 ++-- .../metabonding/validators/locked.token.validator.ts | 4 ++-- .../proxy/validators/add.liquidity.input.validator.ts | 4 ++-- .../proxy/validators/enter.farm.proxy.valodator.ts | 4 ++-- .../proxy/validators/merge.wrapped.token.validator.ts | 4 ++-- .../proxy/validators/wrapped.farm.token.validator.ts | 4 ++-- src/modules/proxy/validators/wrapped.lp.validator.ts | 7 ++----- .../validators/enter.farm.tokens.validator.ts | 4 ++-- .../simple-lock/validators/farm.token.validator.ts | 4 ++-- .../validators/liquidity.token.validator.ts | 4 ++-- .../simple-lock/validators/lpProxy.token.validator.ts | 4 ++-- .../simple-lock/validators/unlock.tokens.validator.ts | 4 ++-- src/modules/staking/staking.resolver.ts | 9 +-------- 22 files changed, 41 insertions(+), 54 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 378c82182..9e2240791 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,5 +14,8 @@ module.exports = { env: { node: true, jest: true, + }, + rules: { + "@typescript-eslint/no-explicit-any": ["off"], } }; diff --git a/src/modules/energy/validators/locked.tokens.validator.ts b/src/modules/energy/validators/locked.tokens.validator.ts index 012890247..6446f681d 100644 --- a/src/modules/energy/validators/locked.tokens.validator.ts +++ b/src/modules/energy/validators/locked.tokens.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { EnergyAbiService } from '../services/energy.abi.service'; @@ -7,7 +7,7 @@ import { EnergyAbiService } from '../services/energy.abi.service'; export class LockedEnergyTokensValidationPipe implements PipeTransform { constructor(private readonly energyAbi: EnergyAbiService) {} - async transform(value: InputTokenModel[], metadata: ArgumentMetadata) { + async transform(value: InputTokenModel[]) { const lockedTokenID = await this.energyAbi.lockedTokenID(); const lockedTokens = []; diff --git a/src/modules/escrow/escrow.resolver.ts b/src/modules/escrow/escrow.resolver.ts index ab9799f7c..305948607 100644 --- a/src/modules/escrow/escrow.resolver.ts +++ b/src/modules/escrow/escrow.resolver.ts @@ -141,7 +141,7 @@ export class EscrowResolver { async cancelEscrowTransfer( @Args('sender') sender: string, @Args('receiver') receiver: string, - @AuthUser(EscrowAdminValidator) _user: UserAuthResult, + @AuthUser(EscrowAdminValidator) user: UserAuthResult, ): Promise { return this.escrowTransaction.cancelTransfer(sender, receiver); } diff --git a/src/modules/escrow/validators/admin.validator.ts b/src/modules/escrow/validators/admin.validator.ts index 896cc4391..08f587a36 100644 --- a/src/modules/escrow/validators/admin.validator.ts +++ b/src/modules/escrow/validators/admin.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { ForbiddenError } from 'apollo-server-express'; import { UserAuthResult } from 'src/modules/auth/user.auth.result'; import { SCPermissions } from '../models/escrow.model'; @@ -8,7 +8,7 @@ import { EscrowAbiService } from '../services/escrow.abi.service'; export class EscrowAdminValidator implements PipeTransform { constructor(private readonly escrowAbi: EscrowAbiService) {} - async transform(value: UserAuthResult, metadata: ArgumentMetadata) { + async transform(value: UserAuthResult) { const permissions = await this.escrowAbi.addressPermission( value.address, ); diff --git a/src/modules/escrow/validators/sender.cooldown.validator.ts b/src/modules/escrow/validators/sender.cooldown.validator.ts index 3c55adf4a..b4a850453 100644 --- a/src/modules/escrow/validators/sender.cooldown.validator.ts +++ b/src/modules/escrow/validators/sender.cooldown.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { ForbiddenError } from 'apollo-server-express'; import { UserAuthResult } from 'src/modules/auth/user.auth.result'; import { EscrowComputeService } from '../services/escrow.compute.service'; @@ -7,7 +7,7 @@ import { EscrowComputeService } from '../services/escrow.compute.service'; export class SenderCooldownValidator implements PipeTransform { constructor(private readonly escrowCompute: EscrowComputeService) {} - async transform(value: UserAuthResult, metadata: ArgumentMetadata) { + async transform(value: UserAuthResult) { const isAddressOnCooldown = await this.escrowCompute.isSenderAddressOnCooldown(value.address); if (isAddressOnCooldown) { diff --git a/src/modules/escrow/validators/transfer.tokens.validator.ts b/src/modules/escrow/validators/transfer.tokens.validator.ts index 228f5f0c6..68a6ffc64 100644 --- a/src/modules/escrow/validators/transfer.tokens.validator.ts +++ b/src/modules/escrow/validators/transfer.tokens.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { EscrowAbiService } from '../services/escrow.abi.service'; @@ -7,7 +7,7 @@ import { EscrowAbiService } from '../services/escrow.abi.service'; export class TransferTokensValidator implements PipeTransform { constructor(private readonly escrowAbi: EscrowAbiService) {} - async transform(value: InputTokenModel[], metadata: ArgumentMetadata) { + async transform(value: InputTokenModel[]) { const lockedTokenID = await this.escrowAbi.lockedTokenID(); for (const payment of value) { if (payment.tokenID !== lockedTokenID || payment.nonce < 1) { diff --git a/src/modules/farm/custom/services/farm.custom.service.ts b/src/modules/farm/custom/services/farm.custom.service.ts index bd5f1b419..8129aac19 100644 --- a/src/modules/farm/custom/services/farm.custom.service.ts +++ b/src/modules/farm/custom/services/farm.custom.service.ts @@ -1,6 +1,5 @@ import { Inject, Injectable, forwardRef } from '@nestjs/common'; import { FarmServiceBase } from '../../base-module/services/farm.base.service'; -import { CalculateRewardsArgs } from '../../models/farm.args'; import { RewardsModel } from '../../models/farm.model'; import { FarmTokenAttributesModel } from '../../models/farmTokenAttributes.model'; import { FarmCustomAbiService } from './farm.custom.abi.service'; @@ -22,15 +21,10 @@ export class FarmCustomService extends FarmServiceBase { super(farmAbi, farmCompute, contextGetter, cachingService, tokenGetter); } - getRewardsForPosition( - positon: CalculateRewardsArgs, - ): Promise { + getRewardsForPosition(): Promise { throw new Error('Method not implemented.'); } - decodeFarmTokenAttributes( - identifier: string, - attributes: string, - ): FarmTokenAttributesModel { + decodeFarmTokenAttributes(): FarmTokenAttributesModel { throw new Error('Method not implemented.'); } } diff --git a/src/modules/farm/mocks/farm.service.mock.ts b/src/modules/farm/mocks/farm.service.mock.ts index 06b28175e..dad13d12b 100644 --- a/src/modules/farm/mocks/farm.service.mock.ts +++ b/src/modules/farm/mocks/farm.service.mock.ts @@ -22,7 +22,7 @@ export class FarmServiceBaseMock { return Tokens(farmingToken.identifier); } - async isFarmToken(tokenID: string): Promise { + async isFarmToken(): Promise { return true; } diff --git a/src/modules/governance/models/governance.contract.model.ts b/src/modules/governance/models/governance.contract.model.ts index f7a80f52a..e35bd1fc7 100644 --- a/src/modules/governance/models/governance.contract.model.ts +++ b/src/modules/governance/models/governance.contract.model.ts @@ -23,7 +23,7 @@ export class GovernanceTokenSnapshotContract { @Field(() => [GovernanceProposalModel]) proposals: GovernanceProposalModel[]; @Field(() => Int) - vetoPercentageLimit: number = 30; + vetoPercentageLimit = 30; constructor(init: Partial) { Object.assign(this, init); diff --git a/src/modules/metabonding/mocks/metabonding.abi.service.mock.ts b/src/modules/metabonding/mocks/metabonding.abi.service.mock.ts index 8f0afa6ad..bd9b4abe6 100644 --- a/src/modules/metabonding/mocks/metabonding.abi.service.mock.ts +++ b/src/modules/metabonding/mocks/metabonding.abi.service.mock.ts @@ -9,10 +9,10 @@ export class MetabondingAbiServiceMock implements IMetabondingAbiService { totalLockedAssetSupply(): Promise { throw new Error('Method not implemented.'); } - stakedAmountForUser(userAddress: string): Promise { + stakedAmountForUser(): Promise { throw new Error('Method not implemented.'); } - async userEntry(userAddress: string): Promise { + async userEntry(): Promise { return new UserEntryModel({ stakedAmount: '0', tokenNonce: 0, diff --git a/src/modules/metabonding/validators/locked.token.validator.ts b/src/modules/metabonding/validators/locked.token.validator.ts index 5502dc208..38bea5517 100644 --- a/src/modules/metabonding/validators/locked.token.validator.ts +++ b/src/modules/metabonding/validators/locked.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { MetabondingAbiService } from '../services/metabonding.abi.service'; @@ -7,7 +7,7 @@ import { MetabondingAbiService } from '../services/metabonding.abi.service'; export class LockedTokenValidator implements PipeTransform { constructor(private readonly metabondingAbi: MetabondingAbiService) {} - async transform(value: InputTokenModel, metadata: ArgumentMetadata) { + async transform(value: InputTokenModel) { const lockedAssetTokenID = await this.metabondingAbi.lockedAssetTokenID(); diff --git a/src/modules/proxy/validators/add.liquidity.input.validator.ts b/src/modules/proxy/validators/add.liquidity.input.validator.ts index d9de3ee11..d608e0281 100644 --- a/src/modules/proxy/validators/add.liquidity.input.validator.ts +++ b/src/modules/proxy/validators/add.liquidity.input.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { scAddress } from 'src/config'; import { AddLiquidityProxyArgs } from '../models/proxy-pair.args'; @@ -8,7 +8,7 @@ import { ProxyPairAbiService } from '../services/proxy-pair/proxy.pair.abi.servi export class LiquidityTokensValidationPipe implements PipeTransform { constructor(private readonly proxyPairAbi: ProxyPairAbiService) {} - async transform(value: AddLiquidityProxyArgs, metadata: ArgumentMetadata) { + async transform(value: AddLiquidityProxyArgs) { if (value.tokens.length < 2) { throw new UserInputError('invalid number of tokens'); } diff --git a/src/modules/proxy/validators/enter.farm.proxy.valodator.ts b/src/modules/proxy/validators/enter.farm.proxy.valodator.ts index 4cbd1f5e5..d2ba9a7c7 100644 --- a/src/modules/proxy/validators/enter.farm.proxy.valodator.ts +++ b/src/modules/proxy/validators/enter.farm.proxy.valodator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { EnterFarmProxyArgs } from '../models/proxy-farm.args'; import { ProxyService } from '../services/proxy.service'; @@ -11,7 +11,7 @@ export class EnterFarmProxyValidationPipe implements PipeTransform { private readonly proxyFarmAbi: ProxyFarmAbiService, ) {} - async transform(value: EnterFarmProxyArgs, metadata: ArgumentMetadata) { + async transform(value: EnterFarmProxyArgs) { if (value.tokens[0].nonce < 1) { throw new UserInputError('invalid meta esdt token'); } diff --git a/src/modules/proxy/validators/merge.wrapped.token.validator.ts b/src/modules/proxy/validators/merge.wrapped.token.validator.ts index 0b332b09b..c2f029af2 100644 --- a/src/modules/proxy/validators/merge.wrapped.token.validator.ts +++ b/src/modules/proxy/validators/merge.wrapped.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { ProxyService } from '../services/proxy.service'; @@ -7,7 +7,7 @@ import { ProxyService } from '../services/proxy.service'; export class MergeWrappedTokenValidationPipe implements PipeTransform { constructor(private readonly proxyService: ProxyService) {} - async transform(value: InputTokenModel[], metadata: ArgumentMetadata) { + async transform(value: InputTokenModel[]) { const proxyAddress = await this.proxyService.getProxyAddressByToken( value[0].tokenID, ); diff --git a/src/modules/proxy/validators/wrapped.farm.token.validator.ts b/src/modules/proxy/validators/wrapped.farm.token.validator.ts index 2c9350e81..34a7188d1 100644 --- a/src/modules/proxy/validators/wrapped.farm.token.validator.ts +++ b/src/modules/proxy/validators/wrapped.farm.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { ExitFarmProxyArgs } from '../models/proxy-farm.args'; import { ProxyService } from '../services/proxy.service'; @@ -11,7 +11,7 @@ export class WrappedFarmValidationPipe implements PipeTransform { private readonly proxyFarmAbi: ProxyFarmAbiService, ) {} - async transform(value: ExitFarmProxyArgs, metadata: ArgumentMetadata) { + async transform(value: ExitFarmProxyArgs) { if (value.wrappedFarmTokenNonce < 1) { throw new UserInputError('invalid meta esdt token'); } diff --git a/src/modules/proxy/validators/wrapped.lp.validator.ts b/src/modules/proxy/validators/wrapped.lp.validator.ts index 10675930c..ebbd5c972 100644 --- a/src/modules/proxy/validators/wrapped.lp.validator.ts +++ b/src/modules/proxy/validators/wrapped.lp.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { RemoveLiquidityProxyArgs } from '../models/proxy-pair.args'; import { ProxyService } from '../services/proxy.service'; @@ -11,10 +11,7 @@ export class WrappedLpValidationPipe implements PipeTransform { private readonly proxyPairAbi: ProxyPairAbiService, ) {} - async transform( - value: RemoveLiquidityProxyArgs, - metadata: ArgumentMetadata, - ) { + async transform(value: RemoveLiquidityProxyArgs) { if (value.wrappedLpTokenNonce < 1) { throw new UserInputError('invalid meta esdt token'); } diff --git a/src/modules/simple-lock/validators/enter.farm.tokens.validator.ts b/src/modules/simple-lock/validators/enter.farm.tokens.validator.ts index 36d89e738..0e562c59f 100644 --- a/src/modules/simple-lock/validators/enter.farm.tokens.validator.ts +++ b/src/modules/simple-lock/validators/enter.farm.tokens.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { SimpleLockService } from '../services/simple.lock.service'; @@ -11,7 +11,7 @@ export class EmterFarmProxyTokensValidationPipe implements PipeTransform { private readonly simpleLockAbi: SimpleLockAbiService, ) {} - async transform(value: InputTokenModel[], metadata: ArgumentMetadata) { + async transform(value: InputTokenModel[]) { const simpleLockAddress = await this.simpleLockService.getSimpleLockAddressFromInputTokens( value, diff --git a/src/modules/simple-lock/validators/farm.token.validator.ts b/src/modules/simple-lock/validators/farm.token.validator.ts index ef9596c64..5b44cade3 100644 --- a/src/modules/simple-lock/validators/farm.token.validator.ts +++ b/src/modules/simple-lock/validators/farm.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { SimpleLockService } from '../services/simple.lock.service'; @@ -11,7 +11,7 @@ export class FarmProxyTokensValidationPipe implements PipeTransform { private readonly simpleLockAbi: SimpleLockAbiService, ) {} - async transform(value: InputTokenModel, metadata: ArgumentMetadata) { + async transform(value: InputTokenModel) { const simpleLockAddress = await this.simpleLockService.getSimpleLockAddressFromInputTokens([ value, diff --git a/src/modules/simple-lock/validators/liquidity.token.validator.ts b/src/modules/simple-lock/validators/liquidity.token.validator.ts index 40c6b9a62..5c6fe1e0e 100644 --- a/src/modules/simple-lock/validators/liquidity.token.validator.ts +++ b/src/modules/simple-lock/validators/liquidity.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { SimpleLockService } from '../services/simple.lock.service'; @@ -11,7 +11,7 @@ export class LiquidityTokensValidationPipe implements PipeTransform { private readonly simpleLockAbi: SimpleLockAbiService, ) {} - async transform(value: InputTokenModel[], metadata: ArgumentMetadata) { + async transform(value: InputTokenModel[]) { const simpleLockAddress = await this.simpleLockService.getSimpleLockAddressFromInputTokens( value, diff --git a/src/modules/simple-lock/validators/lpProxy.token.validator.ts b/src/modules/simple-lock/validators/lpProxy.token.validator.ts index 5652af49f..8ac448729 100644 --- a/src/modules/simple-lock/validators/lpProxy.token.validator.ts +++ b/src/modules/simple-lock/validators/lpProxy.token.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { SimpleLockService } from '../services/simple.lock.service'; @@ -11,7 +11,7 @@ export class LpProxyTokensValidationPipe implements PipeTransform { private readonly simpleLockAbi: SimpleLockAbiService, ) {} - async transform(value: InputTokenModel, metadata: ArgumentMetadata) { + async transform(value: InputTokenModel) { const simpleLockAddress = await this.simpleLockService.getSimpleLockAddressFromInputTokens([ value, diff --git a/src/modules/simple-lock/validators/unlock.tokens.validator.ts b/src/modules/simple-lock/validators/unlock.tokens.validator.ts index 3fe950bcd..5fe3dab28 100644 --- a/src/modules/simple-lock/validators/unlock.tokens.validator.ts +++ b/src/modules/simple-lock/validators/unlock.tokens.validator.ts @@ -1,4 +1,4 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { UserInputError } from 'apollo-server-express'; import { InputTokenModel } from 'src/models/inputToken.model'; import { SimpleLockService } from '../services/simple.lock.service'; @@ -11,7 +11,7 @@ export class UnlockTokensValidationPipe implements PipeTransform { private readonly simpleLockAbi: SimpleLockAbiService, ) {} - async transform(value: InputTokenModel, metadata: ArgumentMetadata) { + async transform(value: InputTokenModel) { const simpleLockAddress = await this.simpleLockService.getSimpleLockAddressFromInputTokens([ value, diff --git a/src/modules/staking/staking.resolver.ts b/src/modules/staking/staking.resolver.ts index ac85d5b41..caade7f31 100644 --- a/src/modules/staking/staking.resolver.ts +++ b/src/modules/staking/staking.resolver.ts @@ -1,12 +1,5 @@ import { UseGuards } from '@nestjs/common'; -import { - Args, - Int, - Parent, - Query, - ResolveField, - Resolver, -} from '@nestjs/graphql'; +import { Args, Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; import { AuthUser } from '../auth/auth.user'; import { UserAuthResult } from '../auth/user.auth.result'; import { TransactionModel } from 'src/models/transaction.model'; From 268d3295656ceaf153c6ba4ba7a5d766c134152f Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 17:28:46 +0300 Subject: [PATCH 04/11] SERVICES-1760: use mapped value for pair fee destinations Signed-off-by: Claudiu Lataretu --- src/modules/pair/services/pair.abi.service.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/pair/services/pair.abi.service.ts b/src/modules/pair/services/pair.abi.service.ts index 161ca934b..780fa1f88 100644 --- a/src/modules/pair/services/pair.abi.service.ts +++ b/src/modules/pair/services/pair.abi.service.ts @@ -581,12 +581,11 @@ export class PairAbiService [], ); const response = await this.getGenericData(interaction); - return response.firstValue.valueOf().map((v) => { + + return response.firstValue.valueOf().map((value) => { return new FeeDestination({ - address: new Address( - response.firstValue.valueOf()[0].field0, - ).bech32(), - tokenID: response.firstValue.valueOf()[0].field1.toString(), + address: new Address(value.field0).bech32(), + tokenID: value.field1.toString(), }); }); } From 30b3127b97e576052c074e8d52d815f22ea2738f Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 18:10:21 +0300 Subject: [PATCH 05/11] SERVICES-1760: remove dd-trace Signed-off-by: Claudiu Lataretu --- src/main.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index b973aaeb1..0237bccfe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,10 +29,6 @@ async function bootstrap() { const apiConfigService = app.get(ApiConfigService); const httpServer = httpAdapterHostService.httpAdapter.getHttpServer(); - if (apiConfigService.isTracerActive()) { - require('dd-trace').init(); - } - httpServer.keepAliveTimeout = apiConfigService.getKeepAliveTimeoutUpstream(); httpServer.headersTimeout = apiConfigService.getKeepAliveTimeoutUpstream(); //`keepAliveTimeout + server's expected response time` From 0aae317bb9ad096dcfd81ab866e5bcb3e50e7c79 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 18:13:01 +0300 Subject: [PATCH 06/11] SERVICES-1760: add linting workflow Signed-off-by: Claudiu Lataretu --- .github/workflows/lint.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..c2afa32b9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: ESLint + +on: + pull_request: + branches: [main, development, feat/**] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run lint From 97269fba5021d2eedc0d5b3f4695544459d2a63a Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 18:28:50 +0300 Subject: [PATCH 07/11] SERVICES-1760: remove admin validator from escrow Signed-off-by: Claudiu Lataretu --- src/modules/escrow/escrow.resolver.ts | 9 +++++++-- .../escrow/validators/admin.validator.ts | 20 ------------------- 2 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 src/modules/escrow/validators/admin.validator.ts diff --git a/src/modules/escrow/escrow.resolver.ts b/src/modules/escrow/escrow.resolver.ts index 305948607..904d96ba9 100644 --- a/src/modules/escrow/escrow.resolver.ts +++ b/src/modules/escrow/escrow.resolver.ts @@ -14,7 +14,6 @@ import { import { EscrowTransactionService } from './services/escrow.transaction.service'; import { SenderCooldownValidator } from './validators/sender.cooldown.validator'; import { TransferTokensValidator } from './validators/transfer.tokens.validator'; -import { EscrowAdminValidator } from './validators/admin.validator'; import { ForbiddenError } from 'apollo-server-express'; import { EscrowAbiService } from './services/escrow.abi.service'; @@ -141,8 +140,14 @@ export class EscrowResolver { async cancelEscrowTransfer( @Args('sender') sender: string, @Args('receiver') receiver: string, - @AuthUser(EscrowAdminValidator) user: UserAuthResult, + @AuthUser() user: UserAuthResult, ): Promise { + const permissions = await this.escrowAbi.addressPermission( + user.address, + ); + if (!permissions.includes(SCPermissions.ADMIN)) { + throw new ForbiddenError('User is not an admin'); + } return this.escrowTransaction.cancelTransfer(sender, receiver); } diff --git a/src/modules/escrow/validators/admin.validator.ts b/src/modules/escrow/validators/admin.validator.ts deleted file mode 100644 index 08f587a36..000000000 --- a/src/modules/escrow/validators/admin.validator.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Injectable, PipeTransform } from '@nestjs/common'; -import { ForbiddenError } from 'apollo-server-express'; -import { UserAuthResult } from 'src/modules/auth/user.auth.result'; -import { SCPermissions } from '../models/escrow.model'; -import { EscrowAbiService } from '../services/escrow.abi.service'; - -@Injectable() -export class EscrowAdminValidator implements PipeTransform { - constructor(private readonly escrowAbi: EscrowAbiService) {} - - async transform(value: UserAuthResult) { - const permissions = await this.escrowAbi.addressPermission( - value.address, - ); - if (!permissions.includes(SCPermissions.ADMIN)) { - throw new ForbiddenError('User is not an admin'); - } - return value; - } -} From 5b3e7bdb4139618830409706c572f2bccabad433 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 18:29:21 +0300 Subject: [PATCH 08/11] SERVICES-1760: move farm burn gas limit implementation to base module Signed-off-by: Claudiu Lataretu --- .../farm/base-module/services/farm.abi.service.ts | 12 +++++++++++- .../farm/v1.3/services/farm.v1.3.abi.service.ts | 8 -------- src/modules/farm/v2/services/farm.v2.abi.service.ts | 8 -------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/modules/farm/base-module/services/farm.abi.service.ts b/src/modules/farm/base-module/services/farm.abi.service.ts index 7ce0f32bd..b4039e217 100644 --- a/src/modules/farm/base-module/services/farm.abi.service.ts +++ b/src/modules/farm/base-module/services/farm.abi.service.ts @@ -14,6 +14,8 @@ import { CacheTtlInfo } from 'src/services/caching/cache.ttl.info'; import { oneHour } from 'src/helpers/helpers'; import { MXApiService } from 'src/services/multiversx-communication/mx.api.service'; import { IFarmAbiService } from './interfaces'; +import { farmVersion } from 'src/utils/farm.utils'; +import { FarmVersion } from '../../models/farm.model'; export class FarmAbiService extends GenericAbiService @@ -330,7 +332,15 @@ export class FarmAbiService } async getBurnGasLimitRaw(farmAddress: string): Promise { - return undefined; + if (farmVersion(farmAddress) === FarmVersion.V1_2) { + return undefined; + } + + const contract = await this.mxProxy.getFarmSmartContract(farmAddress); + const interaction: Interaction = + contract.methodsExplicit.getBurnGasLimit(); + const response = await this.getGenericData(interaction); + return response.firstValue.valueOf().toFixed(); } @ErrorLoggerAsync({ diff --git a/src/modules/farm/v1.3/services/farm.v1.3.abi.service.ts b/src/modules/farm/v1.3/services/farm.v1.3.abi.service.ts index 9aaed6892..fb3c5b2f2 100644 --- a/src/modules/farm/v1.3/services/farm.v1.3.abi.service.ts +++ b/src/modules/farm/v1.3/services/farm.v1.3.abi.service.ts @@ -89,12 +89,4 @@ export class FarmAbiServiceV1_3 return undefined; } } - - async getBurnGasLimitRaw(farmAddress: string): Promise { - const contract = await this.mxProxy.getFarmSmartContract(farmAddress); - const interaction: Interaction = - contract.methodsExplicit.getBurnGasLimit(); - const response = await this.getGenericData(interaction); - return response.firstValue.valueOf().toFixed(); - } } diff --git a/src/modules/farm/v2/services/farm.v2.abi.service.ts b/src/modules/farm/v2/services/farm.v2.abi.service.ts index ec0078082..a638f25bd 100644 --- a/src/modules/farm/v2/services/farm.v2.abi.service.ts +++ b/src/modules/farm/v2/services/farm.v2.abi.service.ts @@ -397,12 +397,4 @@ export class FarmAbiServiceV2 const response = await this.getGenericData(interaction); return response.firstValue.valueOf(); } - - async getBurnGasLimitRaw(farmAddress: string): Promise { - const contract = await this.mxProxy.getFarmSmartContract(farmAddress); - const interaction: Interaction = - contract.methodsExplicit.getBurnGasLimit(); - const response = await this.getGenericData(interaction); - return response.firstValue.valueOf().toFixed(); - } } From f65a7bc6b590d379768683704cda77d7e10980f5 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Mon, 21 Aug 2023 18:48:32 +0300 Subject: [PATCH 09/11] SERVICES-1760: add custom rule for eslint no-ununsed-var - add ignore patterns for underscored variables Signed-off-by: Claudiu Lataretu --- .eslintrc.js | 9 +++++++++ .../farm/base-module/services/farm.compute.service.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9e2240791..f1892f3a5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,5 +17,14 @@ module.exports = { }, rules: { "@typescript-eslint/no-explicit-any": ["off"], + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ], } }; diff --git a/src/modules/farm/base-module/services/farm.compute.service.ts b/src/modules/farm/base-module/services/farm.compute.service.ts index 775e5d4d3..b8caa2d95 100644 --- a/src/modules/farm/base-module/services/farm.compute.service.ts +++ b/src/modules/farm/base-module/services/farm.compute.service.ts @@ -38,7 +38,7 @@ export abstract class FarmComputeService implements IFarmComputeService { return await this.computeFarmLockedValueUSD(farmAddress); } - async computeFarmLockedValueUSD(farmAddress: string): Promise { + async computeFarmLockedValueUSD(_farmAddress: string): Promise { return '0'; } From 058985e093009f396b915a88c56d62853203a399 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Tue, 22 Aug 2023 11:27:05 +0300 Subject: [PATCH 10/11] SERVICES-1760: remove commented code Signed-off-by: Claudiu Lataretu --- src/modules/auto-router/services/auto-router.service.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/auto-router/services/auto-router.service.ts b/src/modules/auto-router/services/auto-router.service.ts index a36cf0b06..2f972c9a6 100644 --- a/src/modules/auto-router/services/auto-router.service.ts +++ b/src/modules/auto-router/services/auto-router.service.ts @@ -148,10 +148,6 @@ export class AutoRouterService { this.pairCompute.tokenPriceUSD(tokenOutID), ]); - // let [amountIn, amountOut] = this.isFixedInput(swapType) - // ? [args.amountIn, result] - // : [result, args.amountOut]; - let amountIn: string; let amountOut: string; if (this.isFixedInput(swapType)) { From fedc6c638f442afcd031a3fbb0d9d6bb069c71c1 Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Tue, 22 Aug 2023 11:31:32 +0300 Subject: [PATCH 11/11] SERVICES-1760: fix linting errors Signed-off-by: Claudiu Lataretu --- src/modules/governance/services/governance.compute.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/governance/services/governance.compute.service.ts b/src/modules/governance/services/governance.compute.service.ts index e9e517bf6..0e29b8c6c 100644 --- a/src/modules/governance/services/governance.compute.service.ts +++ b/src/modules/governance/services/governance.compute.service.ts @@ -48,7 +48,7 @@ export class GovernanceComputeService { remoteTtl: CacheTtlInfo.ContractState.remoteTtl, localTtl: CacheTtlInfo.ContractState.localTtl, }) - async userVoteTypesForContract(scAddress: string, userAddress: string): Promise<{ proposalId: number, vote: VoteType }[]> { + async userVoteTypesForContract(_scAddress: string, _userAddress: string): Promise<{ proposalId: number, vote: VoteType }[]> { return []; }