From 9cbf2a7a42063e03e5e46b666cb1977b675ecac4 Mon Sep 17 00:00:00 2001 From: Vicky Prasad Date: Thu, 14 Jul 2022 14:52:59 +0530 Subject: [PATCH] small fix for the token update --- src/Dashboard/comp/SendTokens.jsx | 85 ++++++++++--------- src/Dashboard/helper/Assets.jsx | 31 +++++++ .../helper/assetsHelper/AssetsSend.jsx | 26 +++--- 3 files changed, 89 insertions(+), 53 deletions(-) diff --git a/src/Dashboard/comp/SendTokens.jsx b/src/Dashboard/comp/SendTokens.jsx index 4ecdbb978..3727b8384 100644 --- a/src/Dashboard/comp/SendTokens.jsx +++ b/src/Dashboard/comp/SendTokens.jsx @@ -6,6 +6,7 @@ import { Divider, IconButton, useTheme, + Tooltip, } from "@mui/material"; import Input from "../../common/Input/Input.jsx"; import { useSnackbar } from "notistack"; @@ -173,28 +174,30 @@ const SendTokens = () => { {/* 1 */} - - - - - - - - - - Buy - + + + + + + + + + + + Buy + + - + {/* 2 */} @@ -219,28 +222,30 @@ const SendTokens = () => { {/* 3 */} - - - - - - - - - - Swap - + + + + + + + + + + + Swap + + - + {/* { const styles = DashboardStyles(); const dispatch = useDispatch(); + + const { privateKey, walletAddress } = useSelector((state) => state?.project); + const provider = new ethers.providers.JsonRpcProvider(NODE_URL); + const signer = new ethers.Wallet(privateKey, provider); + const [loading, setLoading] = useState(false); let [activeAddress, setActiveAddress] = useState(""); const { tokenContractAddress } = useSelector((state) => state?.project); @@ -40,6 +47,30 @@ const Assets = () => { setTokenObj(val); }; + const updateData = async (addr) => { + console.log(addr,"addraddr") + let contract = new ethers.Contract(addr ? addr : "", abi, signer); + const decimals = await contract.decimals(); + const symbol = await contract.symbol(); + const balance = await contract.balanceOf(walletAddress); + console.log(balance, symbol, decimals, "kdhwkdhwdkhwdkhd"); + dispatch( + editCustomToken({ + data: { + tokenDecimal: decimals, + tokenSymbol: symbol, + balance: balance, + address: contract.address, + }, + }) + ); + } + + useEffect(() => { + if(tokenContractAddress.length){ + tokenContractAddress.map((token) => updateData(token.address)); + } + }, []); return ( {tokenObj?.map((token, i) => { diff --git a/src/Dashboard/helper/assetsHelper/AssetsSend.jsx b/src/Dashboard/helper/assetsHelper/AssetsSend.jsx index aa1e06998..3407900d7 100644 --- a/src/Dashboard/helper/assetsHelper/AssetsSend.jsx +++ b/src/Dashboard/helper/assetsHelper/AssetsSend.jsx @@ -102,19 +102,19 @@ const AssetsSend = ({ open, handleClose, addr }) => { walletAddress: "", amount: "", }); - const decimals = await contract.decimals(); - const symbol = await contract.symbol(); - const balance = await contract.balanceOf(walletAddress); - dispatch( - editCustomToken({ - data: { - tokenDecimal: decimals, - tokenSymbol: symbol, - balance: balance, - address: contract.address, - }, - }) - ); + // const decimals = await contract.decimals(); + // const symbol = await contract.symbol(); + // const balance = await contract.balanceOf(walletAddress); + // dispatch( + // editCustomToken({ + // data: { + // tokenDecimal: decimals, + // tokenSymbol: symbol, + // balance: balance, + // address: contract.address, + // }, + // }) + // ); } } catch (error) { setLoading(false);