-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Gateway] : v0.3.1: patch fixes Airdrop, Bring Old Dao Back. (#470)
* removed airdrop from gateway as it's deprecated. * bring back old DAO and disable veDao * yarn updated sentry package * - udpated constants - udated graphql service of governorProposalCreateds - moved fetch calls from home to dao. * loading proposals and threshold on dao page rendering. * fix for import
- Loading branch information
Showing
25 changed files
with
779 additions
and
1,395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
207 changes: 207 additions & 0 deletions
207
packages/boba/gateway/src/containers/VoteAndDao/Dao/OldDao.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
/* | ||
Copyright 2021-present Boba Network. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
import React, { useEffect, useState } from 'react' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
|
||
import { Box, Typography } from '@mui/material' | ||
import { openError, openModal } from 'actions/uiAction' | ||
import { orderBy } from 'lodash' | ||
|
||
import Button from 'components/button/Button' | ||
import ListProposal from 'components/listProposal/listProposal' | ||
|
||
import Select from 'components/select/Select' | ||
|
||
import { selectDaoBalance, selectDaoBalanceX, selectDaoVotes, selectDaoVotesX, selectProposals, selectProposalThreshold } from 'selectors/daoSelector' | ||
import { selectLoading } from 'selectors/loadingSelector' | ||
import { selectAccountEnabled, selectBaseEnabled, selectLayer } from 'selectors/setupSelector' | ||
|
||
import * as G from 'containers/Global.styles' | ||
import * as S from './OldDao.styles' | ||
import PageTitle from 'components/pageTitle/PageTitle' | ||
import Connect from 'containers/connect/Connect' | ||
import { fetchDaoBalance, fetchDaoBalanceX, fetchDaoProposals, fetchDaoVotes, fetchDaoVotesX, getProposalThreshold } from 'actions/daoAction' | ||
import { POLL_INTERVAL } from 'util/constant' | ||
import useInterval from 'hooks/useInterval' | ||
|
||
const PROPOSAL_STATES = [ | ||
{ value: 'All', label: 'All' }, | ||
{ value: 'Pending', label: 'Pending' }, | ||
{ value: 'Active', label: 'Active' }, | ||
{ value: 'Canceled', label: 'Canceled' }, | ||
{ value: 'Defeated', label: 'Defeated' }, | ||
{ value: 'Succeeded', label: 'Succeeded' }, | ||
{ value: 'Queued', label: 'Queued' }, | ||
{ value: 'Expired', label: 'Expired' }, | ||
{ value: 'Executed', label: 'Executed' } | ||
] | ||
|
||
function OldDao() { | ||
|
||
const dispatch = useDispatch() | ||
|
||
const accountEnabled = useSelector(selectAccountEnabled()) | ||
const baseEnabled = useSelector(selectBaseEnabled()) | ||
|
||
const layer = useSelector(selectLayer()); | ||
const loading = useSelector(selectLoading([ 'PROPOSALS/GET' ])) | ||
|
||
let proposals = useSelector(selectProposals) | ||
proposals = orderBy(proposals, i => i.startTimestamp, 'desc') | ||
|
||
const balance = useSelector(selectDaoBalance) | ||
const balanceX = useSelector(selectDaoBalanceX) | ||
const votes = useSelector(selectDaoVotes) | ||
const votesX = useSelector(selectDaoVotesX) | ||
const proposalThreshold = useSelector(selectProposalThreshold) | ||
|
||
const [ selectedState, setSelectedState ] = useState(PROPOSAL_STATES[ 0 ]) | ||
|
||
useInterval(() => { | ||
if(accountEnabled /*== MetaMask is connected*/) { | ||
dispatch(fetchDaoBalance()) // account specific | ||
dispatch(fetchDaoVotes()) // account specific | ||
dispatch(fetchDaoBalanceX()) // account specific | ||
dispatch(fetchDaoVotesX()) // account specific | ||
} | ||
if(baseEnabled /*== we only have have Base L1 and L2 providers*/) { | ||
dispatch(getProposalThreshold()) | ||
dispatch(fetchDaoProposals()) | ||
} | ||
}, POLL_INTERVAL) | ||
|
||
|
||
useEffect(() => { | ||
if (baseEnabled) { | ||
dispatch(getProposalThreshold()) | ||
dispatch(fetchDaoProposals()) | ||
} | ||
}, [dispatch, baseEnabled]); | ||
|
||
|
||
return ( | ||
<S.DaoPageContainer> | ||
<PageTitle title={'Dao'} /> | ||
<Connect | ||
userPrompt={'Please connect to Boba to vote and propose'} | ||
accountEnabled={accountEnabled} | ||
connectToBoba={true} | ||
layer={layer} | ||
/> | ||
<S.DaoPageContent> | ||
<S.DaoWalletContainer> | ||
<Box sx={{ padding: '24px 0px' }}> | ||
<Typography variant="h4">Balances</Typography> | ||
<Typography variant="body1" style={{ opacity: '0.5' }}>BOBA:</Typography> | ||
<Typography variant="h4" >{!!layer ? Math.round(Number(balance)) : '--'}</Typography> | ||
<Typography variant="body1" style={{ opacity: '0.5' }}>xBOBA:</Typography> | ||
<Typography variant="h4" >{!!layer ? Math.round(Number(balanceX)) : '--'}</Typography> | ||
</Box> | ||
<G.DividerLine /> | ||
<Box sx={{ padding: '24px 0px' }}> | ||
<Typography variant="h4">Votes</Typography> | ||
<Typography variant="body1" style={{ opacity: '0.5' }}>Boba:</Typography> | ||
<Typography variant="h4" >{!!layer ? Math.round(Number(votes)) : '--'}</Typography> | ||
<Typography variant="body1" style={{ opacity: '0.5' }}>xBoba:</Typography> | ||
<Typography variant="h4" >{!!layer ? Math.round(Number(votesX)) : '--'}</Typography> | ||
<Typography variant="body1" style={{ opacity: '0.5' }}>Total:</Typography> | ||
<Typography variant="h4" >{!!layer ? Math.round(Number(votes) + Number(votesX)) : '--'}</Typography> | ||
{layer === 'L2' && | ||
<S.DaoWalletAction> | ||
<Button | ||
color="primary" | ||
variant="outlined" | ||
onClick={() => { dispatch(openModal('delegateDaoModal')) }} | ||
disabled={!accountEnabled} | ||
> | ||
Delegate BOBA | ||
</Button> | ||
<Button | ||
color="primary" | ||
variant="outlined" | ||
onClick={() => { dispatch(openModal('delegateDaoXModal')) }} | ||
disabled={!accountEnabled} | ||
> | ||
Delegate xBOBA | ||
</Button> | ||
</S.DaoWalletAction> | ||
} | ||
<Box sx={{ padding: '12px 0px' }}> | ||
<Typography variant="body3">Only votes delegated BEFORE the start of the active voting period are counted in your vote</Typography> | ||
</Box> | ||
</Box> | ||
<G.DividerLine /> | ||
<Box sx={{ | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '10px', | ||
padding: '24px 0px' | ||
}}> | ||
<Button | ||
fullWidth={true} | ||
color="neutral" | ||
variant="outlined" | ||
disabled={!accountEnabled} | ||
onClick={() => { | ||
if (Number(Number(votes) + Number(votesX)) < Number(proposalThreshold)) { | ||
dispatch(openError(`Insufficient BOBA to create a new proposal. You need at least ${proposalThreshold} BOBA + xBOBA to create a proposal.`)) | ||
} else { | ||
dispatch(openModal('newProposalModal')) | ||
} | ||
}} | ||
> | ||
Create new proposal | ||
</Button> | ||
<Box sx={{ padding: '12px 0px' }}> | ||
<Typography variant="body3">At least {proposalThreshold} BOBA + xBOBA are needed to create a new proposal</Typography> | ||
</Box> | ||
</Box> | ||
</S.DaoWalletContainer> | ||
<S.DaoProposalContainer> | ||
<S.DaoProposalHead> | ||
<Typography variant="h3">Proposals</Typography> | ||
<Select | ||
options={PROPOSAL_STATES} | ||
onSelect={(e) => { | ||
setSelectedState(e) | ||
}} | ||
sx={{ marginBottom: '20px' }} | ||
value={selectedState} | ||
newSelect={true} | ||
></Select> | ||
</S.DaoProposalHead> | ||
<G.DividerLine /> | ||
<S.DaoProposalListContainer> | ||
{!!loading && !proposals.length ? <Typography>Loading...</Typography> : null} | ||
{proposals | ||
// eslint-disable-next-line array-callback-return | ||
.filter((p) => { | ||
if (selectedState.value === 'All') { | ||
return true; | ||
} | ||
return selectedState.value === p.state; | ||
}) | ||
.map((p, index) => { | ||
return <React.Fragment key={index}> | ||
<ListProposal proposal={p} /> | ||
</React.Fragment> | ||
})} | ||
</S.DaoProposalListContainer> | ||
</S.DaoProposalContainer> | ||
</S.DaoPageContent> | ||
</S.DaoPageContainer> | ||
) | ||
} | ||
|
||
export default React.memo(OldDao) |
Oops, something went wrong.