Skip to content

Commit

Permalink
[Gateway] : v0.3.1: patch fixes Airdrop, Bring Old Dao Back. (#470)
Browse files Browse the repository at this point in the history
* 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
sk-enya authored Nov 24, 2022
1 parent 1abd873 commit 18fb852
Show file tree
Hide file tree
Showing 25 changed files with 779 additions and 1,395 deletions.
8 changes: 7 additions & 1 deletion packages/boba/gateway/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ REACT_APP_ENV=dev
REACT_APP_CHAIN=mainnet
REACT_APP_STATUS=normal
REACT_APP_SPEED_CHECK=
REACT_APP_AIRDROP=
REACT_APP_GA4_MEASUREMENT_ID=
REACT_APP_SENTRY_DSN=
REACT_APP_ENABLE_LOCK_PAGE= # values can be 0 and 1
REACT_APP_ZENDESK_KEY= ## KEY for the zendesk widget.


################
### Ve Dao #####
################
# to disable the veDao set below flat to 1.
REACT_APP_DISABLE_VE_DAO=1
4 changes: 2 additions & 2 deletions packages/boba/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@mui/icons-material": "^5.3.1",
"@mui/material": "^5.4.0",
"@mui/styles": "^5.3.0",
"@sentry/react": "^7.12.1",
"@sentry/tracing": "^7.12.1",
"@sentry/react": "^7.20.1",
"@sentry/tracing": "^7.20.1",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"axios": "^0.21.1",
Expand Down
1 change: 0 additions & 1 deletion packages/boba/gateway/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ gateway.boba.betwork.
| REACT_APP_CHAIN | Yes | mainnet | Chain where we want to connect the app to like rinkeby, mainnet |
| REACT_APP_STATUS | NO | N/A | To notify the status about any maintainance activity going on. |
| REACT_APP_SPEED_CHECK | | | |
| REACT_APP_AIRDROP | | | |
| REACT_APP_GA4_MEASUREMENT_ID | Yes | N/A | Google analytics api key |
| REACT_APP_SENTRY_DSN | Yes | N/A | Sentry DSN url to catch the error on frontend |
| REACT_APP_ENABLE_LOCK_PAGE | No | N/A | to enable the lock page on gateway menu |
Expand Down
29 changes: 0 additions & 29 deletions packages/boba/gateway/src/actions/airdropAction.js

This file was deleted.

12 changes: 9 additions & 3 deletions packages/boba/gateway/src/components/mainMenu/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export const menuItems = [
key: 'Lock',
icon: "LockIcon",
title: "Lock",
url: "/lock",
url: ROUTES_PATH.LOCK,
},
{
key: 'Vote',
key: 'Vote&Dao',
icon: "VoteIcon",
title: "Vote&Dao",
url: ROUTES_PATH.VOTE_DAO
Expand All @@ -54,5 +54,11 @@ export const menuItems = [
icon: "LinksToBobaChainsIcon",
title: "BOBA Chains",
url: ROUTES_PATH.BOBA_CHAINS
}
},
{
key: 'DAO',
icon: "VoteIcon",
title: "Dao",
url: ROUTES_PATH.DAO
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { selectMonster } from 'selectors/setupSelector'
import { menuItems } from '../menuItems'

import * as S from './MenuItems.styles'
import { DISABLE_VE_DAO } from 'util/constant'

const MenuItems = () => {

Expand Down Expand Up @@ -36,6 +37,9 @@ const MenuItems = () => {
return (
<S.Nav>
{menuList.map((item) => {
if (!!Number(DISABLE_VE_DAO) && (['Lock','Vote&Dao'].includes(item.key))) {
return null;
}
return (
<S.MenuItem
style={({ isActive }) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/boba/gateway/src/components/pageFooter/PageFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ const PageFooter = ({maintenance}) => {
<S.FooterLink
to={ROUTES_PATH.HELP}
>FAQs</S.FooterLink>
<S.FooterLink
to={ROUTES_PATH.AIRDROP}
>AirDrop</S.FooterLink>
<S.FooterLink
to={ROUTES_PATH.BOBASCOPE}
>BobaScope</S.FooterLink>
Expand Down
9 changes: 6 additions & 3 deletions packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { selectLockRecords } from 'selectors/veBobaSelector'

import {DividerLine} from 'containers/Global.styles'
import * as S from './Dao.styles'
import { setConnectBOBA } from 'actions/setupAction'

const PROPOSAL_STATES = [
{ value: 'All', label: 'All' },
Expand All @@ -48,9 +49,7 @@ const PROPOSAL_STATES = [
{ value: 'Executed', label: 'Executed' }
]

function DAO({
connectToBOBA
}) {
function DAO() {

const dispatch = useDispatch()

Expand Down Expand Up @@ -79,6 +78,10 @@ function DAO({
}
}, [ accountEnabled, nftRecords ]);

async function connectToBOBA() {
dispatch(setConnectBOBA(true))
}


return (
<S.DaoPageContent>
Expand Down
207 changes: 207 additions & 0 deletions packages/boba/gateway/src/containers/VoteAndDao/Dao/OldDao.js
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)
Loading

0 comments on commit 18fb852

Please sign in to comment.