Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further fixes for DAO v3 UI #31

Merged
merged 9 commits into from
Feb 28, 2024
10 changes: 0 additions & 10 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import ProposalsProvider from './context/Proposals'
import EventsProvider from './context/Events'
import Avatar from './base/Avatar'
import Overview from './pages/Overview'
import Lending from './pages/Lending'
import Nodes from './pages/Nodes'
import Staking from './pages/Staking'
import Disclaimer from './complex/Disclaimer'
import SettingsDrawer from './complex/Settings'
Expand All @@ -25,14 +23,6 @@ const router = createHashRouter([
path: '/',
element: <Overview />
},
{
path: '/lending',
element: <Lending />
},
{
path: '/nodes',
element: <Nodes />
},
{
path: '/staking',
element: <Staking />
Expand Down
12 changes: 0 additions & 12 deletions src/components/complex/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ const Header = (_props) => {
<StyledLink withmargin="true" to={'/staking'} active={(pathname === '/staking').toString()}>
Staking
</StyledLink>
<StyledLink withmargin="true" to={'/lending'} active={(pathname === '/lending').toString()}>
Lending
</StyledLink>
<StyledLink withmargin="true" to={'/nodes'} active={(pathname === '/nodes').toString()}>
Nodes
</StyledLink>
</StyledNav>
<ButtonsContainer>
<CustomConnectButton />
Expand All @@ -294,12 +288,6 @@ const Header = (_props) => {
<StyledLinkMobile to={'/staking'} active={(pathname === '/staking').toString()}>
Staking
</StyledLinkMobile>
<StyledLinkMobile to={'/lending'} active={(pathname === '/lending').toString()}>
Lending
</StyledLinkMobile>
<StyledLinkMobile to={'/nodes'} active={(pathname === '/nodes').toString()}>
Nodes
</StyledLinkMobile>
</ContainerLinkMobile>
</HeaderContainer>
{/*<ContainerBottomMobile>
Expand Down
40 changes: 12 additions & 28 deletions src/components/complex/Proposal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ const QuorumText = styled(Text)`
color: ${({ theme, quorumreached }) => (quorumreached ? theme.yellow : theme.red)};
`

const QuorumContainer = styled.div`
margin-left: 7px;
`

const StyledIcon = styled(Icon)`
margin-right: 5px;
`
Expand Down Expand Up @@ -143,7 +139,7 @@ const SpinnerView = styled.div`
display: flex;
flex: 1;
justify-content: center;
align-items. center;
align-items: center;
margin-top: 50px;
margin-bottom: 50px;
`
Expand Down Expand Up @@ -205,35 +201,23 @@ const Proposal = ({
[open, daoPntBalance, vote]
)

const { data: yesData, /*isLoading: isLoadingYes,*/ writeContract: callYes, error: yesError } = useWriteContract()
const yes = () => callYes({ activeChainId, address, id: effectiveId, vote: true, enabled: canVote })

const { data: noData, /*isLoading: isLoadingNo,*/ writeContract: callNo, error: noError } = useWriteContract()
const no = () => callNo({ activeChainId, address, id: effectiveId, vote: false, enabled: canVote })

useEffect(() => {
if (yesError && isValidError(yesError)) {
toast.error(yesError.message)
}
}, [yesError])

useEffect(() => {
if (noError && isValidError(noError)) {
toast.error(noError.message)
}
}, [noError])
const { data: voteData, /*isLoading: isLoadingYes,*/ writeContract: callVote, error: voteError } = useWriteContract()
const yes = () =>
callVote(prepareContractWriteVote({ activeChainId, address, id: effectiveId, vote: true, enabled: true }))
envin3 marked this conversation as resolved.
Show resolved Hide resolved
const no = () =>
callVote(prepareContractWriteVote({ activeChainId, address, id: effectiveId, vote: false, enabled: true }))

useEffect(() => {
if (yesData) {
toastifyTransaction(yesData, { chainId: activeChainId })
if (voteError && isValidError(voteError)) {
toast.error(voteError.message)
}
}, [yesData, activeChainId])
}, [voteError])

useEffect(() => {
if (noData) {
toastifyTransaction(noData, { chainId: activeChainId })
if (voteData) {
toastifyTransaction(voteData, { chainId: activeChainId })
}
}, [noData, activeChainId])
}, [voteData, activeChainId])

const renderTooltip = (props) => (
<Tooltip id="button-tooltip" {...props}>
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use-lending-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ const useLend = () => {
)

const { isLoading: isApproving } = useWaitForTransactionReceipt({
hash: approveData?.hash,
hash: approveData,
confirmations: 1
})

const { isLoading: isLending } = useWaitForTransactionReceipt({
hash: lendData?.hash,
hash: lendData,
confirmations: 1
})

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const useProposals = () => {
return [...effectiveDaoV1Proposals, ...effectiveDaoV2ProposalVotes, ...daoV3ProposalsWithVote].sort(
(_a, _b) => _b.timestamp - _a.timestamp
)
}, [daoV1ProposalsWithVote, daoV2ProposalsWithVote])
}, [daoV1ProposalsWithVote, daoV2ProposalsWithVote, daoV3ProposalsWithVote])
}

const useCreateProposal = () => {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/use-registration-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ const useRegisterSentinel = ({ type = 'stake' }) => {
)

const { isLoading: isApproving } = useWaitForTransactionReceipt({
hash: approveData?.hash,
hash: approveData,
confirmations: 1
})

const { isLoading: isUpdatingSentinelRegistrationByStaking } = useWaitForTransactionReceipt({
hash: updateSentinelRegistrationByStakingData?.hash,
hash: updateSentinelRegistrationByStakingData,
confirmations: 1
})

Expand All @@ -145,7 +145,7 @@ const useRegisterSentinel = ({ type = 'stake' }) => {
)

const { isLoading: isUpdatingSentinelRegistrationByBorrowing } = useWaitForTransactionReceipt({
hash: updateSentinelRegistrationByBorrowingData?.hash,
hash: updateSentinelRegistrationByBorrowingData,
confirmations: 1
})

Expand Down
2 changes: 0 additions & 2 deletions src/hooks/use-safe-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const useIsSafe = () => {
useEffect(() => {
const getCode = async () => {
try {
console.log('address', address)
const code = await client.getBytecode({ address: address, blockTag: 'latest' })
console.log('code', code)
if (code === GNOSIS_PROXY_CONTRACT_BYTECODE) {
const contract = getContract({
address: address,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-staking-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const useUnstake = (_opts = {}) => {
)

const { isLoading: isUnstaking } = useWaitForTransactionReceipt({
hash: unstakeData?.hash,
hash: unstakeData,
confirmations: 1
})

Expand Down
4 changes: 2 additions & 2 deletions src/utils/amount.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BigNumber from 'bignumber.js'
import { format } from 'currency-formatter'
import { parseUnits } from 'viem'
import { parseEther } from 'viem'
import numeral from 'numeral'

export const formatAssetAmount = (_amount, _symbol, _opts = {}) => {
Expand Down Expand Up @@ -35,6 +35,6 @@ export const formatCurrency = (_amount, _currency) =>
export const removeUselessDecimals = (_amount, _decimals = 5) =>
BigNumber(BigNumber(_amount).toFixed(_decimals)).toFixed()

export const getEthersOnChainAmount = (_amount) => (_amount.toString().length > 0 ? parseUnits(_amount, 18) : 0n)
export const getEthersOnChainAmount = (_amount) => (_amount.toString().length > 0 ? parseEther(_amount.toString()) : 0n)

export const removeCommas = (_num) => _num?.replace(/,/g, '')