-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-page-content-not-full-height
- Loading branch information
Showing
7 changed files
with
112 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<script setup lang="ts"> | ||
import { lsGet, lsSet } from '@/helpers/utils'; | ||
const KEY = 'showV2Welcome'; | ||
const open = ref(false); | ||
function handleClose() { | ||
open.value = false; | ||
lsSet(KEY, false); | ||
} | ||
onMounted(async () => { | ||
open.value = lsGet(KEY) ?? true; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="open" | ||
class="fixed bottom-0 right-0 sm:mx-4 sm:mb-4 sm:rounded-lg bg-skin-link text-skin-bg z-[99] blocks-x !bg-left-top sm:max-w-[320px]" | ||
> | ||
<UiButton | ||
class="!text-skin-bg !bg-transparent !border-none absolute top-1 right-1 !px-0 w-[40px] !h-[40px]" | ||
@click="handleClose" | ||
> | ||
<IH-x class="inline-block" /> | ||
</UiButton> | ||
<div class="bg-skin-link/90 sm:rounded-lg p-4"> | ||
<div class="flex space-x-3"> | ||
<div class="text-end"> | ||
<img src="@/assets/snapshot.svg" alt="Snapshot" class="w-[36px]" /> | ||
</div> | ||
<div class="font-bold text-md leading-5"> | ||
Welcome to the new | ||
<div class="font-display text-xl">Snapshot</div> | ||
</div> | ||
</div> | ||
<div class="mt-3 mb-4"> | ||
Introducing the next evolution of Snapshot, with a brand new interface, | ||
support for onchain voting, proposal executions, and many more | ||
governance enhancements. | ||
</div> | ||
<div class="space-y-2 text-center"> | ||
<UiButton | ||
class="w-full" | ||
to="https://snapshot.mirror.xyz/0qnfjmE0SFeUykArdi664oO4qFcZUoZTTOd8m7es_Eo" | ||
>Learn more</UiButton | ||
> | ||
<div class="block text-sm"> | ||
<span class="text-skin-bg/70">Or, go back to the </span> | ||
<a href="https://v1.snapshot.box" target="_blank" class="text-skin-bg" | ||
>previous interface</a | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,58 @@ | ||
import { supportsNullCurrent } from '@/networks'; | ||
import { getIndex as getVotingPowerIndex } from '@/stores/votingPowers'; | ||
import { Proposal, Space } from '@/types'; | ||
import { getIndex } from '@/stores/votingPowers'; | ||
import { NetworkID, Proposal, Space } from '@/types'; | ||
|
||
export function useVotingPower() { | ||
const votingPowersStore = useVotingPowersStore(); | ||
const { web3 } = useWeb3(); | ||
const { getCurrent } = useMetaStore(); | ||
|
||
const item = ref<Space | Proposal | undefined>(); | ||
const block = ref<number | null>(null); | ||
|
||
const space = computed(() => | ||
item.value && 'space' in item.value | ||
? (item.value?.space as Space) | ||
: item.value | ||
); | ||
function getLatestBlock(network: NetworkID): number | null { | ||
return supportsNullCurrent(network) ? null : getCurrent(network) || 0; | ||
} | ||
|
||
const proposal = computed(() => | ||
item.value && 'snapshot' in item.value | ||
? (item.value as Proposal) | ||
: undefined | ||
); | ||
function getProposalSnapshot(proposal: Proposal): number | null { | ||
return ( | ||
(proposal.state === 'pending' ? null : proposal.snapshot) || | ||
getLatestBlock(proposal.network) | ||
); | ||
} | ||
|
||
const proposalSnapshot = computed<number | null>(() => { | ||
if (!proposal.value) return null; | ||
function getSnapshot( | ||
space: Space | Proposal['space'], | ||
proposal?: Proposal | ||
): number | null { | ||
return proposal | ||
? getProposalSnapshot(proposal) | ||
: getLatestBlock((space as Space).network); | ||
} | ||
|
||
return proposal.value.state === 'pending' | ||
? latestBlock(proposal.value) | ||
: proposal.value.snapshot; | ||
}); | ||
function fetch(space: Space | Proposal['space'], proposal?: Proposal) { | ||
if (!web3.value.account) return; | ||
|
||
const votingPower = computed( | ||
() => | ||
space.value && | ||
votingPowersStore.votingPowers.get( | ||
getVotingPowerIndex(space.value, block.value) | ||
) | ||
); | ||
votingPowersStore.fetch( | ||
proposal || (space as Space), | ||
web3.value.account, | ||
getSnapshot(space, proposal) | ||
); | ||
} | ||
|
||
function latestBlock(spaceOrProposal: Space | Proposal) { | ||
return supportsNullCurrent(spaceOrProposal.network) | ||
? null | ||
: getCurrent(spaceOrProposal.network) ?? 0; | ||
function get(space: Space | Proposal['space'], proposal?: Proposal) { | ||
return votingPowersStore.votingPowers.get( | ||
getIndex(proposal?.space || space, getSnapshot(space, proposal)) | ||
); | ||
} | ||
|
||
function reset() { | ||
votingPowersStore.reset(); | ||
} | ||
|
||
function fetch(spaceOrProposal: Space | Proposal) { | ||
if (!web3.value.account) return; | ||
item.value = spaceOrProposal; | ||
block.value = proposal.value | ||
? proposalSnapshot.value | ||
: latestBlock(space.value as Space); | ||
|
||
votingPowersStore.fetch(item.value, web3.value.account, block.value); | ||
} | ||
|
||
watch( | ||
() => web3.value.account, | ||
account => { | ||
if (!account) reset(); | ||
} | ||
); | ||
|
||
return { votingPower, fetch, reset }; | ||
return { get, fetch, reset }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters