From 29f3ea35925a45543714131843ac6ff318f6d4c4 Mon Sep 17 00:00:00 2001 From: Kenny Chung Date: Wed, 20 Apr 2022 14:58:00 +0200 Subject: [PATCH] chore: removed code --- .../REPMint/REPMintEditor.tsx | 29 +++++-------------- .../REPMint/REPMintInfoLine.tsx | 28 ++++-------------- .../REPMint/REPMintSummary.tsx | 1 + 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintEditor.tsx b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintEditor.tsx index 179193d7b5..be79f80f0a 100644 --- a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintEditor.tsx +++ b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintEditor.tsx @@ -1,9 +1,9 @@ import styled from 'styled-components'; import { Input } from 'components/Guilds/common/Form/Input'; import Avatar from 'components/Guilds/Avatar'; -import { useEffect, useMemo } from 'react'; +import { useEffect } from 'react'; import { ActionEditorProps } from '..'; -import { BigNumber, ethers } from 'ethers'; +import { ethers } from 'ethers'; import useENSAvatar from 'hooks/Guilds/ether-swr/ens/useENSAvatar'; import { Box } from 'components/Guilds/common/Layout'; import { shortenAddress, MAINNET_ID } from 'utils'; @@ -12,10 +12,9 @@ import { ReactComponent as Info } from '../../../../../assets/images/info.svg'; import StyledIcon from 'components/Guilds/common/SVG'; import useBigNumberToNumber from 'hooks/Guilds/conversions/useBigNumberToNumber'; import { useState } from 'react'; -import { useERC20Info } from 'hooks/Guilds/ether-swr/erc20/useERC20Info'; -import { useGuildConfig } from 'hooks/Guilds/ether-swr/guild/useGuildConfig'; -import { useParams } from 'react-router-dom'; import NumericalInput from 'components/Guilds/common/Form/NumericalInput'; +import { useTotalSupply } from 'hooks/Guilds/guild/useTotalSupply'; +import { useTokenData } from 'hooks/Guilds/guild/useTokenData'; const Control = styled(Box)` display: flex; @@ -50,28 +49,14 @@ const RepMintInput = styled(NumericalInput)` } `; -interface REPMintState { - toAddress: string; - amount: BigNumber; -} - const Mint: React.FC = ({ decodedCall, updateCall }) => { // parse transfer state from calls const [repPercent, setRepPercent] = useState(0); const [repAmount, setRepAmount] = useState(0); - const { guild_id: guildId } = - useParams<{ chain_name?: string; guild_id?: string }>(); - const { data } = useGuildConfig(guildId); - const { data: tokenData } = useERC20Info(data?.token); - const totalSupply = useBigNumberToNumber(tokenData?.totalSupply, 18); + const { parsedData } = useTotalSupply({ decodedCall }); + const { tokenData } = useTokenData(); - const parsedData = useMemo(() => { - if (!decodedCall) return null; - return { - toAddress: decodedCall.args.to, - amount: decodedCall.args.amount, - }; - }, [decodedCall]); + const totalSupply = useBigNumberToNumber(tokenData?.totalSupply, 18); const { imageUrl } = useENSAvatar(parsedData?.toAddress, MAINNET_ID); diff --git a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintInfoLine.tsx b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintInfoLine.tsx index 1ead7cc7c3..1f460d2ab4 100644 --- a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintInfoLine.tsx +++ b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintInfoLine.tsx @@ -1,6 +1,5 @@ import Avatar from 'components/Guilds/Avatar'; import useENSAvatar from 'hooks/Guilds/ether-swr/ens/useENSAvatar'; -import { useMemo } from 'react'; import { FiArrowRight } from 'react-icons/fi'; import { MAINNET_ID, shortenAddress } from 'utils'; import { ActionViewProps } from '..'; @@ -8,37 +7,20 @@ import { Segment } from '../common/infoLine'; import { ReactComponent as Mint } from '../../../../../assets/images/mint.svg'; import StyledIcon from 'components/Guilds/common/SVG'; import styled from 'styled-components'; -import { BigNumber } from 'ethers'; import useBigNumberToNumber from 'hooks/Guilds/conversions/useBigNumberToNumber'; -import { useERC20Info } from 'hooks/Guilds/ether-swr/erc20/useERC20Info'; -import { useGuildConfig } from 'hooks/Guilds/ether-swr/guild/useGuildConfig'; -import { useParams } from 'react-router-dom'; +import { useTotalSupply } from 'hooks/Guilds/guild/useTotalSupply'; +import { useTokenData } from 'hooks/Guilds/guild/useTokenData'; const StyledMintIcon = styled(StyledIcon)` margin: 0; `; -interface REPMintState { - guildAddress: string; - toAddress: string; - amount: BigNumber; -} - const REPMintInfoLine: React.FC = ({ decodedCall }) => { - const { guild_id: guildId } = - useParams<{ chain_name?: string; guild_id?: string }>(); - const { data } = useGuildConfig(guildId); - const { data: tokenData } = useERC20Info(data?.token); + const { parsedData } = useTotalSupply({ decodedCall }); + const { tokenData } = useTokenData(); + const totalSupply = useBigNumberToNumber(tokenData?.totalSupply, 18); - const parsedData = useMemo(() => { - if (!decodedCall) return null; - return { - guildAddress: decodedCall.to, - toAddress: decodedCall.args.to, - amount: decodedCall.args.amount, - }; - }, [decodedCall]); const { ensName, imageUrl } = useENSAvatar(parsedData?.toAddress, MAINNET_ID); const roundedRepAmount = useBigNumberToNumber(parsedData?.amount, 16, 3); diff --git a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintSummary.tsx b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintSummary.tsx index 1b4418477e..90bd25a6ed 100644 --- a/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintSummary.tsx +++ b/src/components/Guilds/ActionsBuilder/SupportedActions/REPMint/REPMintSummary.tsx @@ -7,6 +7,7 @@ import { Segment } from '../common/infoLine'; import { DetailCell, DetailHeader, DetailRow } from '../common/summary'; import { useTotalSupply } from 'hooks/Guilds/guild/useTotalSupply'; import { useTokenData } from 'hooks/Guilds/guild/useTokenData'; + const REPMintSummary: React.FC = ({ decodedCall }) => { const { parsedData } = useTotalSupply({ decodedCall }); const { tokenData } = useTokenData();