diff --git a/frontend/.eslintignore b/frontend/.eslintignore new file mode 100644 index 0000000..1290c15 --- /dev/null +++ b/frontend/.eslintignore @@ -0,0 +1,2 @@ +src/abi +src/generated diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js new file mode 100644 index 0000000..83bcfb2 --- /dev/null +++ b/frontend/.eslintrc.js @@ -0,0 +1,16 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking' + ], + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, + }; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 643fd3d..26887d9 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -20,13 +20,16 @@ "react-scripts": "5.0.0", "sass": "^1.49.10", "tslint": "^6.1.3", - "typescript": "^4.6.2", "web-vitals": "^2.1.4" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.21.0", + "@typescript-eslint/parser": "^5.21.0", + "eslint": "^8.14.0", "ethereum-abi-types-generator": "^1.3.2", "ethers": "^5.6.2", - "prettier": "2.6.1" + "prettier": "2.6.1", + "typescript": "^4.6.3" } }, "node_modules/@ampproject/remapping": { @@ -1983,9 +1986,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.2.tgz", + "integrity": "sha512-lTVWHs7O2hjBFZunXTZYnYqtB9GakA1lnxIf+gKq2nY5gxkkNi/lQvveW6t8gFdOHTg6nG50Xs95PrLqVpcaLg==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -4447,13 +4450,13 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.15.0.tgz", - "integrity": "sha512-u6Db5JfF0Esn3tiAKELvoU5TpXVSkOpZ78cEGn/wXtT2RVqs2vkt4ge6N8cRCyw7YVKhmmLDbwI2pg92mlv7cA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", + "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", "dependencies": { - "@typescript-eslint/scope-manager": "5.15.0", - "@typescript-eslint/type-utils": "5.15.0", - "@typescript-eslint/utils": "5.15.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/type-utils": "5.21.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -4478,6 +4481,119 @@ } } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/@typescript-eslint/experimental-utils": { "version": "5.15.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.15.0.tgz", @@ -4497,13 +4613,13 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.15.0.tgz", - "integrity": "sha512-NGAYP/+RDM2sVfmKiKOCgJYPstAO40vPAgACoWPO/+yoYKSgAXIFaBKsV8P0Cc7fwKgvj27SjRNX4L7f4/jCKQ==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", + "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", "dependencies": { - "@typescript-eslint/scope-manager": "5.15.0", - "@typescript-eslint/types": "5.15.0", - "@typescript-eslint/typescript-estree": "5.15.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", "debug": "^4.3.2" }, "engines": { @@ -4522,6 +4638,76 @@ } } }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/scope-manager": { "version": "5.15.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.15.0.tgz", @@ -4539,11 +4725,11 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.15.0.tgz", - "integrity": "sha512-KGeDoEQ7gHieLydujGEFLyLofipe9PIzfvA/41urz4hv+xVxPEbmMQonKSynZ0Ks2xDhJQ4VYjB3DnRiywvKDA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", + "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", "dependencies": { - "@typescript-eslint/utils": "5.15.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "tsutils": "^3.21.0" }, @@ -4563,6 +4749,119 @@ } } }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "dependencies": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/@typescript-eslint/types": { "version": "5.15.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.15.0.tgz", @@ -7352,11 +7651,11 @@ } }, "node_modules/eslint": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", - "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.14.0.tgz", + "integrity": "sha512-3/CE4aJX7LNEiE3i6FeodHmI/38GZtWCsAtsymScmzYapx8q1nVVb+eLcLSzATmCPXw5pT4TqVs1E0OmxAd9tw==", "dependencies": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.2", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -16342,9 +16641,9 @@ } }, "node_modules/typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -18786,9 +19085,9 @@ } }, "@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.2.tgz", + "integrity": "sha512-lTVWHs7O2hjBFZunXTZYnYqtB9GakA1lnxIf+gKq2nY5gxkkNi/lQvveW6t8gFdOHTg6nG50Xs95PrLqVpcaLg==", "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -20515,19 +20814,85 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" }, "@typescript-eslint/eslint-plugin": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.15.0.tgz", - "integrity": "sha512-u6Db5JfF0Esn3tiAKELvoU5TpXVSkOpZ78cEGn/wXtT2RVqs2vkt4ge6N8cRCyw7YVKhmmLDbwI2pg92mlv7cA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.21.0.tgz", + "integrity": "sha512-fTU85q8v5ZLpoZEyn/u1S2qrFOhi33Edo2CZ0+q1gDaWWm0JuPh3bgOyU8lM0edIEYgKLDkPFiZX2MOupgjlyg==", "requires": { - "@typescript-eslint/scope-manager": "5.15.0", - "@typescript-eslint/type-utils": "5.15.0", - "@typescript-eslint/utils": "5.15.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/type-utils": "5.21.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", "regexpp": "^3.2.0", "semver": "^7.3.5", "tsutils": "^3.21.0" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==" + }, + "@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + } } }, "@typescript-eslint/experimental-utils": { @@ -20539,14 +20904,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.15.0.tgz", - "integrity": "sha512-NGAYP/+RDM2sVfmKiKOCgJYPstAO40vPAgACoWPO/+yoYKSgAXIFaBKsV8P0Cc7fwKgvj27SjRNX4L7f4/jCKQ==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.21.0.tgz", + "integrity": "sha512-8RUwTO77hstXUr3pZoWZbRQUxXcSXafZ8/5gpnQCfXvgmP9gpNlRGlWzvfbEQ14TLjmtU8eGnONkff8U2ui2Eg==", "requires": { - "@typescript-eslint/scope-manager": "5.15.0", - "@typescript-eslint/types": "5.15.0", - "@typescript-eslint/typescript-estree": "5.15.0", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", "debug": "^4.3.2" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==" + }, + "@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + } + } } }, "@typescript-eslint/scope-manager": { @@ -20559,13 +20963,79 @@ } }, "@typescript-eslint/type-utils": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.15.0.tgz", - "integrity": "sha512-KGeDoEQ7gHieLydujGEFLyLofipe9PIzfvA/41urz4hv+xVxPEbmMQonKSynZ0Ks2xDhJQ4VYjB3DnRiywvKDA==", + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz", + "integrity": "sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==", "requires": { - "@typescript-eslint/utils": "5.15.0", + "@typescript-eslint/utils": "5.21.0", "debug": "^4.3.2", "tsutils": "^3.21.0" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.21.0.tgz", + "integrity": "sha512-XTX0g0IhvzcH/e3393SvjRCfYQxgxtYzL3UREteUneo72EFlt7UNoiYnikUtmGVobTbhUDByhJ4xRBNe+34kOQ==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.21.0.tgz", + "integrity": "sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==" + }, + "@typescript-eslint/typescript-estree": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz", + "integrity": "sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/visitor-keys": "5.21.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/utils": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.21.0.tgz", + "integrity": "sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==", + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.21.0", + "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/typescript-estree": "5.21.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz", + "integrity": "sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==", + "requires": { + "@typescript-eslint/types": "5.21.0", + "eslint-visitor-keys": "^3.0.0" + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + } } }, "@typescript-eslint/types": { @@ -22649,11 +23119,11 @@ } }, "eslint": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", - "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.14.0.tgz", + "integrity": "sha512-3/CE4aJX7LNEiE3i6FeodHmI/38GZtWCsAtsymScmzYapx8q1nVVb+eLcLSzATmCPXw5pT4TqVs1E0OmxAd9tw==", "requires": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.2.2", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -29064,9 +29534,9 @@ } }, "typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==" + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==" }, "unbox-primitive": { "version": "1.0.1", diff --git a/frontend/package.json b/frontend/package.json index 4d204f6..e2a5801 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,7 +15,6 @@ "react-scripts": "5.0.0", "sass": "^1.49.10", "tslint": "^6.1.3", - "typescript": "^4.6.2", "web-vitals": "^2.1.4" }, "scripts": { @@ -45,8 +44,12 @@ ] }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.21.0", + "@typescript-eslint/parser": "^5.21.0", + "eslint": "^8.14.0", "ethereum-abi-types-generator": "^1.3.2", "ethers": "^5.6.2", - "prettier": "2.6.1" + "prettier": "2.6.1", + "typescript": "^4.6.3" } } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a50a3e6..0aa1301 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,7 +7,7 @@ import Invest from "./components/Invest"; import poolAbi from "./abi/Pool.json"; import cauldronAbi from "./abi/Cauldron.json"; import ladleAbi from "./abi/Ladle.json"; -import { emptyVaults, Vaults } from "./objects/Vault"; +import { Balances, emptyVaults, Vaults, VaultsAndBalances } from "./objects/Vault"; import VaultComponent from "./components/Vault"; import { Tabs } from "./components/Tabs"; import { ContractContext as ERC20 } from "./abi/ERC20"; @@ -17,23 +17,26 @@ import { ContractContext as Cauldron } from "./abi/Cauldron"; import { ContractContext as Ladle } from "./abi/Ladle"; import yieldLeverAbi from "./generated/abi/YieldLever.json"; import yieldLeverDeployed from "./generated/deployment.json"; +import { ExternalProvider } from "@ethersproject/providers"; const YIELD_LEVER_CONTRACT_ADDRESS: string = yieldLeverDeployed.deployedTo; -const USDC_ADDRESS: string = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; -const POOL_CONTRACT: string = "0xEf82611C6120185D3BF6e020D1993B49471E7da0"; -const CAULDRON_CONTRACT: string = "0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867"; -const LADLE_CONTRACT: string = "0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A"; +const USDC_ADDRESS = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; +const POOL_CONTRACT = "0xEf82611C6120185D3BF6e020D1993B49471E7da0"; +const CAULDRON_CONTRACT = "0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867"; +const LADLE_CONTRACT = "0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A"; -const YEARN_STRATEGY: string = '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE'; +const YEARN_STRATEGY = '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE'; -export const SERIES_ID: string = "0x303230360000"; -export const ILK_ID: string = "0x303900000000"; +export const SERIES_ID = "0x303230360000"; +export const ILK_ID = "0x303900000000"; + +type YearnApiJson = { address: string, apy: { net_apy: number } }[]; interface State { selectedAddress?: string; networkError?: string; usdcBalance?: BigNumber; - vaults: Vaults; + vaults: VaultsAndBalances; yearn_apy?: number; } @@ -45,7 +48,7 @@ export interface Contracts { ladleContract: Ladle; } -export class App extends React.Component<{}, State> { +export class App extends React.Component, State> { private readonly initialState: State; private _provider?: ethers.providers.Web3Provider; @@ -56,7 +59,7 @@ export class App extends React.Component<{}, State> { private vaultsToMonitor: string[] = []; - constructor(properties: {}) { + constructor(properties: Record) { super(properties); this.initialState = { selectedAddress: undefined, @@ -83,9 +86,9 @@ export class App extends React.Component<{}, State> { if (!this.state.selectedAddress) { return ( this._connectWallet()} + connectWallet={() => void this.connectWallet()} networkError={this.state.networkError} - dismiss={() => this._dismissNetworkError()} + dismiss={() => this.dismissNetworkError()} /> ); } @@ -122,48 +125,53 @@ export class App extends React.Component<{}, State> { return {elements}; } + dismissNetworkError(): void { + throw new Error("Method not implemented."); + } - async _connectWallet() { + private async connectWallet() { // This method is run when the user clicks the Connect. It connects the // dapp to the user's wallet, and initializes it. // To connect to the user's wallet, we have to run this method. // It returns a promise that will resolve to the user's address. - const [selectedAddress] = await window.ethereum.request({ + const [selectedAddress] = await (window.ethereum as { request(arg: {method: string}): Promise<[string]>}).request({ method: "eth_requestAccounts", }); // Once we have the address, we can initialize the application. // First we check the network - if (!this._checkNetwork()) { + if (!this.checkNetwork()) { return; } - this._initialize(selectedAddress); + this.initialize(selectedAddress); // We reinitialize it whenever the user changes their account. - window.ethereum.on("accountsChanged", ([newAddress]: [string]) => { - this._stopPollingData(); + (window.ethereum as { on(method: string, callback: (a: any) => void): void } + ).on("accountsChanged", ([newAddress]: [string]) => { + this.stopPollingData(); // `accountsChanged` event can be triggered with an undefined newAddress. // This happens when the user removes the Dapp from the "Connected // list of sites allowed access to your addresses" (Metamask > Settings > Connections) // To avoid errors, we reset the dapp state if (newAddress === undefined) { - return this._resetState(); + return this.resetState(); } - this._initialize(newAddress); + this.initialize(newAddress); }); // We reset the dapp state if the network is changed - window.ethereum.on("chainChanged", ([networkId]: [string]) => { - this._stopPollingData(); - this._resetState(); + (window.ethereum as { on(method: string, callback: (a: any) => void): void } + ).on("chainChanged", ([_networkId]: [string]) => { + this.stopPollingData(); + this.resetState(); }); } - _initialize(userAddress: string) { + private initialize(userAddress: string) { // This method initializes the dapp // We first store the user's address in the component's state @@ -176,39 +184,39 @@ export class App extends React.Component<{}, State> { // Fetching the token data and the user's balance are specific to this // sample project, but you can reuse the same initialization pattern. - this._initializeEthers(); - this._startPollingData(); + void this.initializeEthers(); + void this.startPollingData(); } - async _initializeEthers() { + private initializeEthers() { // We first initialize ethers by creating a provider using window.ethereum - this._provider = new ethers.providers.Web3Provider(window.ethereum); + this._provider = new ethers.providers.Web3Provider(window.ethereum as any as ExternalProvider, "any"); this.contracts = { usdcContract: new ethers.Contract( USDC_ADDRESS, erc20Abi, this._provider.getSigner(0) - ) as any, + ) as any as ERC20, yieldLeverContract: new ethers.Contract( YIELD_LEVER_CONTRACT_ADDRESS, yieldLeverAbi.abi, this._provider.getSigner(0) - ) as any, + ) as any as YieldLever, poolContract: new ethers.Contract( POOL_CONTRACT, poolAbi, this._provider.getSigner(0) - ) as any, + ) as any as Pool, cauldronContract: new ethers.Contract( CAULDRON_CONTRACT, cauldronAbi, this._provider - ) as any, + ) as any as Cauldron, ladleContract: new ethers.Contract( LADLE_CONTRACT, ladleAbi, this._provider - ) as any, + ) as any as Ladle, }; // if (this.state.selectedAddress !== undefined) @@ -226,19 +234,19 @@ export class App extends React.Component<{}, State> { this.state.selectedAddress ); this.contracts.cauldronContract.on(vaultsBuiltFilter, (vaultId: string) => - this.addVault(vaultId) + void this.addVault(vaultId) ); this.contracts.cauldronContract.on( vaultsReceivedFilter, - (vaultId: string) => this.addVault(vaultId) + (vaultId: string) => void this.addVault(vaultId) ); - await this._startPollingData(); + this.startPollingData(); } // This is an utility method that turns an RPC error into a human readable // message. - _getRpcErrorMessage(error: { data?: { message: string }; message: string }) { + getRpcErrorMessage(error: { data?: { message: string }; message: string }) { if (error.data) { return error.data.message; } @@ -247,19 +255,17 @@ export class App extends React.Component<{}, State> { } // This method resets the state - _resetState() { + resetState() { this.setState(this.initialState); } - _checkNetwork() { + checkNetwork() { // TODO: Really check network return true; } - _dismissNetworkError() {} - - private async _startPollingData() { - this.pollId = setInterval(() => this.pollData(), 1000) as any; + private startPollingData() { + this.pollId = setInterval(() => void this.pollData(), 1000) as any as number; } private async pollData() { @@ -278,8 +284,8 @@ export class App extends React.Component<{}, State> { ]) ), ]); - const vaults = Object.create(null); - const balances = Object.create(null); + const vaults = Object.create(null) as Vaults; + const balances = Object.create(null) as Balances; this.vaultsToMonitor.forEach((vaultId, i) => { if (vaultAndBalances[i] !== undefined) { vaults[vaultId] = vaultAndBalances[i][0]; @@ -288,9 +294,9 @@ export class App extends React.Component<{}, State> { }); const yearnResponse = await fetch('https://api.yearn.finance/v1/chains/1/vaults/all'); - const yearnStrategies: any[] = await yearnResponse.json(); + const yearnStrategies = await yearnResponse.json() as YearnApiJson; const strategy = yearnStrategies.find((strat) => strat.address === YEARN_STRATEGY); - const yearn_apy = strategy.apy.net_apy as number; + const yearn_apy = strategy?.apy.net_apy; this.setState({ usdcBalance, @@ -303,7 +309,7 @@ export class App extends React.Component<{}, State> { } } - private _stopPollingData() { + private stopPollingData() { clearInterval(this.pollId); } diff --git a/frontend/src/components/Invest.tsx b/frontend/src/components/Invest.tsx index 759870f..f49e1c0 100644 --- a/frontend/src/components/Invest.tsx +++ b/frontend/src/components/Invest.tsx @@ -11,8 +11,8 @@ import { ContractContext as Cauldron, } from "../abi/Cauldron"; -const UNITS_USDC: number = 6; -const UNITS_LEVERAGE: number = 2; +const UNITS_USDC = 6; +const UNITS_LEVERAGE = 2; interface Properties { usdcBalance: BigNumber; @@ -79,7 +79,7 @@ export default class Invest extends React.Component { className="button" type="button" value="Approve" - onClick={() => this.approve()} + onClick={() => void this.approve()} /> ); break; @@ -90,7 +90,7 @@ export default class Invest extends React.Component { className="button" type="button" value="Transact!" - onClick={() => this.transact()} + onClick={() => void this.transact()} /> ); break; @@ -174,14 +174,14 @@ export default class Invest extends React.Component { {this.state.interest !== undefined ? ( ) : null} {this.props.yearnApi !== undefined ? ( ) : null} @@ -190,23 +190,23 @@ export default class Invest extends React.Component { ); } - private async onSlippageChange(slippage: number) { + private onSlippageChange(slippage: number) { this.setState({ slippage }); - await this.checkApprovalState(); + void this.checkApprovalState(); } private onUsdcInputChange(usdcToInvest: BigNumber) { this.setState({ usdcToInvest, approvalState: ApprovalState.Loading }); - this.checkApprovalState(); + void this.checkApprovalState(); } - private async onLeverageChange(leverage: string) { - this.setState({ leverage: utils.parseUnits(leverage, UNITS_LEVERAGE) }); - await this.checkApprovalState(); + private onLeverageChange(leverage: string) { + this.setState({ leverage: utils.parseUnits(leverage, UNITS_LEVERAGE), approvalState: ApprovalState.Loading }); + void this.checkApprovalState(); } public componentDidMount() { - this.checkApprovalState(); + void this.checkApprovalState(); } private totalToInvest(): BigNumber { @@ -337,7 +337,7 @@ export default class Invest extends React.Component { if (this.series === undefined) this.series = this.contracts.cauldronContract.series( SERIES_ID - ) as Promise; + ) ; return this.series; } diff --git a/frontend/src/components/ValueDisplay.tsx b/frontend/src/components/ValueDisplay.tsx index a159faf..44ed081 100644 --- a/frontend/src/components/ValueDisplay.tsx +++ b/frontend/src/components/ValueDisplay.tsx @@ -38,7 +38,7 @@ export default function ValueDisplay(value: Value): JSX.Element { val = value.value; } return ( -
+

