Skip to content

Commit

Permalink
small fix for the token update
Browse files Browse the repository at this point in the history
  • Loading branch information
vickyshaw29 committed Jul 14, 2022
1 parent 23f7c36 commit 9cbf2a7
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 53 deletions.
85 changes: 45 additions & 40 deletions src/Dashboard/comp/SendTokens.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Divider,
IconButton,
useTheme,
Tooltip,
} from "@mui/material";
import Input from "../../common/Input/Input.jsx";
import { useSnackbar } from "notistack";
Expand Down Expand Up @@ -173,28 +174,30 @@ const SendTokens = () => {
</Grid>
<Grid item container justifyContent="center">
{/* 1 */}
<Grid item>
<Grid container direction="column">
<Grid item>
<IconButton
color="primary"
component="span"
style={{
backgroundColor: theme.palette.primary.main,
color: "#fff",
}}
disabled
>
<FileDownloadOutlinedIcon />
</IconButton>
</Grid>
<Grid item>
<Typography variant="body1" align="center" sx={{ mt: 1 }}>
Buy
</Typography>
<Tooltip title="Coming soon" placement="top">
<Grid item>
<Grid container direction="column">
<Grid item>
<IconButton
color="primary"
component="span"
style={{
backgroundColor: theme.palette.primary.main,
color: "#fff",
}}
disabled
>
<FileDownloadOutlinedIcon />
</IconButton>
</Grid>
<Grid item>
<Typography variant="body1" align="center" sx={{ mt: 1 }}>
Buy
</Typography>
</Grid>
</Grid>
</Grid>
</Grid>
</Tooltip>
{/* 2 */}
<Grid item sx={{ ml: 4 }}>
<Grid container direction="column">
Expand All @@ -219,28 +222,30 @@ const SendTokens = () => {
</Grid>
</Grid>
{/* 3 */}
<Grid item sx={{ ml: 4 }}>
<Grid container direction="column">
<Grid item>
<IconButton
color="primary"
component="span"
style={{
backgroundColor: theme.palette.primary.main,
color: "#fff",
}}
disabled
>
<SwapHorizontalCircleOutlinedIcon />
</IconButton>
</Grid>
<Grid item>
<Typography variant="body1" sx={{ mt: 1 }}>
Swap
</Typography>
<Tooltip title="Coming soon" placement="top">
<Grid item sx={{ ml: 4 }}>
<Grid container direction="column">
<Grid item>
<IconButton
color="primary"
component="span"
style={{
backgroundColor: theme.palette.primary.main,
color: "#fff",
}}
disabled
>
<SwapHorizontalCircleOutlinedIcon />
</IconButton>
</Grid>
<Grid item>
<Typography variant="body1" sx={{ mt: 1 }}>
Swap
</Typography>
</Grid>
</Grid>
</Grid>
</Grid>
</Tooltip>
</Grid>
</Grid>
{/* <Grid
Expand Down
31 changes: 31 additions & 0 deletions src/Dashboard/helper/Assets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ import { useEffect } from "react";
import { removeToken } from "../../redux/projects/projectSlice";
import SendIcon from "@mui/icons-material/Send";
import AssetsSend from "./assetsHelper/AssetsSend.jsx";
import { editCustomToken } from "../../redux/projects/projectSlice";
import { NODE_URL } from "../../services/helper/config";

const Assets = () => {
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);
Expand All @@ -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 (
<Grid container direction="column">
{tokenObj?.map((token, i) => {
Expand Down
26 changes: 13 additions & 13 deletions src/Dashboard/helper/assetsHelper/AssetsSend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9cbf2a7

Please sign in to comment.