Skip to content

Commit

Permalink
onchain dao etherlink
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshpw committed Dec 21, 2024
1 parent d1cd923 commit 8cbb96c
Show file tree
Hide file tree
Showing 10 changed files with 730 additions and 150 deletions.
5 changes: 5 additions & 0 deletions src/modules/etherlink/components/EvmDaoProposalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export const EvmDaoProposalList: React.FC<Props> = ({ proposals, showFullList =
const [isLoading, setIsLoading] = useState(false)

console.log("EvmDaoProposalList", proposals)
console.log(
"EvmDaoProposalListX",
proposals?.filter((p: any) => p.proposalData?.length > 0).map((p: any) => p.type)
)

const pageCount = Math.ceil(proposals ? proposals.length / offsetLimit : 0)

// Invoke when user click to request another page.
Expand Down
2 changes: 1 addition & 1 deletion src/modules/etherlink/components/EvmDaoSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const EvmDaoSettingModal: React.FC<{
value: daoSelected?.votingDelay
},
{
key: "Execution Delay (minutes)",
key: "Execution Delay (seconds)",
value: daoSelected?.executionDelay
}
]
Expand Down
11 changes: 8 additions & 3 deletions src/modules/etherlink/components/EvmProposalCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dayjs from "dayjs"
import React, { useContext, useEffect, useMemo, useState } from "react"
import { EtherlinkContext } from "services/wagmi/context"
import { GridContainer } from "modules/common/GridContainer"
import { ProposalStatus } from "services/services/dao/mappers/proposal/types"

interface TimeLeft {
days: number
Expand All @@ -30,8 +31,12 @@ export const EvmProposalCountdown = () => {
return "Time left to vote"
}

if (daoProposalSelected?.status === ProposalStatus.PASSED) {
return "Execution available in"
}

return "Voting concluded"
}, [votingStartTimestamp, votingExpiresAt])
}, [votingStartTimestamp, votingExpiresAt, daoProposalSelected?.status])

useEffect(() => {
const calculateTimeLeft = () => {
Expand Down Expand Up @@ -88,8 +93,8 @@ export const EvmProposalCountdown = () => {
)

return (
<GridContainer container direction="column" style={{ maxWidth: 200 }}>
<Box sx={{ display: "flex", alignItems: "center" }}>
<GridContainer container direction="column" style={{ maxWidth: "100%" }}>
<Box sx={{ display: "flex", alignItems: "center", margin: "auto", marginBottom: 2 }}>
<Timer sx={{ width: 24, height: 24, mr: 2, color: "white" }} />
<Typography variant="h3" color="white" sx={{ fontWeight: 600, fontSize: 18 }}>
{timerLabel}
Expand Down
Empty file.
15 changes: 5 additions & 10 deletions src/modules/etherlink/components/EvmProposalVoteDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import React, { useContext, useEffect, useMemo, useState } from "react"
import { Button, Grid, styled, Theme, Typography, useMediaQuery, useTheme } from "@material-ui/core"
import { GridContainer } from "modules/common/GridContainer"
import { VotesDialog } from "modules/lite/explorer/components/VotesDialog"
import { Poll } from "models/Polls"
import { Choice } from "models/Choice"
import ProgressBar from "react-customizable-progressbar"

import { useTezos } from "services/beacon/hooks/useTezos"
import { getTurnoutValue } from "services/utils/utils"
import { useTokenDelegationSupported } from "services/contracts/token/hooks/useTokenDelegationSupported"
import { DownloadCsvFile } from "modules/lite/explorer/components/DownloadCsvFile"
import { EtherlinkContext } from "services/wagmi/context"
import { LinearProgress } from "components/ui/LinearProgress"
import { formatNumber } from "modules/explorer/utils/FormatNumber"
import { useEvmDaoOps } from "services/contracts/etherlinkDAO/hooks/useEvmDaoOps"
import { EVM_PROPOSAL_CHOICES } from "../config"

const Container = styled(Grid)(({ theme }) => ({
background: theme.palette.primary.main,
Expand Down Expand Up @@ -93,12 +91,11 @@ const HistoryValue = styled(Typography)({

export const EvmProposalVoteDetail: React.FC<{
poll: Poll | undefined
choices: Choice[]
token: any
}> = ({ poll, choices, token }) => {
}> = ({ poll, token }) => {
const theme = useTheme()
const isMobileSmall = useMediaQuery(theme.breakpoints.down("xs"))

const choices = EVM_PROPOSAL_CHOICES
const { network } = useTezos()
const [turnout, setTurnout] = useState<number | null>()
const [votes, setVotes] = useState<Choice[]>([])
Expand All @@ -122,8 +119,6 @@ export const EvmProposalVoteDetail: React.FC<{
// setVotes(choices.filter(elem => elem.walletAddresses.length > 0))
}

console.log({ showProposalVoterList })

useMemo(async () => {
if (token && tokenData) {
const value = await getTurnoutValue(
Expand All @@ -139,7 +134,7 @@ export const EvmProposalVoteDetail: React.FC<{
}
}, [poll, network, token, tokenData, totalVoteCount])

const votesQuorumPercentage = 50
const votesQuorumPercentage = daoProposalSelected?.votesWeightPercentage

console.log({ daoProposalSelected })

Expand Down Expand Up @@ -278,7 +273,7 @@ export const EvmProposalVoteDetail: React.FC<{
/> */}
</GraphicsContainer>
</Container>
<Container container style={{ marginTop: 120, marginBottom: 12 }}>
<Container container style={{ marginTop: 60, marginBottom: 12 }}>
<Grid item container direction="column" spacing={8} style={{ paddingLeft: 12, paddingRight: 12 }}>
<Grid item container direction="row" spacing={8}>
{/* Quorum */}
Expand Down
19 changes: 19 additions & 0 deletions src/modules/etherlink/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,44 +100,63 @@ export const EvmProposalOptions = [
}
]

// TODO: Ensure tags are unique
export const proposalInterfaces = [
{
tags: ["registry"],
interface: ["function editRegistry(string key, string Value)"],
name: "editRegistry"
},
{
tags: ["token"],
interface: ["function mint(address to, uint256 amount)"],
name: "mint"
},
{
tags: ["token"],
interface: ["function burn(address from, uint256 amount)"],
name: "burn"
},
{
tags: ["transfer"],
interface: ["function transferETH(address to, uint256 amount)"],
name: "transferETH"
},
{
tags: ["token", "mint", "burn"],
interface: ["function transferERC20(address token, address to, uint256 amount)"],
name: "transferERC20"
},
{
tags: ["token"],
interface: ["function transferERC721(address token, address to, uint256 tokenId)"],
name: "transferERC721"
},
{
tags: ["quorum"],
label: "Update Quorum",
unit: "%",
interface: ["function updateQuorumNumerator(uint256 newQuorumNumerator)"],
name: "updateQuorumNumerator"
},
{
tags: ["voting delay"],
label: "Update Voting Delay",
unit: "seconds",
interface: ["function setVotingDelay(uint256 newVotingDelay)"],
name: "setVotingDelay"
},
{
tags: ["voting period"],
label: "Update Voting Period",
unit: "seconds",
interface: ["function setVotingPeriod(uint256 newVotingPeriod)"],
name: "setVotingPeriod"
},
{
tags: ["proposal threshold"],
label: "Update Proposal Threshold",
unit: "tokens",
interface: ["function setProposalThreshold(uint256 newProposalThreshold)"],
name: "setProposalThreshold"
}
Expand Down
Loading

0 comments on commit 8cbb96c

Please sign in to comment.