From c7098aa572a444eefdac3e621805048b342e6813 Mon Sep 17 00:00:00 2001 From: Y0moo Date: Fri, 29 Oct 2021 20:02:51 +0200 Subject: [PATCH] feat: absolite import added --- jsconfig.json | 3 +++ src/App.jsx | 33 ++++++++++++++----------- src/components/Chains/Chains.jsx | 6 ----- src/components/InchDex/hooks/useInch.js | 6 +++-- src/components/TokenPrice.jsx | 6 ++--- src/hooks/useERC20Balance.js | 2 +- src/hooks/useERC20Transfers.js | 2 +- src/hooks/useNFTBalance.js | 2 +- 8 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..eebe37627 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,3 @@ +{ + "compilerOptions": { "baseUrl": "src" } +} diff --git a/src/App.jsx b/src/App.jsx index 334c6ffef..eeaf2e017 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,16 +1,16 @@ -import React from "react"; +import React, { useEffect } from "react"; import { useMoralis } from "react-moralis"; import { BrowserRouter as Router, Switch, Route, NavLink, Redirect } from "react-router-dom"; -import Account from "./components/Account"; -import Chains from "./components/Chains"; -import TokenPrice from "./components/TokenPrice"; -import Contract from "./components/Contract/Contract"; -import ERC20Balance from "./components/ERC20Balance"; -import ERC20Transfers from "./components/ERC20Transfers"; -import InchDex from "./components/InchDex"; -import NFTBalance from "./components/NFTBalance"; -import Wallet from "./components/Wallet"; -import { Flex } from "./uikit/Flex/Flex"; +import Account from "components/Account"; +import Chains from "components/Chains"; +import TokenPrice from "components/TokenPrice"; +import Contract from "components/Contract/Contract"; +import ERC20Balance from "components/ERC20Balance"; +import ERC20Transfers from "components/ERC20Transfers"; +import InchDex from "components/InchDex"; +import NFTBalance from "components/NFTBalance"; +import Wallet from "components/Wallet"; +import { Flex } from "uikit/Flex/Flex"; const styles = { content: { @@ -44,8 +44,13 @@ const styles = { }, }; const App = () => { - const { isAuthenticated, isInitialized } = useMoralis(); - console.log("isInitialized: ", isInitialized); + const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading } = useMoralis(); + + useEffect(() => { + if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading) enableWeb3(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isAuthenticated, isWeb3Enabled]); + return ( { margin="15px 0" padding="0 20px" > - +
Wallet diff --git a/src/components/Chains/Chains.jsx b/src/components/Chains/Chains.jsx index 21dc9992b..4d602e579 100644 --- a/src/components/Chains/Chains.jsx +++ b/src/components/Chains/Chains.jsx @@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react"; import useChain from "../../hooks/useChain"; import { Avalanche, Polygon, Binance, Ethereum } from "./components"; import { useMoralisDapp } from "../../providers/MoralisDappProvider/MoralisDappProvider"; -import { useMoralis } from "react-moralis"; /** TO DO * Use only one chain component with providing img links and chain names @@ -11,13 +10,8 @@ import { useMoralis } from "react-moralis"; function Chains(props) { const { switchNetwork } = useChain(); const { chainId: chain } = useMoralisDapp(); - const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading } = useMoralis(); const [chainId, setChainId] = useState(); - useEffect(() => { - if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading) enableWeb3(); - }, [isAuthenticated, isWeb3Enabled]); - useEffect(() => setChainId(chain), [chain]); console.log(chain); diff --git a/src/components/InchDex/hooks/useInch.js b/src/components/InchDex/hooks/useInch.js index 9b3489564..6f3e7faf6 100644 --- a/src/components/InchDex/hooks/useInch.js +++ b/src/components/InchDex/hooks/useInch.js @@ -1,6 +1,6 @@ import { useState } from "react"; import { useMoralis } from "react-moralis"; -import { useMoralisDapp } from "../../../providers/MoralisDappProvider/MoralisDappProvider"; +import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider"; const useInch = () => { const { Moralis } = useMoralis(); @@ -9,7 +9,9 @@ const useInch = () => { const [tokenList, setTokenlist] = useState(); const getSupportedTokens = async (chain) => - await Moralis.Plugins.oneInch.getSupportedTokens({ chain }).then((tokens) => setTokenlist(tokens.tokens)); + await Moralis.Plugins.oneInch + .getSupportedTokens({ chain }) + .then((tokens) => setTokenlist(tokens.tokens)); const getQuote = async (params) => await Moralis.Plugins.oneInch.quote({ diff --git a/src/components/TokenPrice.jsx b/src/components/TokenPrice.jsx index 4912980a3..ae5ce12c2 100644 --- a/src/components/TokenPrice.jsx +++ b/src/components/TokenPrice.jsx @@ -1,5 +1,5 @@ -import React, {useState} from "react"; -import useTokenPrice from "../hooks/useTokenPrice"; +import React, { useState } from "react"; +import useTokenPrice from "hooks/useTokenPrice"; const styles = { token: { @@ -25,7 +25,7 @@ function TokenPrice(props) { const noLogoToken = "https://etherscan.io/images/main/empty-token.png"; - return ( + return (
logo { const { account } = useMoralisWeb3Api(); const { isInitialized } = useMoralis(); diff --git a/src/hooks/useERC20Transfers.js b/src/hooks/useERC20Transfers.js index bc9abe03d..2cc7a1d20 100644 --- a/src/hooks/useERC20Transfers.js +++ b/src/hooks/useERC20Transfers.js @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { useMoralis, useMoralisWeb3Api } from "react-moralis"; -import { useMoralisDapp } from "../providers/MoralisDappProvider/MoralisDappProvider"; +import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider"; const useERC20Transfers = () => { const { account } = useMoralisWeb3Api(); diff --git a/src/hooks/useNFTBalance.js b/src/hooks/useNFTBalance.js index a2d7c0daf..124e3d942 100644 --- a/src/hooks/useNFTBalance.js +++ b/src/hooks/useNFTBalance.js @@ -1,5 +1,5 @@ import { useMoralisWeb3Api } from "react-moralis"; -import { useMoralisDapp } from "../providers/MoralisDappProvider/MoralisDappProvider"; +import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider"; const useNFTBalance = () => { const { account } = useMoralisWeb3Api();