Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelianoB committed Apr 17, 2024
2 parents ebca87f + fb2c223 commit 983bd0b
Show file tree
Hide file tree
Showing 55 changed files with 1,208 additions and 138 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"@sentry/vite-plugin": "^2.10.1",
"@sentry/vue": "^7.80.1",
"@shutter-network/shutter-crypto": "1.0.1",
"@snapshot-labs/lock": "^0.2.3",
"@snapshot-labs/lock": "^0.2.4",
"@snapshot-labs/pineapple": "^1.1.0",
"@snapshot-labs/snapshot.js": "^0.11.15",
"@snapshot-labs/snapshot.js": "^0.11.17",
"@vue/apollo-composable": "4.0.0-beta.11",
"@vueuse/core": "^10.6.1",
"@vueuse/head": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion snapshot-spaces
10 changes: 7 additions & 3 deletions src/components/ModalPostVote.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
import { getChoiceString } from '@/helpers/utils';
import { ExtendedSpace, Proposal } from '@/helpers/interfaces';
import { getSafeAppLink } from '@/plugins/oSnap/utils';
const { shareVote, shareProposalX, shareProposalHey } = useSharing();
const { web3Account } = useWeb3();
const { web3, web3Account } = useWeb3();
const { userState, loadEmailSubscriptions, initialized } =
useEmailSubscription();
Expand Down Expand Up @@ -100,10 +101,13 @@ onMounted(() => {
<i-ho-mail class="text-skin-link" />
{{ $t('proposal.postVoteModal.subscribe') }}
</TuneButton>

<div v-if="props.waitingForSigners">
<BaseLink
:link="`https://gnosis-safe.io/app/eth:${web3Account}/transactions/queue`"
:link="
getSafeAppLink(web3.network.chainId, web3Account, {
path: 'transactions/queue'
})
"
hide-external-icon
>
<TuneButton tabindex="-1" class="w-full">
Expand Down
9 changes: 5 additions & 4 deletions src/components/ModalVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { shorten, getChoiceString, explorerUrl } from '@/helpers/utils';
import { getPower, voteValidation } from '@/helpers/snapshot';
import { ExtendedSpace, Proposal } from '@/helpers/interfaces';
import shutterEncryptChoice from '@/helpers/shutter';
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
const { web3Account } = useWeb3();
Expand Down Expand Up @@ -273,8 +274,8 @@ watch(
tag="span"
scope="global"
>
<template #discord>
<BaseLink link="https://discord.snapshot.org">Discord</BaseLink>
<template #help>
<BaseLink :link="SNAPSHOT_HELP_LINK">Help Center</BaseLink>
</template>
</i18n-t>
</BaseMessageBlock>
Expand All @@ -291,8 +292,8 @@ watch(
tag="span"
scope="global"
>
<template #discord>
<BaseLink link="https://discord.snapshot.org">Discord</BaseLink>
<template #help>
<BaseLink :link="SNAPSHOT_HELP_LINK">Help Center</BaseLink>
</template>
</i18n-t>
</BaseMessageBlock>
Expand Down
32 changes: 22 additions & 10 deletions src/components/ProposalsItemFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@
import capitalize from 'lodash/capitalize';
import { Proposal } from '@/helpers/interfaces';
defineProps<{
const props = defineProps<{
proposal: Proposal;
}>();
const { getRelativeProposalPeriod, formatPercentNumber } = useIntl();
const quorumText = computed(() => {
if (!props.proposal.quorum || !props.proposal.scores_total) {
return '';
}
const quorumOfRejection = props.proposal.quorumType === 'rejection';
const percentage = formatPercentNumber(
quorumOfRejection
? Number(
props.proposal.scores
.filter((c, i) => i === 1)
.reduce((a, b) => a + b, 0) / props.proposal.quorum
)
: Number(props.proposal.scores_total / props.proposal.quorum)
);
return quorumOfRejection
? `${percentage} quorum rejection`
: `${percentage} quorum reached`;
});
</script>

<template>
Expand All @@ -29,16 +48,9 @@ const { getRelativeProposalPeriod, formatPercentNumber } = useIntl();
)
}}
</span>
<template
v-if="
proposal.quorum &&
proposal.scores_total &&
!proposal.space.plugins?.quorum
"
>
<template v-if="proposal.quorum && proposal.scores_total">
-
{{ formatPercentNumber(Number(proposal.scores_total / proposal.quorum)) }}
{{ $t('quorumReached') }}
{{ quorumText }}
</template>
</div>
</template>
2 changes: 1 addition & 1 deletion src/components/SettingsTreasuriesBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const modalOsnapOpen = ref(false);
const currentTreasuryIndex = ref<number | null>(null);
const currentTreasury = ref<TreasuryWallet>(clone(treasuryObj));
const hasOsnapPlugin = computed(() => {
return Object.keys(props.space.plugins).includes('oSnap');
return Object.keys(form.value.plugins).includes('oSnap');
});
const isOsnapEnabledOnCurrentTreasury = ref(false);
Expand Down
19 changes: 19 additions & 0 deletions src/components/SettingsVotingBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ const { form, validationErrors } = useFormSpaceSettings(props.context);
block
/>

<TuneListbox
v-model="form.voting.quorumType"
placeholder="Default"
label="Quorum type"
hint="The type of quorum used for this space."
:items="[
{
value: 'default',
name: 'Default'
},
{
value: 'rejection',
name: 'Quorum of rejection'
}
]"
:disabled="isViewOnly"
:error="validationErrors?.voting?.quorumType"
/>

<TuneInput
:model-value="form.voting.quorum"
:label="$t('settings.quorum.label')"
Expand Down
55 changes: 48 additions & 7 deletions src/components/SetupDomain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ watch(
);
const triggerEnsUnavailableTooltip = (key: string, error_code: string) => {
const text =
error_code === 'deleted-space'
? 'This ENS name is used by a previously deleted space, and can not be used anymore to create a new space. <a target="_blank" href="https://docs.snapshot.org/faq#why-cant-i-create-a-new-space-with-my-previous-deleted-space-ens-name">Learn more.</a>'
: t('setup.domain.invalidEns');
let text;
switch (error_code) {
case 'deleted-space':
text =
'This ENS name is used by a previously deleted space, and can not be used anymore to create a new space. <a target="_blank" href="https://docs.snapshot.org/faq#why-cant-i-create-a-new-space-with-my-previous-deleted-space-ens-name">Learn more.</a>';
break;
case 'invalid-ens-length':
text = 'The ENS name is too long. It must be less than 64 characters.';
break;
default:
text = t('setup.domain.invalidEns');
}
useTippy(refEnsUnavailableTooltip.value[key], {
content: text,
Expand All @@ -57,7 +65,8 @@ const availableDomains = computed(() => {
d =>
!spaceIds.includes(d.name) &&
!d.isInvalid &&
!deletedSpaces.value.includes(d.name)
!deletedSpaces.value.includes(d.name) &&
d.name.length <= 64
);
});
Expand All @@ -66,7 +75,9 @@ const unavailableDomains = computed(() => {
return ownedEnsDomains.value.filter(
d =>
!spaceIds.includes(d.name) &&
(d.isInvalid || deletedSpaces.value.includes(d.name))
(d.isInvalid ||
deletedSpaces.value.includes(d.name) ||
d.name.length > 64)
);
});
Expand Down Expand Up @@ -189,7 +200,37 @@ onUnmounted(() => clearInterval(waitingForRegistrationInterval));
</div>
</TuneButton>
</template>

<template v-else-if="ens.name.length > 64">
<TuneButton class="flex w-full items-center justify-between">
{{ shortenInvalidEns(ens.name) }}
<div
@mouseenter="
triggerEnsUnavailableTooltip(
ens.name,
'invalid-ens-length'
)
"
@focus="
triggerEnsUnavailableTooltip(
ens.name,
'invalid-ens-length'
)
"
>
<div
:ref="
v => {
refEnsUnavailableTooltip[ens.name] = v;
}
"
>
<i-ho-exclamation-circle
class="-mr-2 text-red cursor-help"
/>
</div>
</div>
</TuneButton>
</template>
<template v-else-if="ens.isInvalid">
<TuneButton class="flex w-full items-center justify-between">
{{ shortenInvalidEns(ens.name) }}
Expand Down
8 changes: 5 additions & 3 deletions src/components/SetupMessageHelp.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
</script>

<template>
<BaseBlock class="mt-4 text-skin-text">
Expand All @@ -13,8 +15,8 @@
documentation</BaseLink
>
</template>
<template #discord>
<BaseLink link="https://discord.snapshot.org/"> Discord</BaseLink>
<template #help>
<BaseLink :link="SNAPSHOT_HELP_LINK">Help Center</BaseLink>
</template>
</i18n-t>
</BaseBlock>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SpaceCreateWarnings.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
import { ExtendedSpace } from '@/helpers/interfaces';
const props = defineProps<{
Expand Down Expand Up @@ -63,7 +64,7 @@ const strategySymbolsString = computed(() => {
is-responsive
>
{{ $t('create.errorGettingSnapshot') }}
<BaseLink link="https://discord.snapshot.org/">
<BaseLink :link="SNAPSHOT_HELP_LINK">
{{ $t('learnMore') }}
</BaseLink>
</BaseMessageBlock>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SpaceProposalResults.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
import {
ExtendedSpace,
Proposal,
Expand Down Expand Up @@ -72,7 +73,7 @@ onMounted(() => {
</BaseMessage>
<BaseLink
v-if="isAdmin"
link="https://discord.snapshot.org/"
:link="SNAPSHOT_HELP_LINK"
class="mt-3 block"
hide-external-icon
>
Expand Down
19 changes: 15 additions & 4 deletions src/components/SpaceProposalResultsQuorum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ const props = defineProps<{
results: Results;
}>();
const { totalQuorumScore, quorum, loadingQuorum } = useQuorum(props);
const { totalQuorumScore, quorum, quorumType, loadingQuorum } =
useQuorum(props);
const { formatCompactNumber, formatPercentNumber } = useIntl();
</script>

<template>
<div class="pt-2 text-skin-link">
<div class="flex justify-between">
<div class="flex items-center gap-1">
{{ $t('settings.quorum.label') }}
{{ quorumType === 'rejection' ? 'Quorum of rejection' : 'Quorum' }}
</div>
<LoadingSpinner v-if="loadingQuorum" class="mr-1" />
<div v-else class="flex gap-2">
<i-ho-check
v-if="quorum && totalQuorumScore >= quorum"
class="text-skin-success text-green"
v-if="
quorum && quorumType === 'default' && totalQuorumScore >= quorum
"
class="text-green"
/>
<i-ho-x
v-if="
quorum && quorumType === 'rejection' && totalQuorumScore >= quorum
"
class="text-red"
/>

<span
v-tippy="{ content: formatPercentNumber(totalQuorumScore / quorum) }"
>
Expand Down
5 changes: 3 additions & 2 deletions src/components/SpaceProposalVote.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
import { Proposal, Choice } from '@/helpers/interfaces';
import voting from '@snapshot-labs/snapshot.js/src/voting';
Expand Down Expand Up @@ -120,8 +121,8 @@ watch(
class="border px-3 py-[12px] rounded-xl bg-[--border-color-subtle]"
>
Oops, we were unable to validate your vote. Please try voting again or
consider opening a ticket with our support team on
<BaseLink link="https://discord.snapshot.org">Discord</BaseLink>
consider contacting our support team on
<BaseLink :link="SNAPSHOT_HELP_LINK">Help Center</BaseLink>
</BaseMessage>
<div v-else>
<SpaceProposalVoteSingleChoice
Expand Down
5 changes: 3 additions & 2 deletions src/components/SpaceProposalsNotice.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
import { useStorage } from '@vueuse/core';
defineProps<{
Expand Down Expand Up @@ -49,8 +50,8 @@ const createdSpaces = useStorage(
documentation</BaseLink
>
</template>
<template #discord>
<BaseLink link="https://discord.snapshot.org/"> Discord</BaseLink>
<template #help>
<BaseLink :link="SNAPSHOT_HELP_LINK">Help Center</BaseLink>
</template>
</i18n-t>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/TheFooter.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
const yearNow = new Date().getFullYear();
const snapshotTextLinks = [
Expand Down Expand Up @@ -31,7 +33,7 @@ const resourcesTextLinks = [
},
{
text: 'support',
link: 'https://discord.snapshot.org/'
link: SNAPSHOT_HELP_LINK
}
];
</script>
Expand Down
5 changes: 3 additions & 2 deletions src/components/TheModalNotification.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { SNAPSHOT_HELP_LINK } from '@/helpers/constants';
import defaults from '@/locales/default.json';
const { items } = useModalNotification();
Expand All @@ -20,8 +21,8 @@ const { items } = useModalNotification();
tag="span"
scope="global"
>
<template #discord>
<BaseLink link="https://discord.snapshot.org">Discord</BaseLink>
<template #help>
<BaseLink :link="SNAPSHOT_HELP_LINK">Discord</BaseLink>
</template>
</i18n-t>
</template>
Expand Down
Loading

0 comments on commit 983bd0b

Please sign in to comment.