Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update db dump #1888

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified scripts/development.dump
Binary file not shown.
65 changes: 1 addition & 64 deletions src/entities/Proposal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ import {
import 'isomorphic-fetch'
import numeral from 'numeral'

import { Governance } from '../../clients/Governance'
import { GOVERNANCE_URL } from '../../constants'
import { getEnumDisplayName } from '../../helpers'
import { getTile } from '../../utils/Land'
import Time from '../../utils/date/Time'
import { SNAPSHOT_SPACE, SNAPSHOT_URL } from '../Snapshot/constants'
import { SNAPSHOT_URL } from '../Snapshot/constants'
import { isSameAddress } from '../Snapshot/utils'
import { UpdateAttributes } from '../Updates/types'
import { DISCOURSE_API } from '../User/utils'
import { VotesForProposals } from '../Votes/types'

import { MAX_NAME_SIZE, MIN_NAME_SIZE } from './constants'
import {
CatalystType,
PoiType,
PriorityProposal,
PriorityProposalType,
ProposalAttributes,
ProposalStatus,
ProposalType,
SortingOrder,
isCatalystType,
isPoiType,
isProposalType,
isSortingOrder,
} from './types'
Expand All @@ -51,14 +45,6 @@ export function isValidName(name: string) {
return REGEX_NAME.test(name)
}

export function isValidDomainName(domain: string) {
return new RegExp('^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$').test(domain)
}

export async function isValidImage(imageUrl: string) {
return await Governance.get().checkImage(imageUrl)
}

export function isAlreadyBannedName(name: string) {
return !!getNameDenylistFromCache('mainnet').find(
(bannedName: string) => bannedName.toLowerCase() === name.toLowerCase()
Expand Down Expand Up @@ -136,12 +122,6 @@ export function forumUrl(
return target.toString()
}

export function forumUserUrl(username: string) {
const target = new URL(DISCOURSE_API || '')
target.pathname = `/u/${username}`
return target.toString()
}

export function governanceUrl(pathname = '') {
const target = new URL(GOVERNANCE_URL)
target.pathname = `/governance${pathname}`
Expand All @@ -158,29 +138,10 @@ export function proposalUrl(id: ProposalAttributes['id']) {
return target.toString()
}

export const EDIT_DELEGATE_SNAPSHOT_URL = snapshotUrl(`#/delegate/${SNAPSHOT_SPACE}`)

export function userModifiedForm(stateValue?: Record<string, unknown>, initialState?: Record<string, unknown>) {
if (!stateValue || !initialState) {
return false
}
const isInitialState = JSON.stringify(stateValue) === JSON.stringify(initialState)
return !isInitialState && Object.values(stateValue).some((value) => !!value)
}

export function isProposalInCliffPeriod(enactedDate: number) {
const now = Time.utc()
return Time.unix(enactedDate).add(CLIFF_PERIOD_IN_DAYS, 'day').isAfter(now)
}

export function isGovernanceProcessProposal(type: ProposalType) {
return type === ProposalType.Poll || type === ProposalType.Draft || type === ProposalType.Governance
}

export function isBiddingAndTenderingProposal(type: ProposalType) {
return type === ProposalType.Pitch || type === ProposalType.Tender || type === ProposalType.Bid
}

export function isProposalStatus(value: string | null | undefined): boolean {
switch (value) {
case ProposalStatus.Pending:
Expand Down Expand Up @@ -209,18 +170,10 @@ export function toProposalStatus<OrElse>(value: string | null | undefined, orEls
return toCustomType<ProposalStatus, OrElse, typeof value>(value, isProposalStatus, orElse)
}

export function toCatalystType<OrElse>(value: string | null | undefined, orElse: () => OrElse) {
return toCustomType<CatalystType, OrElse, typeof value>(value, isCatalystType, orElse)
}

export function toProposalType<OrElse>(value: string | null | undefined, orElse: () => OrElse) {
return toCustomType<ProposalType, OrElse, typeof value>(value, isProposalType, orElse)
}

export function toPoiType<OrElse>(value: string | null | undefined, orElse: () => OrElse) {
return toCustomType<PoiType, OrElse, typeof value>(value, isPoiType, orElse)
}

export function toSortingOrder<OrElse>(value: string | null | undefined, orElse: () => OrElse) {
return toCustomType<SortingOrder, OrElse, typeof value>(value, isSortingOrder, orElse)
}
Expand All @@ -245,10 +198,6 @@ export function getProposalEndDate(duration: number) {
return Time.utc().set('seconds', 0).add(duration, 'seconds').toDate()
}

export function getProposalStatusShortName(status: ProposalStatus) {
return status === ProposalStatus.OutOfBudget ? 'OOB' : getEnumDisplayName(status)
}

export function isGrantProposalSubmitEnabled(now: number) {
const ENABLE_START_DATE = Time.utc('2023-03-01').add(8, 'hour')
return !Time(now).isBefore(ENABLE_START_DATE)
Expand All @@ -272,18 +221,6 @@ export function hasTenderProcessStarted(tenderProposals?: ProposalAttributes[])
return !!tenderProposals && tenderProposals.length > 0 && Time(tenderProposals[0].start_at).isBefore(Time())
}

export function getBudget(proposal: ProposalAttributes) {
const { type, configuration } = proposal
switch (type) {
case ProposalType.Grant:
return Number(configuration.size)
case ProposalType.Bid:
return Number(configuration.funding)
default:
return null
}
}

export function getDisplayedPriorityProposals(
votes?: VotesForProposals,
priorityProposals?: PriorityProposal[],
Expand Down
Loading