-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress on governance card component
Fix for proposal search
- Loading branch information
Showing
8 changed files
with
120 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
export const DEFAULT_DISPLAY_DECIMALS = 2; | ||
export const DEFAULT_TOKEN_DECIMALS = 18; | ||
export const MIN_REMAINING_BALANCE = 10000000000000000n; // 0.01 CELO | ||
export const AVG_BLOCK_TIMES_MS = 5_000; // 5 seconds | ||
export const EPOCH_DURATION_MS = 86_400_000; // 1 day | ||
export const BALANCE_REFRESH_INTERVAL = 5_000; // 5 seconds | ||
|
||
// Locking | ||
export const MIN_REMAINING_BALANCE = 10000000000000000n; // 0.01 CELO | ||
|
||
// Staking | ||
export const MIN_GROUP_SCORE_FOR_RANDOM = 90; | ||
export const MIN_INCREMENTAL_VOTE_AMOUNT = 10000000000000000n; // 0.01 CELO | ||
|
||
// From the Election contract electableValidators config | ||
export const MAX_NUM_ELECTABLE_VALIDATORS = 110; | ||
export const MAX_NUM_GROUPS_VOTED_FOR = 10; | ||
|
||
// Governance | ||
export const QUEUED_STAGE_EXPIRY_TIME = 2_419_200_000; // 4 weeks | ||
export const APPROVAL_STAGE_EXPIRY_TIME = 86_400_000; // 1 day | ||
export const EXECUTION_STAGE_EXPIRY_TIME = 259_200_000; // 3 days |
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,49 @@ | ||
import Image from 'next/image'; | ||
import { StageBadge } from 'src/features/governance/StageBadge'; | ||
import { MergedProposalData } from 'src/features/governance/useGovernanceProposals'; | ||
import ClockIcon from 'src/images/icons/clock.svg'; | ||
import { trimToLength } from 'src/utils/strings'; | ||
import { getHumanReadableTimeString } from 'src/utils/time'; | ||
|
||
export function ProposalCard({ data }: { data: MergedProposalData }) { | ||
const { stage, proposal, metadata } = data; | ||
|
||
const { id, timestamp, expiryTimestamp, votes } = proposal || {}; | ||
const { title, timestamp: cgpTimestamp, timestampExecuted, cgp } = metadata || {}; | ||
|
||
const idValue = id ? `# ${id}` : cgp ? `CGP ${cgp}` : undefined; | ||
const titleValue = title ? trimToLength(title, 50) : undefined; | ||
const proposedTimestamp = timestamp || cgpTimestamp; | ||
const proposedTimeValue = proposedTimestamp | ||
? new Date(proposedTimestamp).toLocaleDateString() | ||
: undefined; | ||
const endTimestamp = timestampExecuted || expiryTimestamp; | ||
const endTimeValue = endTimestamp ? getHumanReadableTimeString(endTimestamp) : undefined; | ||
const endTimeLabel = timestampExecuted ? 'Executed' : 'Expires'; | ||
|
||
return ( | ||
<div className="space-y-2"> | ||
<div className="flex items-center space-x-3"> | ||
{idValue && ( | ||
<div className="rounded-full border border-taupe-300 px-2 py-0.5 text-sm font-light"> | ||
{idValue} | ||
</div> | ||
)} | ||
<StageBadge stage={stage} /> | ||
{proposedTimeValue && ( | ||
<div className="text-sm text-taupe-600">{`Proposed ${proposedTimeValue}`}</div> | ||
)} | ||
</div> | ||
{titleValue && <h3 className="text-xl font-medium">{titleValue}</h3>} | ||
{votes && ( | ||
<div className="text-sm text-taupe-600">{`Votes: ${votes.yes} Yes, ${votes.no} No, ${votes.abstain} Abstain`}</div> | ||
)} | ||
{endTimeValue && ( | ||
<div className="flex items-center space-x-2"> | ||
<Image src={ClockIcon} alt="" width={16} height={16} /> | ||
<div className="text-sm font-medium">{`${endTimeLabel} ${endTimeValue}`}</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
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,14 @@ | ||
import clsx from 'clsx'; | ||
import { ProposalStage, ProposalStageToStyle } from 'src/features/governance/contractTypes'; | ||
|
||
export function StageBadge({ stage, className }: { stage: ProposalStage; className?: string }) { | ||
const { color, label } = ProposalStageToStyle[stage]; | ||
return ( | ||
<div | ||
style={{ backgroundColor: color }} | ||
className={clsx('rounded-full px-2 py-0.5 text-sm font-light', className)} | ||
> | ||
{label} | ||
</div> | ||
); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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