Skip to content

Commit

Permalink
feat: absolite import added
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0moo committed Oct 29, 2021
1 parent 8e4e3ba commit c7098aa
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
3 changes: 3 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"compilerOptions": { "baseUrl": "src" }
}
33 changes: 19 additions & 14 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -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 (
<Router>
<Flex
Expand All @@ -55,7 +60,7 @@ const App = () => {
margin="15px 0"
padding="0 20px"
>
<Logo />
<Logo />
<div style={styles.navBar}>
<NavLink to="/wallet" style={styles.navLink} activeStyle={styles.navLinkActive}>
Wallet
Expand Down
6 changes: 0 additions & 6 deletions src/components/Chains/Chains.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/components/InchDex/hooks/useInch.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions src/components/TokenPrice.jsx
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -25,7 +25,7 @@ function TokenPrice(props) {

const noLogoToken = "https://etherscan.io/images/main/empty-token.png";

return (
return (
<div style={styles.token}>
<img src={props.image || noLogoToken} alt="logo" style={{ height: props?.size || "35px" }} />
<span
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useERC20Balance.js
Original file line number Diff line number Diff line change
@@ -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 useERC20Balance = (props) => {
const { account } = useMoralisWeb3Api();
const { isInitialized } = useMoralis();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useERC20Transfers.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useNFTBalance.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit c7098aa

Please sign in to comment.