Skip to content

Commit

Permalink
chore: clean envs and types
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp committed Apr 16, 2024
1 parent 736913c commit 57e06bf
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 255 deletions.
72 changes: 32 additions & 40 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,56 +1,48 @@
# Front end variables
DEFAULT_CHAIN_ID=11155111
GOVERNANCE_URL=https://localhost:8000/
GOVERNANCE_API=https://localhost:8000/api
BUY_MANA_URL=https://kyberswap.com/swap/eth-mana
BUY_LAND_URL=https://market.decentraland.org/browse?section=land
BUY_NAME_URL=https://builder.decentraland.org/names
VESTING_DASHBOARD_URL=https://vesting.decentraland.org/%23/
VITE_GOVERNANCE_URL=http://localhost:5173/
VITE_GOVERNANCE_API=https://localhost:8000/api
VITE_BUY_MANA_URL=https://kyberswap.com/swap/eth-mana
VITE_BUY_LAND_URL=https://market.decentraland.org/browse?section=land
VITE_BUY_NAME_URL=https://builder.decentraland.org/names
VITE_VESTING_DASHBOARD_URL=https://vesting.decentraland.org/%23/

# Snapshot integration
SNAPSHOT_API=https://testnet.hub.snapshot.org/
SNAPSHOT_URL=https://testnet.snapshot.org/
SNAPSHOT_QUERY_ENDPOINT=https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot
SNAPSHOT_SPACE=daotest.dcl.eth
SNAPSHOT_DURATION=600
SNAPSHOT_DELEGATE_CONTRACT_ADDRESS=0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446
SNAPSHOT_ADDRESS=
VITE_SNAPSHOT_API=https://testnet.hub.snapshot.org/
VITE_SNAPSHOT_URL=https://testnet.snapshot.org/
VITE_SNAPSHOT_QUERY_ENDPOINT=https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot
VITE_SNAPSHOT_SPACE=daotest.dcl.eth
VITE_SNAPSHOT_DURATION=600
VITE_SNAPSHOT_DELEGATE_CONTRACT_ADDRESS=0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446

# Snapshot Status
SNAPSHOT_STATUS_ENABLED='false'
VITE_SNAPSHOT_STATUS_ENABLED='false'

# Discourse integration
DISCOURSE_USER=dao
DISCOURSE_API=https://forum.decentraland.org
DISCOURSE_CONNECT_THREAD=0

# Required voting power to pass a proposal by type
VOTING_POWER_TO_PASS_LINKED_WEARABLES=0
VOTING_POWER_TO_PASS_CATALYST=0
VOTING_POWER_TO_PASS_BAN_NAME=0
VOTING_POWER_TO_PASS_POI=0
VOTING_POWER_TO_PASS_POLL=0
VOTING_POWER_TO_PASS_DRAFT=0
VOTING_POWER_TO_PASS_GOVERNANCE=0
VOTING_POWER_TO_PASS_PITCH=0
VOTING_POWER_TO_PASS_TENDER=0
VOTING_POWER_TO_PASS_HIRING=0
VOTING_POWER_TO_PASS_GRANT=0
VITE_DISCOURSE_USER=dao
VITE_DISCOURSE_API=https://forum.decentraland.org
VITE_DISCOURSE_CONNECT_THREAD=0

# Discord
VITE_DISCORD_PROFILE_VERIFICATION_URL=https://discord.gg/nquz9JbCCx

# Submission threshold for governance proposals
SUBMISSION_THRESHOLD_POLL=100
SUBMISSION_THRESHOLD_DRAFT=100
SUBMISSION_THRESHOLD_GOVERNANCE=100
SUBMISSION_THRESHOLD_PITCH=100
SUBMISSION_THRESHOLD_TENDER=100
SUBMISSION_THRESHOLD_HIRING=100
SUBMISSION_THRESHOLD_GRANT=100
VITE_SUBMISSION_THRESHOLD_POLL=100
VITE_SUBMISSION_THRESHOLD_DRAFT=100
VITE_SUBMISSION_THRESHOLD_GOVERNANCE=100
VITE_SUBMISSION_THRESHOLD_PITCH=100
VITE_SUBMISSION_THRESHOLD_TENDER=100
VITE_SUBMISSION_THRESHOLD_HIRING=100
VITE_SUBMISSION_THRESHOLD_GRANT=100

# Single Sign On
SSO_URL="https://id.decentraland.zone"
VITE_SSO_URL="https://id.decentraland.zone"

