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

fix: fix empty voting period being overriden #1014

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions apps/ui/src/networks/offchain/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import {
ApiStrategy,
ApiVote
} from './types';
import { DEFAULT_VOTING_DELAY } from '../constants';

const DEFAULT_AUTHENTICATOR = 'OffchainAuthenticator';

Expand Down Expand Up @@ -175,8 +174,8 @@ function formatSpace(
voting_types: space.voting.type
? [space.voting.type]
: constants.EDITOR_VOTING_TYPES,
min_voting_period: space.voting.period ?? DEFAULT_VOTING_DELAY,
max_voting_period: space.voting.period ?? DEFAULT_VOTING_DELAY,
min_voting_period: space.voting.period ?? 0,
max_voting_period: space.voting.period ?? 0,
proposal_threshold: '1',
treasuries,
labels: space.labels,
Expand Down
2 changes: 0 additions & 2 deletions apps/ui/src/networks/offchain/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ export const EDITOR_VOTING_TYPES: VoteType[] = [
'weighted',
'quadratic'
];

export const DEFAULT_VOTING_DELAY = 60 * 60 * 24 * 7;
31 changes: 23 additions & 8 deletions apps/ui/src/views/Space/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { validateForm } from '@/helpers/validation';
import { getNetwork, offchainNetworks } from '@/networks';
import { Contact, Space, Transaction, VoteType } from '@/types';

const DEFAULT_VOTING_DELAY = 60 * 60 * 24 * 3;

const TITLE_DEFINITION = {
type: 'string',
title: 'Title',
Expand Down Expand Up @@ -173,6 +175,16 @@ const proposalLimitReached = computed(

const propositionPower = computed(() => getPropositionPower(props.space));

const proposalStart = computed(
() => Math.floor(Date.now() / 1000) + props.space.voting_delay
);

const proposalMinEnd = computed(
() =>
proposalStart.value +
(props.space.min_voting_period || DEFAULT_VOTING_DELAY)
);

async function handleProposeClick() {
if (!proposal.value) return;

Expand Down Expand Up @@ -214,10 +226,6 @@ async function handleProposeClick() {
);
} else {
const appName = (route.query.app as LocationQueryValue) || '';
const currentTime = Math.floor(Date.now() / 1000);
const start = currentTime + props.space.voting_delay;
const minEnd = start + props.space.min_voting_period;
const maxEnd = start + props.space.max_voting_period;

result = await propose(
props.space,
Expand All @@ -228,9 +236,9 @@ async function handleProposeClick() {
choices,
proposal.value.labels,
appName.length <= 128 ? appName : '',
start,
minEnd,
maxEnd,
proposalStart.value,
proposalMinEnd.value,
proposalMinEnd.value,
executions
);
}
Expand Down Expand Up @@ -566,7 +574,14 @@ watchEffect(() => {
/>
<div>
<h4 class="eyebrow mb-2.5" v-text="'Timeline'" />
<ProposalTimeline :data="space" />
<ProposalTimeline
:data="{
...space,
start: proposalStart,
min_end: proposalMinEnd,
max_end: proposalMinEnd
}"
/>
</div>
</div>
</Affix>
Expand Down