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

Creator updates #495

Merged
merged 21 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d069041
Squashed commit of the following:
fabiolalombardim Dec 21, 2022
740680c
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 3, 2023
cb8245d
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 8, 2023
8cbe0d7
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 10, 2023
8a1590f
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 10, 2023
435639f
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 11, 2023
a56b6e9
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 12, 2023
c66cef7
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 19, 2023
1830e65
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 25, 2023
10436dd
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Jan 26, 2023
2e70d41
added tooltip for token id
fabiolalombardim Jan 29, 2023
f7ae439
fixed conditional votting settings depending on network
fabiolalombardim Jan 31, 2023
c4d73a4
estimated blocks
fabiolalombardim Jan 31, 2023
2955169
update initialization of values
fabiolalombardim Feb 6, 2023
f0796b7
useBlocks
fabiolalombardim Feb 7, 2023
d6a0e2c
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Feb 7, 2023
68544f7
Merge branch 'develop' into creator-updates
fabiolalombardim Feb 7, 2023
9d78ca9
useBlocks updated
fabiolalombardim Feb 11, 2023
859b217
values updated
fabiolalombardim Feb 11, 2023
6a7af36
Merge branch 'develop' of https://github.com/dOrgTech/homebase-app in…
fabiolalombardim Feb 15, 2023
b9e7d72
summary bug fixed & develop merged
fabiolalombardim Feb 15, 2023
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
55 changes: 52 additions & 3 deletions src/modules/creator/state/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React, { createContext, useReducer, Dispatch, useMemo } from "react"

import useLocalStorage from "modules/common/hooks/useLocalStorage"
import { CreatorAction, CreatorState, ActionTypes, MigrationParams } from "modules/creator/state/types"
import { useTezos } from "services/beacon/hooks/useTezos"
import { networkNameMap } from "services/bakingBad"
import { getTezosNetwork } from "services/beacon/utils"