# DCL Data
DCL_DATA_API=https://data.decentraland.vote/
VITE_DCL_DATA_API=https://data.decentraland.vote/

# Notifications
PUSH_CHANNEL_ID=
VITE_PUSH_CHANNEL_ID=

# Testing only
VITE_GRANT_VP_THRESHOLD=
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,9 @@ If you are running this project locally you only need to check the following env

These environment variables are used by the application backend. The environment variables for the frontend are located in `src/config/env`.

### Setup the required voting power to pass

The minimum amount of voting power require to pass a proposal of each type it's defined in these variables, if they are not defined or are not numbers `0` will be used instead

```bash
VOTING_POWER_TO_PASS_LINKED_WEARABLES=0
VOTING_POWER_TO_PASS_CATALYST=0
VOTING_POWER_TO_PASS_BAN_NAME=0
VOTING_POWER_TO_PASS_POI=0
VOTING_POWER_TO_PASS_POLL=0
```

## Database setup

Make sure you have Postgres installed and running:

```shell
brew install postgresql@14
brew services start postgresql@14
createdb
```

## Snapshot Setup

- `SNAPSHOT_SPACE`: the snapshot space where the proposals will be published
- `SNAPSHOT_ADDRESS`: a pair address/key with permissions to publish at that snapshot space
- The configured SNAPSHOT_PROPOSAL_TYPE for the project is 'single-choice', which means each voter may select only one choice. See [available voting systems](https://docs.snapshot.org/proposals/voting-types#single-choice-voting)

### Creating a Snapshot space
Expand Down
5 changes: 2 additions & 3 deletions src/clients/Governance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import snakeCase from 'lodash/snakeCase'

import { SpecState } from '../components/Debug/UploadBadgeSpec'
import { config } from '../config'
import { GOVERNANCE_API } from '../constants'
import {
DetailedScores,
Expand Down Expand Up @@ -99,7 +98,7 @@ export type GetProposalsFilter = ProposalListFilter & {
}

const getGovernanceApiUrl = () => {
if (config.get('VITE_HEROKU_APP_NAME')) {
if (import.meta.env.VITE_HEROKU_APP_NAME) {
return `https://governance.decentraland.vote/api`
}

Expand All @@ -120,7 +119,7 @@ export class Governance extends API {
}

static get() {
return this.from(config.get('GOVERNANCE_API', this.Url))
return this.from(this.Url)
}

async fetchApiResponse<T>(endpoint: string, options: ApiOptions = { method: 'GET', sign: false }): Promise<T> {
Expand Down
7 changes: 3 additions & 4 deletions src/clients/SnapshotApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import snapshot from '@snapshot-labs/snapshot.js'
import Client from '@snapshot-labs/snapshot.js/dist/sign'
import { ProposalType, Vote } from '@snapshot-labs/snapshot.js/dist/sign/types'

import { config } from '../config'
import { SNAPSHOT_SPACE } from '../constants/snapshot'
import { SNAPSHOT_API, SNAPSHOT_SPACE } from '../constants/snapshot'

import { trimLastForwardSlash } from './utils'

Expand All @@ -31,7 +30,7 @@ type CastVote = {
}

export class SnapshotApi {
static Url = config.get('SNAPSHOT_API') || 'https://hub.snapshot.org'
static Url = SNAPSHOT_API

static Cache = new Map<string, SnapshotApi>()
private readonly client: Client
Expand All @@ -57,7 +56,7 @@ export class SnapshotApi {
}

static get() {
return this.from(config.get('SNAPSHOT_API', this.Url))
return this.from(this.Url)
}

async castVote({
Expand Down
5 changes: 2 additions & 3 deletions src/clients/SnapshotGraphql.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import uniqBy from 'lodash/uniqBy'

import { config } from '../config'
import { SNAPSHOT_API, SNAPSHOT_SPACE } from '../constants/snapshot'
import {
SnapshotConfig,
Expand Down Expand Up @@ -45,7 +44,7 @@ const GET_VOTES_QUERY = `
`

export class SnapshotGraphql extends API {
static Url = SNAPSHOT_API || 'https://hub.snapshot.org/'
static Url = SNAPSHOT_API
static Cache = new Map<string, SnapshotGraphql>()

static from(baseUrl: string): SnapshotGraphql {
Expand All @@ -57,7 +56,7 @@ export class SnapshotGraphql extends API {
}

static get(): SnapshotGraphql {
return this.from(config.get('SNAPSHOT_API', this.Url))
return this.from(this.Url)
}

async getConfig() {
Expand Down
10 changes: 4 additions & 6 deletions src/clients/Transparency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config } from '../config'
import { TRANSPARENCY_API } from '../constants'
import { ProjectStatus } from '../types/grants'
import { TokenInWallet } from '../types/transparency'
import { ErrorCategory } from '../utils/errorCategories'
Expand Down Expand Up @@ -87,12 +87,10 @@ const EMPTY_API: TransparencyData = {
committees: [],
}

const API_URL = config.get('DCL_DATA_API') || 'https://data.decentraland.vote/'

export class Transparency {
static async getData() {
try {
const response = (await (await fetch(`${API_URL}/api.json`)).json()) as TransparencyData
const response = (await (await fetch(`${TRANSPARENCY_API}/api.json`)).json()) as TransparencyData
return response
} catch (error) {
ErrorClient.report('Failed to fetch transparency data', { error, category: ErrorCategory.Transparency })
Expand All @@ -102,7 +100,7 @@ export class Transparency {

static async getBudgets() {
try {
const response = (await (await fetch(`${API_URL}/budgets.json`)).json()) as TransparencyBudget[]
const response = (await (await fetch(`${TRANSPARENCY_API}/budgets.json`)).json()) as TransparencyBudget[]
return response
} catch (error) {
ErrorClient.report('Failed to fetch transparency budgets data', { error, category: ErrorCategory.Transparency })
Expand All @@ -112,7 +110,7 @@ export class Transparency {

static async getVestings() {
try {
const response = (await (await fetch(`${API_URL}/vestings.json`)).json()) as TransparencyVesting[]
const response = (await (await fetch(`${TRANSPARENCY_API}/vestings.json`)).json()) as TransparencyVesting[]
return response
} catch (error) {
ErrorClient.report('Failed to fetch transparency vestings data', { error, category: ErrorCategory.Transparency })
Expand Down
1 change: 1 addition & 0 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default function Layout({ children }: LayoutProps) {
track(DROPDOWN_MENU_BALANCE_CLICK_EVENT, { network })

setTimeout(() => {
// TODO: Missing variable ACCOUNT_URL
window.open(config.get('ACCOUNT_URL'), '_blank', 'noopener')
}, 300)
},
Expand Down
6 changes: 5 additions & 1 deletion src/components/Proposal/Submit/ProposalSubmitPoiPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Governance } from '../../../clients/Governance'
import { useAuthContext } from '../../../context/AuthProvider'
import { disableOnWheelInput } from '../../../helpers'
import useFormatMessage from '../../../hooks/useFormatMessage'
import { PoiType, ProposalType, getPoiTypeAction, newProposalPOIScheme } from '../../../types/proposals'
import { PoiType, ProposalType, newProposalPOIScheme } from '../../../types/proposals'
import locations from '../../../utils/locations'
import { asNumber, isAlreadyPointOfInterest, isValidPointOfInterest } from '../../../utils/proposal'
import Field from '../../Common/Form/Field'
Expand Down Expand Up @@ -78,6 +78,10 @@ interface Props {
poiType: PoiType
}

function getPoiTypeAction(poiType: PoiType) {
return poiType.split('_')[0] // "add" | "remove"
}

export default function ProposalSubmitPoiPage({ poiType }: Props) {
const t = useFormatMessage()
const [account, accountState] = useAuthContext()
Expand Down
3 changes: 2 additions & 1 deletion src/components/Transparency/DaoVestingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useIntl } from 'react-intl'

import isNumber from 'lodash/isNumber'

import { DAO_VESTING_CONTRACT_ADDRESS } from '../../constants'
import { CURRENCY_FORMAT_OPTIONS, getVestingContractUrl } from '../../helpers'
import useFormatMessage from '../../hooks/useFormatMessage'
import useManaPrice from '../../hooks/useManaPrice'
Expand All @@ -11,6 +10,8 @@ import FinancialCard from '../Updates/FinancialCard'

import DaoFinancial from './DaoFinancial'

const DAO_VESTING_CONTRACT_ADDRESS = '0x7a3abf8897f31b56f09c6f69d074a393a905c1ac'

function DaoVestingCard() {
const t = useFormatMessage()
const { vestingData } = useVestingContractData([DAO_VESTING_CONTRACT_ADDRESS])
Expand Down
11 changes: 0 additions & 11 deletions src/config/env/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"MAINTENANCE": "false",
"SEGMENT_KEY": "CXcLRdj0SnrRBlwYTcyWVBuE9kYaIP47",
"PROD_ENV_VAR": "only for testing dev",
"SNAPSHOT_ADDRESS": "0x2Ba0352480bd1Ea073A83e6639b06362131894CE",
"SNAPSHOT_DELEGATE_CONTRACT_ADDRESS": "0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446",
"SNAPSHOT_API": "https://testnet.hub.snapshot.org/",
"SNAPSHOT_DURATION": "300",
Expand All @@ -30,16 +29,6 @@
"SUBMISSION_THRESHOLD_GRANT": "100",
"SUBMISSION_THRESHOLD_HIRING": "99",
"GRANT_VP_THRESHOLD": "50",
"VOTING_POWER_TO_PASS_LINKED_WEARABLES": "99",
"VOTING_POWER_TO_PASS_BAN_NAME": "99",
"VOTING_POWER_TO_PASS_CATALYST": "99",
"VOTING_POWER_TO_PASS_DRAFT": "100",
"VOTING_POWER_TO_PASS_GOVERNANCE": "100",
"VOTING_POWER_TO_PASS_POI": "99",
"VOTING_POWER_TO_PASS_POLL": "100",
"VOTING_POWER_TO_PASS_PITCH": "100",
"VOTING_POWER_TO_PASS_TENDER": "100",
"VOTING_POWER_TO_PASS_HIRING": "99",
"SSO_URL": "https://id.decentraland.zone",
"PUSH_CHANNEL_ID": "0xBf363AeDd082Ddd8DB2D6457609B03f9ee74a2F1",
"DISCORD_PROFILE_VERIFICATION_URL": "https://discord.gg/6nt4qcECdk",
Expand Down
11 changes: 0 additions & 11 deletions src/config/env/prd.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"MAINTENANCE": "false",
"SEGMENT_KEY": "vNzuKtwiBQvYxLAVzWQARB1i507VkSHq",
"PROD_ENV_VAR": "only for testing prod",
"SNAPSHOT_ADDRESS": "0x5E23D08324f017d5425e59A2782C9ae27aCE0958",
"SNAPSHOT_DELEGATE_CONTRACT_ADDRESS": "0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446",
"SNAPSHOT_API": "https://hub.snapshot.org/",
"SNAPSHOT_DURATION": "604800",
Expand All @@ -28,16 +27,6 @@
"SUBMISSION_THRESHOLD_PITCH": "100",
"SUBMISSION_THRESHOLD_TENDER": "2500",
"SUBMISSION_THRESHOLD_GRANT": "100",
"VOTING_POWER_TO_PASS_LINKED_WEARABLES": "4000000",
"VOTING_POWER_TO_PASS_BAN_NAME": "4000000",
"VOTING_POWER_TO_PASS_CATALYST": "2000000",
"VOTING_POWER_TO_PASS_DRAFT": "1000000",
"VOTING_POWER_TO_PASS_GOVERNANCE": "6000000",
"VOTING_POWER_TO_PASS_POI": "2000000",
"VOTING_POWER_TO_PASS_POLL": "500000",
"VOTING_POWER_TO_PASS_PITCH": "2000000",
"VOTING_POWER_TO_PASS_TENDER": "4000000",
"VOTING_POWER_TO_PASS_HIRING": "6000000",
"SSO_URL": "https://id.decentraland.org",
"PUSH_CHANNEL_ID": "0x4BaaC83d0A68C079550142B9d792328b7C239844",
"DISCORD_PROFILE_VERIFICATION_URL": "https://discord.gg/nquz9JbCCx",
Expand Down
5 changes: 1 addition & 4 deletions src/constants/grants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { config } from '../config'
import Time from '../utils/date/Time'

export const GRANT_VP_THRESHOLD = config.get('VITE_GRANT_VP_THRESHOLD') // Testing variable
export const MAX_LOWER_TIER_GRANT_FUNDING = 20000
export const BUDGETING_START_DATE = Time.utc('2023-01-01 00:00:00Z').toDate()
export const GRANT_VP_THRESHOLD = import.meta.env.VITE_GRANT_VP_THRESHOLD || config.get('GRANT_VP_THRESHOLD') // Testing variable
Loading

0 comments on commit 57e06bf

Please sign in to comment.