Skip to content

Commit

Permalink
improve: add oshhhnap integration into modal
Browse files Browse the repository at this point in the history
  • Loading branch information
james-a-morris committed Sep 25, 2023
1 parent 2b4f5e5 commit a76bc35
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 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 { timelockEncryptionForOshhhnap } from '@/helpers/oshhhnap';
const { web3Account } = useWeb3();
Expand Down Expand Up @@ -33,6 +34,7 @@ const { addVotedProposalId } = useProposals();
const { isGnosisAndNotSpaceNetwork } = useGnosis(props.space);
const isLoadingShutter = ref(false);
const isLoadingOshhnap = ref(false);
const symbols = computed(() =>
props.strategies.map(strategy => strategy.params.symbol || '')
Expand Down Expand Up @@ -69,19 +71,47 @@ async function voteShutter() {
});
}
async function voteOshhhnap() {
// TODO: Implement Oshhhnap
isLoadingOshhnap.value = true;
const timelockEncryptedChoice = await timelockEncryptionForOshhhnap(
JSON.stringify(props.selectedChoices),
props.proposal.id,
props.proposal.end
);
if (!timelockEncryptedChoice) return null;
const resultantVote = vote({
proposal: props.proposal,
choice: timelockEncryptedChoice,
privacy: 'oshhhnap',
reason: reason.value
});
isLoadingOshhnap.value = false;
return resultantVote;
}
async function vote(payload) {
return send(props.space, 'vote', payload);
}
async function handleSubmit() {
let result: { id: string; ipfs?: string } | null = null;
if (props.proposal.privacy === 'shutter') result = await voteShutter();
else
result = await vote({
proposal: props.proposal,
choice: props.selectedChoices,
reason: reason.value
});
switch (props.proposal.privacy) {
case 'shutter':
result = await voteShutter();
break;
case 'oshhhnap':
result = await voteOshhhnap();
break;
default:
result = await vote({
proposal: props.proposal,
choice: props.selectedChoices,
reason: reason.value
});
break;
}
console.log('Result', result);
Expand Down

0 comments on commit a76bc35

Please sign in to comment.