From 3ce762439c2f05ea5cad9de58733379571394bba Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar Date: Sat, 19 Nov 2022 15:04:50 +0530 Subject: [PATCH 1/4] bring back old dao on gateway with flag for veDao and Lock --- packages/boba/gateway/.env.example | 22 ++ .../boba/gateway/src/api/etherScanAxios.js | 1 + .../gateway/src/api/metaTransactionAxios.js | 1 + .../boba/gateway/src/api/omgxWatcherAxios.js | 1 + .../gateway/src/api/verifierWatcherAxios.js | 1 + .../mainMenu/menuItems/MenuItems.js | 7 +- .../{menuItems.js => menuItems/menuList.js} | 10 +- .../src/containers/VoteAndDao/Dao/Dao.js | 7 +- .../boba/gateway/src/containers/dao/OldDao.js | 196 +++++++++++++ .../src/containers/dao/OldDao.styles.js | 103 +++++++ .../boba/gateway/src/containers/home/Home.js | 2 +- .../modals/dao/old/NewProposalModalOldDao.js | 268 ++++++++++++++++++ .../src/containers/wallet/token/Token.js | 1 + packages/boba/gateway/src/layout/index.js | 11 +- .../gateway/src/services/graphQLService.js | 4 +- .../gateway/src/services/networkService.js | 140 ++++++++- packages/boba/gateway/src/util/constant.js | 17 ++ 17 files changed, 773 insertions(+), 19 deletions(-) rename packages/boba/gateway/src/components/mainMenu/{menuItems.js => menuItems/menuList.js} (87%) create mode 100644 packages/boba/gateway/src/containers/dao/OldDao.js create mode 100644 packages/boba/gateway/src/containers/dao/OldDao.styles.js create mode 100644 packages/boba/gateway/src/containers/modals/dao/old/NewProposalModalOldDao.js diff --git a/packages/boba/gateway/.env.example b/packages/boba/gateway/.env.example index 8091010d63..ef7772f964 100644 --- a/packages/boba/gateway/.env.example +++ b/packages/boba/gateway/.env.example @@ -12,3 +12,25 @@ 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. + +############################### +#### TESTNET CHAIN CONFIG ##### +############################### +REACT_APP_TESTNET_NETWORK_NAME=rinkeby + +REACT_APP_TESTNET_L1_NAME=Rinkeby +REACT_APP_TESTNET_L1_CHAIN_ID=4 +REACT_APP_TESTNET_L1_CHAIN_ID_HEX=0x4 +REACT_APP_TESTNET_L1_RPC_URL=https://rpc.ankr.com/eth_rinkeby +REACT_APP_TESTNET_L1_BLOCK_EXPLORER=https://api-rinkeby.etherscan.io/api?module=account&action=txlist&startblock=0&endblock=99999999&sort=asc&apikey= +REACT_APP_TESTNET_L1_TRANSACTION=https://rinkeby.etherscan.io/tx/ + +REACT_APP_TESTNET_OMGX_WATCHER_URL=https://api-watcher.rinkeby.boba.network/ +REACT_APP_TESTNET_VERIFIER_WATCHER_URL=https://api-verifier.rinkeby.boba.network/ +REACT_APP_TESTNET_MM_LABEL=Rinkeby + +################ +### Ve Dao ##### +################ +# to disable the veDoa set below flat to 1. +REACT_APP_DISABLE_VE_DAO=1 diff --git a/packages/boba/gateway/src/api/etherScanAxios.js b/packages/boba/gateway/src/api/etherScanAxios.js index 698333e3b9..164c747aed 100644 --- a/packages/boba/gateway/src/api/etherScanAxios.js +++ b/packages/boba/gateway/src/api/etherScanAxios.js @@ -1,4 +1,5 @@ import axios from 'axios' +import { TESTNET_NETWORK_NAME } from 'util/constant'; import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/api/metaTransactionAxios.js b/packages/boba/gateway/src/api/metaTransactionAxios.js index 8f0bc37044..cbd2d329ee 100644 --- a/packages/boba/gateway/src/api/metaTransactionAxios.js +++ b/packages/boba/gateway/src/api/metaTransactionAxios.js @@ -1,4 +1,5 @@ import axios from 'axios' +import { TESTNET_NETWORK_NAME } from 'util/constant'; import { getBaseServices } from 'util/masterConfig' export default function metaTransactionAxiosInstance(networkGateway){ diff --git a/packages/boba/gateway/src/api/omgxWatcherAxios.js b/packages/boba/gateway/src/api/omgxWatcherAxios.js index f313540d3e..962723647c 100644 --- a/packages/boba/gateway/src/api/omgxWatcherAxios.js +++ b/packages/boba/gateway/src/api/omgxWatcherAxios.js @@ -1,4 +1,5 @@ import axios from 'axios' +import { TESTNET_NETWORK_NAME } from 'util/constant' import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/api/verifierWatcherAxios.js b/packages/boba/gateway/src/api/verifierWatcherAxios.js index 270aa035b6..2164e13c47 100644 --- a/packages/boba/gateway/src/api/verifierWatcherAxios.js +++ b/packages/boba/gateway/src/api/verifierWatcherAxios.js @@ -1,4 +1,5 @@ import axios from 'axios' +import { TESTNET_NETWORK_NAME } from 'util/constant' import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js b/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js index 532593c79c..7c38905110 100644 --- a/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js +++ b/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js @@ -3,10 +3,10 @@ import { useSelector } from 'react-redux' import { useTheme } from '@mui/material' import { selectMonster } from 'selectors/setupSelector' - -import { menuItems } from '../menuItems' +import { menuItems } from './menuList' import * as S from './MenuItems.styles' +import { DISABLE_VE_DAO } from 'util/constant' const MenuItems = () => { @@ -36,6 +36,9 @@ const MenuItems = () => { return ( {menuList.map((item) => { + if (!!Number(DISABLE_VE_DAO) && (['Lock'].includes(item.key))) { + return null; + } return ( { diff --git a/packages/boba/gateway/src/components/mainMenu/menuItems.js b/packages/boba/gateway/src/components/mainMenu/menuItems/menuList.js similarity index 87% rename from packages/boba/gateway/src/components/mainMenu/menuItems.js rename to packages/boba/gateway/src/components/mainMenu/menuItems/menuList.js index 0e478d2874..5c65a0142e 100644 --- a/packages/boba/gateway/src/components/mainMenu/menuItems.js +++ b/packages/boba/gateway/src/components/mainMenu/menuItems/menuList.js @@ -41,14 +41,20 @@ 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 }, + { + key: 'DAO', + icon: "VoteIcon", + title: "Dao", + url: ROUTES_PATH.DAO + }, { key: 'LinksToBobaChains', icon: "LinksToBobaChainsIcon", diff --git a/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js b/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js index e2c6b5d8ef..d7638b41fb 100644 --- a/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js +++ b/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js @@ -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' }, @@ -49,7 +50,7 @@ const PROPOSAL_STATES = [ ] function DAO({ - connectToBOBA + }) { const dispatch = useDispatch() @@ -80,6 +81,10 @@ function DAO({ }, [ accountEnabled, nftRecords ]); + async function connectToBOBA() { + dispatch(setConnectBOBA(true)) + } + return ( diff --git a/packages/boba/gateway/src/containers/dao/OldDao.js b/packages/boba/gateway/src/containers/dao/OldDao.js new file mode 100644 index 0000000000..870f92870e --- /dev/null +++ b/packages/boba/gateway/src/containers/dao/OldDao.js @@ -0,0 +1,196 @@ +/* +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, selectLatestProposalState, selectProposals, selectProposalThreshold } from 'selectors/daoSelector' +import { selectLoading } from 'selectors/loadingSelector' +import { selectAccountEnabled, selectLayer } from 'selectors/setupSelector' + +import { selectLockRecords } from 'selectors/veBobaSelector' + + +import * as G from 'containers/Global.styles' +import * as S from './OldDao.styles' +import { setConnectBOBA } from 'actions/setupAction' +import PageTitle from 'components/pageTitle/PageTitle' +import Connect from 'containers/connect/Connect' + +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 layer = useSelector(selectLayer()); + const loading = useSelector(selectLoading()); + + let proposals = useSelector(selectProposals) + proposals = orderBy(proposals, i => i.startTimestamp, 'desc') + + // const [ balance, setBalance ] = useState('--'); + 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 ]) + + // useEffect(() => { + // if (!!accountEnabled) { + // const veBoba = nftRecords.reduce((s, record) => s + Number(record.balance), 0); + // setBalance(veBoba.toFixed(2)) + // } + // }, [ accountEnabled, nftRecords ]); + + return ( + + + + + + + Balances + BOBA: + {!!layer ? Math.round(Number(balance)) : '--'} + xBOBA: + {!!layer ? Math.round(Number(balanceX)) : '--'} + + + + Votes + Boba: + {!!layer ? Math.round(Number(votes)) : '--'} + xBoba: + {!!layer ? Math.round(Number(votesX)) : '--'} + Total: + {!!layer ? Math.round(Number(votes) + Number(votesX)) : '--'} + {layer === 'L2' && + + + + + } + + Only votes delegated BEFORE the start of the active voting period are counted in your vote + + + + + + + At least {proposalThreshold} BOBA + xBOBA are needed to create a new proposal + + + + + + Proposals + + + + + {!!loading && !proposals.length ? Loading... : 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 + + + })} + + + + + ) +} + +export default React.memo(OldDao) diff --git a/packages/boba/gateway/src/containers/dao/OldDao.styles.js b/packages/boba/gateway/src/containers/dao/OldDao.styles.js new file mode 100644 index 0000000000..d70538bca5 --- /dev/null +++ b/packages/boba/gateway/src/containers/dao/OldDao.styles.js @@ -0,0 +1,103 @@ +import { styled } from '@mui/material/styles' +import { Box } from "@mui/material" + +export const DaoPageContainer = styled(Box)(({ theme }) => ({ + margin: '0px auto', + display: 'flex', + flexDirection: 'column', + justifyContent: 'space-around', + padding: '10px', + paddingTop: '0px', + width: '70%', + gap: '10px', + [theme.breakpoints.between('md', 'lg')]: { + width: '90%', + padding: '0px', + }, + [theme.breakpoints.between('sm', 'md')]: { + width: '90%', + padding: '0px', + }, + [theme.breakpoints.down('sm')]: { + width: '100%', + padding: '0px', + }, + +})); + +export const DaoPageContent = styled(Box)(({ theme }) => ({ + display: 'flex', + flexDirection: 'row', + justifyContent: 'center', + alignItems: 'flex-start', + paddingTop: '0px', + gap: '10px', + [theme.breakpoints.down('sm')]: { + flexDirection: 'column' + }, +})); + +export const DaoWalletContainer = styled(Box)(({ theme }) => ({ + display: 'flex', + flexDirection: 'column', + padding: '0px 20px', + minHeight: '700px', + width: '30%', + gap: '10px', + borderRadius: theme.palette.primary.borderRadius, + background: theme.palette.background.secondary, + [theme.breakpoints.down('sm')]: { + width: '100%', + }, +})); + +export const DaoProposalContainer = styled(Box)(({ theme }) => ({ + width: '70%', + display: 'flex', + flexDirection: 'column', + justifyContent: 'flex-start', + padding: '0 32px', + minHeight: '500px', + borderRadius: theme.palette.primary.borderRadius, + background: theme.palette.background.secondary, + [theme.breakpoints.down('sm')]: { + width: '100%', + padding: '0 20px', + }, +})); + +export const DaoProposalHead = styled(Box)(({ theme }) => ({ + display: 'flex', + alignItems: 'center', + alignSelf: 'flex-start', + justifyContent: 'space-between', + padding: '15px 0px', + width: '100%', + margin: '5px', + [theme.breakpoints.down('sm')]: { + padding: '0px', + }, +})) + +export const DaoProposalListContainer = styled(Box)(({ theme }) => ({ + overflowY: 'auto', + margin: '10px auto', + borderRadius: '8px', + padding: '20px 10px', + width: '100%', + height: '600px', + '.loadingContainer' : { + padding: '10px auto', + }, + [theme.breakpoints.down('sm')]: { + padding: '0px', + }, +})) + +export const DaoWalletAction = styled(Box)(({ theme }) => ({ + display: 'flex', + justifyContent: 'space-around', + width: '100%', + margin: '10px auto', + gap: '10px', +})); diff --git a/packages/boba/gateway/src/containers/home/Home.js b/packages/boba/gateway/src/containers/home/Home.js index c000445c06..3757f46e0b 100644 --- a/packages/boba/gateway/src/containers/home/Home.js +++ b/packages/boba/gateway/src/containers/home/Home.js @@ -68,7 +68,7 @@ import FarmDepositModal from 'containers/modals/farm/FarmDepositModal' import FarmWithdrawModal from 'containers/modals/farm/FarmWithdrawModal' import DelegateDaoModal from 'containers/modals/dao/DelegateDaoModal' import DelegateDaoXModal from 'containers/modals/dao/DelegateDaoXModal' -import NewProposalModal from 'containers/modals/dao/NewProposalModal' +import NewProposalModal from 'containers/modals/dao/old/NewProposalModalOldDao' import CastVoteModal from 'containers/modals/dao/CastVoteModal' import TokenPickerModal from 'containers/modals/tokenPicker/TokenPickerModal' import TransferPendingModal from 'containers/modals/transferPending/TransferPending' diff --git a/packages/boba/gateway/src/containers/modals/dao/old/NewProposalModalOldDao.js b/packages/boba/gateway/src/containers/modals/dao/old/NewProposalModalOldDao.js new file mode 100644 index 0000000000..4bfddb550e --- /dev/null +++ b/packages/boba/gateway/src/containers/modals/dao/old/NewProposalModalOldDao.js @@ -0,0 +1,268 @@ +/* +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, { useState } from 'react' +import { Box, Typography } from '@mui/material' + +import { useDispatch, useSelector } from 'react-redux' +import { closeModal, openAlert } from 'actions/uiAction' +import Modal from 'components/modal/Modal' +import Button from 'components/button/Button' +import Input from 'components/input/Input' +// import Select from 'react-select' +import Select from 'components/select/Select' + +import { createDaoProposal } from 'actions/daoAction' +import { selectProposalThreshold } from 'selectors/daoSelector' +import BobaGlassIcon from 'components/icons/BobaGlassIcon' + +function NewProposalModal({ open }) { + + const dispatch = useDispatch() + + const [ action, setAction ] = useState('') + const [ votingThreshold, setVotingThreshold ] = useState('') + + const [ LPfeeMin, setLPfeeMin ] = useState('') + const [ LPfeeMax, setLPfeeMax ] = useState('') + const [ LPfeeOwn, setLPfeeOwn ] = useState('') + + const [ proposeText, setProposeText ] = useState('') + const [ proposalUri, setProposalUri ] = useState('') + + const loading = false //ToDo useSelector(selectLoading([ 'PROPOSAL_DAO/CREATE' ])) + + + const proposalThreshold = useSelector(selectProposalThreshold) + + const onActionChange = (e) => { + setVotingThreshold('') + setLPfeeMin('') + setLPfeeMax('') + setLPfeeOwn('') + setProposeText('') + setProposalUri('') + setAction(e.target.value) + } + + function handleClose() { + setVotingThreshold('') + setLPfeeMin('') + setLPfeeMax('') + setLPfeeOwn('') + setAction('') + setProposeText('') + setProposalUri('') + dispatch(closeModal('newProposalModal')) + } + + const options = [ + { value: 'change-threshold', label: 'Change Voting Threshold', title: 'Change Voting Threshold' }, + { value: 'text-proposal', label: 'Freeform Text Proposal', title: 'Freeform Text Proposal' }, + { value: 'change-lp1-fee', label: 'Change L1 LP fees', title: 'Change L1 LP fees' }, + { value: 'change-lp2-fee', label: 'Change L2 LP fees', title: 'Change L2 LP fees' } + ] + + const customStyles = { + option: (provided, state) => ({ + ...provided, + color: state.isSelected ? '#282828' : '#909090', + }), + } + + const submit = async () => { + + let res = null + + if (action === 'change-threshold') { + res = await dispatch(createDaoProposal({ + action, + value: [ votingThreshold ], + text: '' //extra text if any + })) + } else if (action === 'text-proposal') { + res = await dispatch(createDaoProposal({ + action, + text: `${proposeText}@@${proposalUri}` + })) + } else if (action === 'change-lp1-fee' || action === 'change-lp2-fee') { + res = await dispatch(createDaoProposal({ + action, + value: [ Math.round(Number(LPfeeMin) * 10), Math.round(Number(LPfeeMax) * 10), Math.round(Number(LPfeeOwn) * 10) ], + text: '' //extra text if any + })) + } + + if (res) { + dispatch(openAlert(`Proposal has been submitted. It will be listed soon`)) + } + handleClose() + } + + const disabled = () => { + if (action === 'change-threshold') { + return !votingThreshold + } else if (action === 'text-proposal') { + return !proposeText + } else if (action === 'change-lp1-fee' || action === 'change-lp2-fee') { + if (Number(LPfeeMin) < 0.0 || Number(LPfeeMin) > 5.0) { + return true //aka disabled + } + if (Number(LPfeeMax) < 0.0 || Number(LPfeeMax) > 5.0) { + return true //aka disabled + } + if (Number(LPfeeMax) <= Number(LPfeeMin)) { + return true //aka disabled + } + if (Number(LPfeeOwn) < 0.0 || Number(LPfeeOwn) > 5.0) { + return true + } + if (LPfeeMin === '') { + return true + } + if (LPfeeMax === '') { + return true + } + if (LPfeeOwn === '') { + return true + } + return false + } + } + + return ( + + + + + + New Proposal + + + + + {action === '' && + + Currently, the DAO can change the voting threshold, propose free-form text proposals, and + change to the bridge fee limits for the L1 and L2 bridge pools. + + } + + {action === 'change-threshold' && + <> + + The minimum number of votes required for an account to create a proposal. The current value is {proposalThreshold}. + + setVotingThreshold(i.target.value)} + fullWidth + sx={{ marginBottom: '20px' }} + /> + + } + {(action === 'change-lp1-fee' || action === 'change-lp2-fee') && + <> + + Possible settings range from 0.0% to 5.0%. + All three values must be specified and the maximum fee must be larger than the minimum fee. + + setLPfeeMin(i.target.value)} + fullWidth + /> + setLPfeeMax(i.target.value)} + fullWidth + /> + setLPfeeOwn(i.target.value)} + fullWidth + /> + + } + {action === 'text-proposal' && + <> + + Your proposal title is limited to 100 characters. Use the link field below to provide more information. + + setProposeText(i.target.value.slice(0, 100))} + /> + + You should provide additional information (technical specifications, diagrams, forum threads, and other material) on a seperate + website. The link length is limited to 150 characters. You may need to use a link shortener. + + setProposalUri(i.target.value.slice(0, 150))} + /> + + } + + + + + + + ) +} + +export default React.memo(NewProposalModal) diff --git a/packages/boba/gateway/src/containers/wallet/token/Token.js b/packages/boba/gateway/src/containers/wallet/token/Token.js index 71a647ed9f..5dcb9ddb32 100644 --- a/packages/boba/gateway/src/containers/wallet/token/Token.js +++ b/packages/boba/gateway/src/containers/wallet/token/Token.js @@ -32,6 +32,7 @@ import networkService from 'services/networkService' import { Md5 } from "ts-md5/dist/md5" import { useNavigate } from 'react-router-dom' +import { TESTNET_NETWORK_NAME } from 'util/constant' function TokenPage() { diff --git a/packages/boba/gateway/src/layout/index.js b/packages/boba/gateway/src/layout/index.js index 0fc5779825..4148030f58 100644 --- a/packages/boba/gateway/src/layout/index.js +++ b/packages/boba/gateway/src/layout/index.js @@ -39,8 +39,10 @@ import Lock from 'containers/veboba/Lock' import FarmWrapper from 'containers/farm/FarmWrapper' import SaveWrapper from 'containers/save/SaveWrapper' import Projects from 'containers/ecosystem/Projects' -import { ROUTES_PATH } from 'util/constant' +import { DISABLE_VE_DAO, ROUTES_PATH } from 'util/constant' import VoteAndDao from 'containers/VoteAndDao' +import Dao from 'containers/VoteAndDao/Dao/Dao' +import OldDao from 'containers/dao/OldDao' function App() { @@ -298,14 +300,17 @@ function App() { } /> } /> } /> - } /> + } /> } /> } /> } > } /> - } /> + {/* FIXME: On setting flag below to 1 below routes will not be available to user. */} + {!Number(DISABLE_VE_DAO) && } />} + {!Number(DISABLE_VE_DAO) && } />} + } /> } /> diff --git a/packages/boba/gateway/src/services/graphQLService.js b/packages/boba/gateway/src/services/graphQLService.js index 6931c9944c..de72a21911 100644 --- a/packages/boba/gateway/src/services/graphQLService.js +++ b/packages/boba/gateway/src/services/graphQLService.js @@ -1,6 +1,6 @@ import { ApolloClient, gql, HttpLink, InMemoryCache } from '@apollo/client'; import fetch from 'cross-fetch'; -import { APP_CHAIN } from 'util/constant' +import { APP_CHAIN, TESTNET_NETWORK_NAME } from 'util/constant' class GraphQLService { @@ -16,7 +16,7 @@ class GraphQLService { async queryBridgeProposalCreated() { - const query = gql(`query { governorProposalCreateds { proposalId values description proposer to startTimestamp endTimestamp proposer } }`) + const query = gql(`query { governorProposalCreateds { proposalId values description proposer } }`) /* curl -g -X POST \ diff --git a/packages/boba/gateway/src/services/networkService.js b/packages/boba/gateway/src/services/networkService.js index 9b48ed61a5..6f8630d986 100644 --- a/packages/boba/gateway/src/services/networkService.js +++ b/packages/boba/gateway/src/services/networkService.js @@ -3885,6 +3885,10 @@ class NetworkService { } // Create Proposal + /************************/ + /*****Old Dao Fix Me.****/ + /************************/ + // FIXME: async createProposal(payload) { if( this.L1orL2 !== 'L2' ) return @@ -3901,10 +3905,17 @@ class NetworkService { let value3 = 0 let description = '' let address = [''] - let callData = [''] - let tokenIds = payload.tokenIds - // create proposal only on latest contracts. - const delegateCheck = await this.delegateContract.attach(allAddresses.GovernorBravoDelegatorV2) + let callData = [ '' ] + // FIXME: Ve DAO From here + /* + let tokenIds = payload.tokenIds + // create proposal only on latest contracts. + const delegateCheck = await this.delegateContract.attach(allAddresses.GovernorBravoDelegatorV2) + + */ + // FIXME: Ve DAO Till here + + const delegateCheck = await this.delegateContract.attach(allAddresses.GovernorBravoDelegator) if( payload.action === 'text-proposal' ) { address = ['0x000000000000000000000000000000000000dEaD'] @@ -3957,7 +3968,6 @@ class NetworkService { values, signatures, callData, - tokenIds, description ) @@ -3975,8 +3985,8 @@ class NetworkService { * group created proposals by `to` and make use of respective contract to prepare the proposal data list. * */ - - async fetchProposals() { + // Use this proposal fetch for veDao. + async fetchProposalsVeDao() { if (!this.delegateContract || this.networkGateway === 'goerli') return @@ -4089,8 +4099,11 @@ class NetworkService { } } + + //Cast vote for proposal - async castProposalVote({id, userVote,tokenIds}) { + // FIXME: keeping this to refer in next release will cleanup. + async castProposalVoteVeDao({id, userVote,tokenIds}) { if( !this.delegateContract ) return @@ -5069,6 +5082,117 @@ class NetworkService { } } + /**************************************** + ************* STARTS HERE ************** + ***********OLD DAO REMOVE ME *********** + *****************************************/ + + // FIXME: remove me once deprecated old dao. + + async fetchProposals() { + + if (!this.delegateContract) return + + const delegateCheck = await this.delegateContract.attach(allAddresses.GovernorBravoDelegator) + + try { + + let proposalList = [] + + const proposalCounts = await delegateCheck.proposalCount() + const totalProposals = await proposalCounts.toNumber() + + /// @notice An event emitted when a new proposal is created + // event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startTimestamp, uint endTimestamp, string description); + + let descriptionList = await GraphQLService.queryBridgeProposalCreated() + + for (let i = 0; i < totalProposals; i++) { + const proposalRaw = descriptionList.data.governorProposalCreateds[i] + + if(typeof(proposalRaw) === 'undefined') continue + + let proposalID = proposalRaw.proposalId + + //this is a number such as 2 + let proposalData = await delegateCheck.proposals(proposalID) + + const proposalStates = [ + 'Pending', + 'Active', + 'Canceled', + 'Defeated', + 'Succeeded', + 'Queued', + 'Expired', + 'Executed', + ] + + let state = await delegateCheck.state(proposalID) + + let againstVotes = parseInt(formatEther(proposalData.againstVotes)) + let forVotes = parseInt(formatEther(proposalData.forVotes)) + let abstainVotes = parseInt(formatEther(proposalData.abstainVotes)) + + let startTimestamp = proposalData.startTimestamp.toString() + let endTimestamp = proposalData.endTimestamp.toString() + + let proposal = await delegateCheck.getActions(i+2) + + let hasVoted = null + + let description = proposalRaw.description.toString() + + proposalList.push({ + id: proposalID?.toString(), + proposal, + description, + totalVotes: forVotes + againstVotes, + forVotes, + againstVotes, + abstainVotes, + state: proposalStates[state], + startTimestamp, + endTimestamp, + hasVoted: hasVoted + }) + + } + return { proposalList } + } catch(error) { + console.log("NS: fetchProposals error:",error) + return error + } + } + + + async castProposalVote({id, userVote}) { + + if( !this.delegateContract ) return + + if( !this.account ) { + console.log('NS: castProposalVote() error - called but account === null') + return + } + try { + const delegateCheck = await this.delegateContract + .connect(this.provider.getSigner()) + .attach(allAddresses.GovernorBravoDelegator) + return delegateCheck.castVote(id, userVote) + } catch(error) { + console.log("NS: castProposalVote error:",error) + return error + } + } + + + /**************************************** + ************* END HERE ***************** + ***********OLD DAO REMOVE ME TILL HERE * + *****************************************/ + + + } const networkService = new NetworkService() diff --git a/packages/boba/gateway/src/util/constant.js b/packages/boba/gateway/src/util/constant.js index e408c30eb0..1da1ee477f 100644 --- a/packages/boba/gateway/src/util/constant.js +++ b/packages/boba/gateway/src/util/constant.js @@ -23,6 +23,22 @@ export const SERVICE_OPTIMISM_API_URL = process.env.REACT_APP_SERVICE_OPTIMISM_A export const SPEED_CHECK = process.env.REACT_APP_SPEED_CHECK export const TARGET_CHAIN_URL = process.env.REACT_APP_TARGET_CHAIN_URL +// Testnet Constants Configs. +export const TESTNET_NETWORK_NAME = process.env.REACT_APP_TESTNET_NETWORK_NAME + +export const TESTNET_L1_NAME= process.env.REACT_APP_RINKEBY_L1_NAME +export const TESTNET_L1_CHAIN_ID= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID +export const TESTNET_L1_CHAIN_ID_HEX= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID_HEX +export const TESTNET_L1_RPC_URL = process.env.REACT_APP_RINKEBY_L1_RPC_URL +export const TESTNET_L1_BLOCK_EXPLORER = process.env.REACT_APP_TESTNET_L1_BLOCK_EXPLORER +export const TESTNET_L1_TRANSACTION = process.env.REACT_APP_TESTNET_L1_TRANSACTION +export const DISABLE_VE_DAO = process.env.REACT_APP_DISABLE_VE_DAO + + +export const TESTNET_OMG_WATCHER_URL = process.env.REACT_APP_TESTNET_OMGX_WATCHER_URL +export const TESTNET_VERIFIER_WATCHER_URL = process.env.REACT_APP_TESTNET_VERIFIER_WATCHER_URL +export const TESTNET_MM_LABEL = process.env.REACT_APP_TESTNET_MM_LABEL + export const BRIDGE_TYPE = { FAST_BRIDGE: "FAST_BRIDGE", CLASSIC_BRIDGE: "CLASSIC_BRIDGE", @@ -68,5 +84,6 @@ export const ROUTES_PATH = { BOBASCOPE: '/bobascope', MONSTER: '/monster', VOTE_DAO: '/votedao', + DAO: '/DAO', } export const PER_PAGE = 8 From e7253ee791b184f50b7235d05dc8ff4c9c148404 Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar Date: Sat, 19 Nov 2022 15:09:00 +0530 Subject: [PATCH 2/4] cleaning up the old dao --- .../src/containers/VoteAndDao/Dao/Dao.js | 4 +--- .../boba/gateway/src/containers/dao/OldDao.js | 23 ++++--------------- packages/boba/gateway/src/layout/index.js | 1 - 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js b/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js index d7638b41fb..33b52ce663 100644 --- a/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js +++ b/packages/boba/gateway/src/containers/VoteAndDao/Dao/Dao.js @@ -49,9 +49,7 @@ const PROPOSAL_STATES = [ { value: 'Executed', label: 'Executed' } ] -function DAO({ - -}) { +function DAO() { const dispatch = useDispatch() diff --git a/packages/boba/gateway/src/containers/dao/OldDao.js b/packages/boba/gateway/src/containers/dao/OldDao.js index 870f92870e..706003d48e 100644 --- a/packages/boba/gateway/src/containers/dao/OldDao.js +++ b/packages/boba/gateway/src/containers/dao/OldDao.js @@ -13,7 +13,7 @@ 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 React, { useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { Box, Typography } from '@mui/material' @@ -25,16 +25,12 @@ import ListProposal from 'components/listProposal/listProposal' import Select from 'components/select/Select' -import { selectDaoBalance, selectDaoBalanceX, selectDaoVotes, selectDaoVotesX, selectLatestProposalState, selectProposals, selectProposalThreshold } from 'selectors/daoSelector' +import { selectDaoBalance, selectDaoBalanceX, selectDaoVotes, selectDaoVotesX, selectProposals, selectProposalThreshold } from 'selectors/daoSelector' import { selectLoading } from 'selectors/loadingSelector' import { selectAccountEnabled, selectLayer } from 'selectors/setupSelector' -import { selectLockRecords } from 'selectors/veBobaSelector' - - import * as G from 'containers/Global.styles' import * as S from './OldDao.styles' -import { setConnectBOBA } from 'actions/setupAction' import PageTitle from 'components/pageTitle/PageTitle' import Connect from 'containers/connect/Connect' @@ -50,19 +46,17 @@ const PROPOSAL_STATES = [ { value: 'Executed', label: 'Executed' } ] -function OldDao({ - -}) { +function OldDao() { const dispatch = useDispatch() + const accountEnabled = useSelector(selectAccountEnabled()) const layer = useSelector(selectLayer()); - const loading = useSelector(selectLoading()); + const loading = useSelector(selectLoading([ 'PROPOSALS/GET' ])) let proposals = useSelector(selectProposals) proposals = orderBy(proposals, i => i.startTimestamp, 'desc') - // const [ balance, setBalance ] = useState('--'); const balance = useSelector(selectDaoBalance) const balanceX = useSelector(selectDaoBalanceX) const votes = useSelector(selectDaoVotes) @@ -71,13 +65,6 @@ function OldDao({ const [ selectedState, setSelectedState ] = useState(PROPOSAL_STATES[ 0 ]) - // useEffect(() => { - // if (!!accountEnabled) { - // const veBoba = nftRecords.reduce((s, record) => s + Number(record.balance), 0); - // setBalance(veBoba.toFixed(2)) - // } - // }, [ accountEnabled, nftRecords ]); - return ( diff --git a/packages/boba/gateway/src/layout/index.js b/packages/boba/gateway/src/layout/index.js index 4148030f58..28084db986 100644 --- a/packages/boba/gateway/src/layout/index.js +++ b/packages/boba/gateway/src/layout/index.js @@ -41,7 +41,6 @@ import SaveWrapper from 'containers/save/SaveWrapper' import Projects from 'containers/ecosystem/Projects' import { DISABLE_VE_DAO, ROUTES_PATH } from 'util/constant' import VoteAndDao from 'containers/VoteAndDao' -import Dao from 'containers/VoteAndDao/Dao/Dao' import OldDao from 'containers/dao/OldDao' function App() { From a1f74a5c86262d19946994f7c9400d20c96c743d Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar Date: Mon, 21 Nov 2022 12:53:40 +0530 Subject: [PATCH 3/4] cleanup for testnet name. --- packages/boba/gateway/.env.example | 1 - packages/boba/gateway/src/api/etherScanAxios.js | 1 - packages/boba/gateway/src/api/metaTransactionAxios.js | 1 - packages/boba/gateway/src/api/omgxWatcherAxios.js | 1 - packages/boba/gateway/src/api/verifierWatcherAxios.js | 1 - packages/boba/gateway/src/containers/wallet/token/Token.js | 1 - packages/boba/gateway/src/services/graphQLService.js | 2 +- packages/boba/gateway/src/util/constant.js | 2 -- 8 files changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/boba/gateway/.env.example b/packages/boba/gateway/.env.example index ef7772f964..fa10e67b9c 100644 --- a/packages/boba/gateway/.env.example +++ b/packages/boba/gateway/.env.example @@ -16,7 +16,6 @@ REACT_APP_ZENDESK_KEY= ## KEY for the zendesk widget. ############################### #### TESTNET CHAIN CONFIG ##### ############################### -REACT_APP_TESTNET_NETWORK_NAME=rinkeby REACT_APP_TESTNET_L1_NAME=Rinkeby REACT_APP_TESTNET_L1_CHAIN_ID=4 diff --git a/packages/boba/gateway/src/api/etherScanAxios.js b/packages/boba/gateway/src/api/etherScanAxios.js index 164c747aed..698333e3b9 100644 --- a/packages/boba/gateway/src/api/etherScanAxios.js +++ b/packages/boba/gateway/src/api/etherScanAxios.js @@ -1,5 +1,4 @@ import axios from 'axios' -import { TESTNET_NETWORK_NAME } from 'util/constant'; import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/api/metaTransactionAxios.js b/packages/boba/gateway/src/api/metaTransactionAxios.js index cbd2d329ee..8f0bc37044 100644 --- a/packages/boba/gateway/src/api/metaTransactionAxios.js +++ b/packages/boba/gateway/src/api/metaTransactionAxios.js @@ -1,5 +1,4 @@ import axios from 'axios' -import { TESTNET_NETWORK_NAME } from 'util/constant'; import { getBaseServices } from 'util/masterConfig' export default function metaTransactionAxiosInstance(networkGateway){ diff --git a/packages/boba/gateway/src/api/omgxWatcherAxios.js b/packages/boba/gateway/src/api/omgxWatcherAxios.js index 962723647c..f313540d3e 100644 --- a/packages/boba/gateway/src/api/omgxWatcherAxios.js +++ b/packages/boba/gateway/src/api/omgxWatcherAxios.js @@ -1,5 +1,4 @@ import axios from 'axios' -import { TESTNET_NETWORK_NAME } from 'util/constant' import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/api/verifierWatcherAxios.js b/packages/boba/gateway/src/api/verifierWatcherAxios.js index 2164e13c47..270aa035b6 100644 --- a/packages/boba/gateway/src/api/verifierWatcherAxios.js +++ b/packages/boba/gateway/src/api/verifierWatcherAxios.js @@ -1,5 +1,4 @@ import axios from 'axios' -import { TESTNET_NETWORK_NAME } from 'util/constant' import { getNetwork } from 'util/masterConfig' const nw = getNetwork() diff --git a/packages/boba/gateway/src/containers/wallet/token/Token.js b/packages/boba/gateway/src/containers/wallet/token/Token.js index 5dcb9ddb32..71a647ed9f 100644 --- a/packages/boba/gateway/src/containers/wallet/token/Token.js +++ b/packages/boba/gateway/src/containers/wallet/token/Token.js @@ -32,7 +32,6 @@ import networkService from 'services/networkService' import { Md5 } from "ts-md5/dist/md5" import { useNavigate } from 'react-router-dom' -import { TESTNET_NETWORK_NAME } from 'util/constant' function TokenPage() { diff --git a/packages/boba/gateway/src/services/graphQLService.js b/packages/boba/gateway/src/services/graphQLService.js index de72a21911..bba8990b7b 100644 --- a/packages/boba/gateway/src/services/graphQLService.js +++ b/packages/boba/gateway/src/services/graphQLService.js @@ -1,6 +1,6 @@ import { ApolloClient, gql, HttpLink, InMemoryCache } from '@apollo/client'; import fetch from 'cross-fetch'; -import { APP_CHAIN, TESTNET_NETWORK_NAME } from 'util/constant' +import { APP_CHAIN } from 'util/constant' class GraphQLService { diff --git a/packages/boba/gateway/src/util/constant.js b/packages/boba/gateway/src/util/constant.js index 1da1ee477f..de2009c3ac 100644 --- a/packages/boba/gateway/src/util/constant.js +++ b/packages/boba/gateway/src/util/constant.js @@ -24,8 +24,6 @@ export const SPEED_CHECK = process.env.REACT_APP_SPEED_CHECK export const TARGET_CHAIN_URL = process.env.REACT_APP_TARGET_CHAIN_URL // Testnet Constants Configs. -export const TESTNET_NETWORK_NAME = process.env.REACT_APP_TESTNET_NETWORK_NAME - export const TESTNET_L1_NAME= process.env.REACT_APP_RINKEBY_L1_NAME export const TESTNET_L1_CHAIN_ID= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID export const TESTNET_L1_CHAIN_ID_HEX= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID_HEX From 162a848e0116ea52bfe256d9498bca1bb2c92137 Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar Date: Mon, 21 Nov 2022 13:02:20 +0530 Subject: [PATCH 4/4] .env cleanup and menu fix for vote and dao --- packages/boba/gateway/.env.example | 15 --------------- .../components/mainMenu/menuItems/MenuItems.js | 2 +- packages/boba/gateway/src/util/constant.js | 14 +------------- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/packages/boba/gateway/.env.example b/packages/boba/gateway/.env.example index fa10e67b9c..f3850d3187 100644 --- a/packages/boba/gateway/.env.example +++ b/packages/boba/gateway/.env.example @@ -13,21 +13,6 @@ REACT_APP_SENTRY_DSN= REACT_APP_ENABLE_LOCK_PAGE= # values can be 0 and 1 REACT_APP_ZENDESK_KEY= ## KEY for the zendesk widget. -############################### -#### TESTNET CHAIN CONFIG ##### -############################### - -REACT_APP_TESTNET_L1_NAME=Rinkeby -REACT_APP_TESTNET_L1_CHAIN_ID=4 -REACT_APP_TESTNET_L1_CHAIN_ID_HEX=0x4 -REACT_APP_TESTNET_L1_RPC_URL=https://rpc.ankr.com/eth_rinkeby -REACT_APP_TESTNET_L1_BLOCK_EXPLORER=https://api-rinkeby.etherscan.io/api?module=account&action=txlist&startblock=0&endblock=99999999&sort=asc&apikey= -REACT_APP_TESTNET_L1_TRANSACTION=https://rinkeby.etherscan.io/tx/ - -REACT_APP_TESTNET_OMGX_WATCHER_URL=https://api-watcher.rinkeby.boba.network/ -REACT_APP_TESTNET_VERIFIER_WATCHER_URL=https://api-verifier.rinkeby.boba.network/ -REACT_APP_TESTNET_MM_LABEL=Rinkeby - ################ ### Ve Dao ##### ################ diff --git a/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js b/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js index 7c38905110..fbaaa017b8 100644 --- a/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js +++ b/packages/boba/gateway/src/components/mainMenu/menuItems/MenuItems.js @@ -36,7 +36,7 @@ const MenuItems = () => { return ( {menuList.map((item) => { - if (!!Number(DISABLE_VE_DAO) && (['Lock'].includes(item.key))) { + if (!!Number(DISABLE_VE_DAO) && (['Lock','Vote&Dao'].includes(item.key))) { return null; } return ( diff --git a/packages/boba/gateway/src/util/constant.js b/packages/boba/gateway/src/util/constant.js index de2009c3ac..c2e04835c3 100644 --- a/packages/boba/gateway/src/util/constant.js +++ b/packages/boba/gateway/src/util/constant.js @@ -22,21 +22,9 @@ export const SELLER_OPTIMISM_API_URL = process.env.REACT_APP_SELLER_OPTIMISM_API export const SERVICE_OPTIMISM_API_URL = process.env.REACT_APP_SERVICE_OPTIMISM_API_URL export const SPEED_CHECK = process.env.REACT_APP_SPEED_CHECK export const TARGET_CHAIN_URL = process.env.REACT_APP_TARGET_CHAIN_URL - -// Testnet Constants Configs. -export const TESTNET_L1_NAME= process.env.REACT_APP_RINKEBY_L1_NAME -export const TESTNET_L1_CHAIN_ID= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID -export const TESTNET_L1_CHAIN_ID_HEX= process.env.REACT_APP_RINKEBY_L1_CHAIN_ID_HEX -export const TESTNET_L1_RPC_URL = process.env.REACT_APP_RINKEBY_L1_RPC_URL -export const TESTNET_L1_BLOCK_EXPLORER = process.env.REACT_APP_TESTNET_L1_BLOCK_EXPLORER -export const TESTNET_L1_TRANSACTION = process.env.REACT_APP_TESTNET_L1_TRANSACTION +// VE DAO FLAG export const DISABLE_VE_DAO = process.env.REACT_APP_DISABLE_VE_DAO - -export const TESTNET_OMG_WATCHER_URL = process.env.REACT_APP_TESTNET_OMGX_WATCHER_URL -export const TESTNET_VERIFIER_WATCHER_URL = process.env.REACT_APP_TESTNET_VERIFIER_WATCHER_URL -export const TESTNET_MM_LABEL = process.env.REACT_APP_TESTNET_MM_LABEL - export const BRIDGE_TYPE = { FAST_BRIDGE: "FAST_BRIDGE", CLASSIC_BRIDGE: "CLASSIC_BRIDGE",