{value.label}

{val}

diff --git a/frontend/src/components/Vault.tsx b/frontend/src/components/Vault.tsx index 6ff768b..7e3cb01 100644 --- a/frontend/src/components/Vault.tsx +++ b/frontend/src/components/Vault.tsx @@ -64,19 +64,19 @@ export default class Vault extends React.Component { className="button" value="Unwind" type="button" - onClick={() => this.unwind()} + onClick={() => void this.unwind()} />
); } componentDidMount() { - this.updateToBorrow(); + void this.updateToBorrow(); } - private async onSlippageChange(slippage: number) { + private onSlippageChange(slippage: number) { this.setState({ slippage, toBorrow: undefined }); - await this.updateToBorrow(); + void this.updateToBorrow(); } private async updateToBorrow() { @@ -89,7 +89,7 @@ export default class Vault extends React.Component { ); if (balance.art.eq(0)) return BigNumber.from(0); try { - console.log('Expected FY:\t' + + utils.formatUnits(await this.props.contracts.poolContract.buyFYTokenPreview(balance.art), 6) + " USDC"); + console.log(`Expected FY:\t${utils.formatUnits(await this.props.contracts.poolContract.buyFYTokenPreview(balance.art), 6)} USDC`); return addSlippage( await this.props.contracts.poolContract.buyFYTokenPreview(balance.art), this.state.slippage ); @@ -115,7 +115,7 @@ export default class Vault extends React.Component { await this.updateToBorrow(); } const maxFy = this.state.toBorrow; - console.log("Base required:\t" + utils.formatUnits(maxFy, 6) + " USDC"); + console.log(`Base required:\t${utils.formatUnits(maxFy, 6)} USDC`); console.log(this.props.vaultId, maxFy, poolAddress, diff --git a/frontend/src/objects/Vault.tsx b/frontend/src/objects/Vault.tsx index 649913c..6e984f9 100644 --- a/frontend/src/objects/Vault.tsx +++ b/frontend/src/objects/Vault.tsx @@ -12,12 +12,20 @@ export interface Balance { } export interface Vaults { - vaults: { [vaultId: string]: Vault }; - balances: { [vaultId: string]: Balance }; + [vaultId: string]: Vault } -const CAULDRON_CREATED_BLOCK_NUMBER: number = 13461506; -const BLOCK_STEPS: number = 10; +export interface Balances { + [vaultId: string]: Balance +} + +export interface VaultsAndBalances { + vaults: Vaults; + balances: Balances; +} + +const CAULDRON_CREATED_BLOCK_NUMBER = 13461506; +const BLOCK_STEPS = 10; export async function loadVaults( cauldron: Contract, @@ -46,9 +54,9 @@ export async function loadVaults( } } -export function emptyVaults(): Vaults { +export function emptyVaults(): VaultsAndBalances { return { - vaults: Object.create(null), - balances: Object.create(null), + vaults: Object.create(null) as Vaults, + balances: Object.create(null) as Balances, }; }