const deploymentStatus = {
deploying: false,
Expand Down Expand Up @@ -30,7 +33,16 @@ export const INITIAL_MIGRATION_STATE: MigrationParams = {
minXtzAmount: 0,
maxXtzAmount: 0,
proposalFlushBlocks: 0,
proposalExpiryBlocks: 0
proposalExpiryBlocks: 0,
votingBlocksDay: 0,
votingBlocksHours: 0,
votingBlocksMinutes: 5,
proposalFlushBlocksDay: 0,
proposalFlushBlocksHours: 0,
proposalFlushBlocksMinutes: 5,
proposalExpiryBlocksDay: 0,
proposalExpiryBlocksHours: 0,
proposalExpiryBlocksMinutes: 5
},
quorumSettings: {
quorumThreshold: 2,
Expand All @@ -41,8 +53,24 @@ export const INITIAL_MIGRATION_STATE: MigrationParams = {
}
}

const getInitialState = (data: MigrationParams) => {
const network = getTezosNetwork()

data.votingSettings.votingBlocksDay = network === networkNameMap.ghostnet ? 0 : 3
data.votingSettings.votingBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
data.votingSettings.votingBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0
data.votingSettings.proposalFlushBlocksDay = network === networkNameMap.ghostnet ? 0 : 1
data.votingSettings.proposalFlushBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
data.votingSettings.proposalFlushBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0
data.votingSettings.proposalExpiryBlocksDay = network === networkNameMap.ghostnet ? 0 : 6
data.votingSettings.proposalExpiryBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
data.votingSettings.proposalExpiryBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0

return data
}

export const INITIAL_STATE: CreatorState = {
data: INITIAL_MIGRATION_STATE,
data: getInitialState(INITIAL_MIGRATION_STATE),
deploymentStatus
}

Expand Down Expand Up @@ -77,6 +105,7 @@ export const reducer = (state: CreatorState, action: CreatorAction): CreatorStat
}
return state
case ActionTypes.UPDATE_ORGANIZATION_SETTINGS:
localStorage.setItem("creator-started", "true")
state = {
...state,
data: {
Expand Down Expand Up @@ -114,6 +143,7 @@ export const reducer = (state: CreatorState, action: CreatorAction): CreatorStat
return state
case ActionTypes.CLEAR_CACHE:
window.localStorage.removeItem(LOCAL_STORAGE_KEY)
window.localStorage.removeItem("creator-started")
state = {
...INITIAL_STATE,
deploymentStatus: {
Expand All @@ -125,12 +155,31 @@ export const reducer = (state: CreatorState, action: CreatorAction): CreatorStat
}
}

const updateInitialState = (network: string, values: MigrationParams) => {
values.votingSettings.votingBlocksDay = network === networkNameMap.ghostnet ? 0 : 3
values.votingSettings.votingBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
values.votingSettings.votingBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0
values.votingSettings.proposalFlushBlocksDay = network === networkNameMap.ghostnet ? 0 : 1
values.votingSettings.proposalFlushBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
values.votingSettings.proposalFlushBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0
values.votingSettings.proposalExpiryBlocksDay = network === networkNameMap.ghostnet ? 0 : 6
values.votingSettings.proposalExpiryBlocksHours = network === networkNameMap.ghostnet ? 0 : 0
values.votingSettings.proposalExpiryBlocksMinutes = network === networkNameMap.ghostnet ? 5 : 0

return values
}

const CreatorProvider: React.FC = ({ children }) => {
const [data, updateCache] = useLocalStorage<MigrationParams>(LOCAL_STORAGE_KEY, INITIAL_STATE.data)
const isCreatorStarted = localStorage.getItem("creator-started")

const { network } = useTezos()

const updatedData = isCreatorStarted ? data : updateInitialState(network, data)

const stateWithCache = {
...INITIAL_STATE,
data
updatedData
}

const [state, dispatch] = useReducer(reducer, stateWithCache)
Expand Down
12 changes: 12 additions & 0 deletions src/modules/creator/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ export type VotingSettings = {
votingBlocks: number
proposalFlushBlocks: number
proposalExpiryBlocks: number

votingBlocksDay?: number
votingBlocksHours?: number
votingBlocksMinutes?: number

proposalFlushBlocksDay?: number
proposalFlushBlocksHours?: number
proposalFlushBlocksMinutes?: number

proposalExpiryBlocksDay?: number
proposalExpiryBlocksHours?: number
proposalExpiryBlocksMinutes?: number
}

export interface MigrationParams {
Expand Down
69 changes: 12 additions & 57 deletions src/modules/creator/steps/DaoSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ const DaoSettingsForm = withRouter(({ submitForm, values, setFieldValue, errors,
inputProps={{
maxLength: 36
}}
// InputProps={{
// endAdornment: (
// <InputAdornment position="start">
// <Tooltip placement="bottom" title="Token Address">
// <InfoIconInput />
// </Tooltip>
// </InputAdornment>
// )
// }}
/>
</CustomInputContainer>
{errors.governanceToken?.address && touched.governanceToken?.address ? (
Expand All @@ -195,15 +186,18 @@ const DaoSettingsForm = withRouter(({ submitForm, values, setFieldValue, errors,
placeholder="0"
name="governanceToken.tokenId"
component={CustomFormikTextField}
// InputProps={{
// endAdornment: (
// <InputAdornment position="start">
// <Tooltip placement="bottom" title="Token ID">
// <InfoIconInput />
// </Tooltip>
// </InputAdornment>
// )
// }}
InputProps={{
endAdornment: (
<InputAdornment position="start">
<Tooltip
placement="bottom"
title="Homebase will only track your governance token at a certain ID index, which is a parameter specified upon deploying the token contract. Fungible tokens usually have the ID of 0 (zero)."
>
<InfoIconInput />
</Tooltip>
</InputAdornment>
)
}}
/>
</CustomInputContainer>
{errors.governanceToken?.tokenId && touched.governanceToken?.tokenId ? (
Expand All @@ -230,48 +224,10 @@ const DaoSettingsForm = withRouter(({ submitForm, values, setFieldValue, errors,
type="text"
placeholder="My Group’s Token"
component={CustomFormikTextField}
// InputProps={{
// endAdornment: (
// <InputAdornment position="start">
// <Tooltip placement="bottom" title="DAO Name info">
// <InfoIconInput />
// </Tooltip>
// </InputAdornment>
// )
// }}
></Field>
</CustomInputContainer>
{errors.name && touched.name ? <ErrorText>{errors.name}</ErrorText> : null}
</Grid>

{/* <Grid item xs={isMobile ? 12 : 3}>
<Typography variant="subtitle1" color="textSecondary">
{" "}
Token Symbol{" "}
</Typography>
<CustomInputContainer>
<Field
name="symbol"
type="text"
inputProps={{
style: { textTransform: "uppercase" },
maxLength: 6
}}
placeholder="MYTOK"
component={CustomFormikTextField}
InputProps={{
endAdornment: (
<InputAdornment position="start">
<Tooltip placement="bottom" title="Token symbol info">
<InfoIconInput />
</Tooltip>
</InputAdornment>
)
}}
></Field>
</CustomInputContainer>
{errors.symbol && touched.symbol ? <ErrorText>{errors.symbol}</ErrorText> : null}
</Grid> */}
</SecondContainer>
<SecondContainer container direction="row" alignItems="center">
<Grid item xs={12}>
Expand Down Expand Up @@ -399,7 +355,6 @@ const validateForm = (values: OrgSettings) => {
}
}

console.log(errors)
return errors
}

Expand Down
Loading