From b2b65227fcfec3692e8a0f385d4b1e045ba895f8 Mon Sep 17 00:00:00 2001 From: Christopher Cali Date: Wed, 8 Nov 2023 11:12:35 -0500 Subject: [PATCH 1/6] Remove unnecessary chain related code in ethers composable --- apps/web/src/composables/ethers.ts | 85 ------------------------------ 1 file changed, 85 deletions(-) diff --git a/apps/web/src/composables/ethers.ts b/apps/web/src/composables/ethers.ts index 6067ad11d..5098aa588 100644 --- a/apps/web/src/composables/ethers.ts +++ b/apps/web/src/composables/ethers.ts @@ -166,16 +166,6 @@ export default function useEthers() { return parseFloat(ethers.utils.formatEther(balance)) } - async function getEthersBrowserProviderSelectedCurrency(providerString: ProviderString) { - // IOTEX Smart Contract Address: 0x6fb3e0a217407efff7ca062d46c26e5d60a14d69 - const browserProvider = getBrowserProvider(providerString) - const web3Provider: ethers.providers.Web3Provider = new ethers.providers.Web3Provider(browserProvider as EthersProvider) - const network = await web3Provider.getNetwork() - // console.log('network.chainId :>> ', network.chainId) - const { currency } = currenciesByChainId[network.chainId.toString() as keyof typeof currenciesByChainId] - return currency - } - function getEthersBrowserSigner(providerString: ProviderString): ethers.Signer | undefined { const provider = getBrowserProvider(providerString) if (provider) { @@ -288,79 +278,4 @@ function getTrustWallet() { } else { window.open("https://trustwallet.com/download", "_blank") } -} - -const currenciesByChainId = { - "1": { - name: "Mainnet ETH", - currency: "ETH", - }, - "3": { - name: "Ropsten ETH", - currency: "ETH", - }, - "4": { - name: "Rinkeby ETH", - currency: "ETH", - }, - "5": { - name: "Goerli ETH", - currency: "ETH", - }, - "42": { - name: "Kovan ETH", - currency: "ETH", - }, - "56": { - name: "Binance Smart Chain", - currency: "BNB", - }, - "97": { - name: "Binance Smart Chain Testnet", - currency: "BNB", - }, - "137": { - name: "Polygon", - currency: "MATIC", - }, - "31337": { - name: "Localhost Network", - currency: "ETH", - }, - "80001": { - name: "Polygon Testnet", - currency: "MATIC", - }, - "4690": { - name: "IoTeX", - currency: "IOTX", - }, - "4691": { - name: "IoTeX Testnet", - currency: "IOTX", - }, -} - -const iotexNetwork = { - chainId: ethers.utils.hexlify(4690), - chainName: "IoTeX", - nativeCurrency: { - name: "IoTeX", - symbol: "IOTX", - decimals: 18 - }, - rpcUrls: ["https://api.testnet.iotex.one:80", "http://api.testnet.iotex.one:80"], - blockExplorerUrls: ["https://iotexscan.io"] -} - -const goerliNetwork = { - chainId: "0x5", - chainName: "Goerli Testnet", - nativeCurrency: { - name: "Goerli", - symbol: "GĂ–ETH", - decimals: 18 - }, - rpcUrls: ["https://goerli.infura.io/v3/6b9f3a5d3d5e4c8e9b5d1f0c3e5f1e4a"], - blockExplorerUrls: ["https://goerli.etherscan.io"] } \ No newline at end of file From 42249ef2ec701a33d92b166a10c9d825ff8c51db Mon Sep 17 00:00:00 2001 From: Christopher Cali Date: Tue, 14 Nov 2023 10:08:03 -0500 Subject: [PATCH 2/6] Reduce number of node requests via provider options + composable refactors --- .vscode/settings.json | 10 +- apps/web/.eslintrc | 12 +- apps/web/src/App.vue | 21 ++ .../web/src/components/ConnectWalletsFlow.vue | 12 +- apps/web/src/composables/auth.ts | 21 +- apps/web/src/composables/breakdownMetrics.ts | 250 +++++++-------- apps/web/src/composables/contracts.ts | 68 ++-- apps/web/src/composables/environment.ts | 7 +- apps/web/src/composables/ethers.ts | 132 +------- apps/web/src/composables/format.ts | 55 ++-- apps/web/src/composables/operators.ts | 59 ++-- apps/web/src/composables/staking.ts | 91 +++--- apps/web/src/composables/user.ts | 65 ++-- apps/web/src/composables/walletConnectV2.ts | 2 +- apps/web/src/main.ts | 13 +- apps/web/src/pages/operators/Operator.vue | 55 ++-- .../overview/components/BreakdownChart.vue | 28 +- .../src/pages/overview/components/Staking.vue | 292 +++++++++--------- common/env/src/index.ts | 5 + package-lock.json | 33 +- scripts/cdk/deploy.ts | 4 +- scripts/root/dev.ts | 4 +- 22 files changed, 618 insertions(+), 621 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 960b64ffb..025d86f9c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,12 @@ { + "css.lint.unknownAtRules": "ignore", "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, + "eslint.validate": [ + "vue", + "typescript" + ], "[html]": { "editor.defaultFormatter": "Vue.volar" }, @@ -14,10 +19,5 @@ "[json]": { "editor.defaultFormatter": "vscode.json-language-features" }, - "eslint.validate": [ - "vue", - "typescript" - ], - "css.lint.unknownAtRules": "ignore", "volar.inlayHints.eventArgumentInInlineHandlers": false } \ No newline at end of file diff --git a/apps/web/.eslintrc b/apps/web/.eslintrc index 9009c65f6..2b7a8f6c2 100644 --- a/apps/web/.eslintrc +++ b/apps/web/.eslintrc @@ -21,8 +21,16 @@ "@typescript-eslint" ], "rules": { - "max-len": ["error", { "code": 200, "ignoreStrings": true, "comments":300, "ignoreTemplateLiterals": true }], - "vue/multi-word-component-names": "off", + "max-len": [ + "error", + { + "code": 200, + "ignoreStrings": true, + "comments": 300, + "ignoreTemplateLiterals": true + } + ], + "vue/multi-word-component-names": "off" }, "ignorePatterns": [ "**/node_modules/**", diff --git a/apps/web/src/App.vue b/apps/web/src/App.vue index 5ea62b95d..b318984b7 100644 --- a/apps/web/src/App.vue +++ b/apps/web/src/App.vue @@ -1,6 +1,27 @@