Skip to content

Commit

Permalink
initial version of snapshot voting, only support entering private keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ericet committed Nov 16, 2022
1 parent eab2694 commit fee7f12
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>
<%= htmlWebpackPlugin.options.title %>
Snapshot Voting by Ericet
</title>
</head>

Expand Down
7 changes: 6 additions & 1 deletion src/components/Accounts/AccountSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="font-general-semibold text-sm text-ternary-dark dark:text-ternary-light font-semibold mb-4"
v-for="(proposal, index) in proposals" :key="index">
<div class="flex justify-between items-center mx-2">
{{proposal.space}}:【{{ index+1 }}】
{{getSpace(proposal.space)}}:【{{ index+1 }}】
<span v-if="proposal.status_code == 'ready'">
<div class="group relative ">
<i data-feather="clock"
Expand Down Expand Up @@ -55,6 +55,11 @@ export default {
mounted() {
feather.replace();
},
methods:{
getSpace(id) {
return this.$store.state.spaceMap.get(id).name;
}
},
updated() {
feather.replace();
},
Expand Down
9 changes: 9 additions & 0 deletions src/components/KeyVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@ export default {
props: ["accounts"],
methods: {
async vote() {
this.clearVoteStatus();
for (let ac of this.accounts) {
let key = ac.key;
let proposals = ac.proposals;
this.startVoting(key, proposals);
}
},
clearVoteStatus() {
for (let account of this.accounts) {
for (let proposal of account.proposals) {
proposal.status_code = '';
proposal.status_message = '';
}
}
},
async startVoting(key, proposals) {
let wallet = getWallet(key);
for (let proposal of proposals) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeysInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
placeholder="One private key per line"
></textarea>
<AccountsGrid :accounts="accounts" />
<KeyVote :accounts="accounts" />
<KeyVote :accounts="accounts" v-if="accounts.length>0"/>
</div>
</template>

Expand Down
8 changes: 4 additions & 4 deletions src/config/spaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const spacesList = [
id: "sismo.eth",
name: "Sismo"
},
// {
// id:"plutusclub.eth",
// name:"Test"
// }
{
id:"plutusclub.eth",
name:"Test"
}
];
28 changes: 28 additions & 0 deletions src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@
class="mx-auto max-w-4xl"
v-if="proposals.length > 0"
/>
<div
v-if="proposals.length == 0 && ready"
class="mx-auto max-w-4xl mb-5 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
role="alert"
>
<span class="block sm:inline"
>No proposals found or all proposals have been voted!</span
>
<span class="absolute top-0 bottom-0 right-0 px-4 py-3" @click="close">
<svg
class="fill-current h-6 w-6 text-red-500"
role="button"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
>
<title>Close</title>
<path
d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"
/>
</svg>
</span>
</div>
</div>
<KeysInput
:proposals="proposals"
Expand Down Expand Up @@ -68,9 +90,13 @@ export default {
proposals: [],
spacesList: spacesList,
options: [],
ready: false,
};
},
methods: {
close() {
this.response = {};
},
populateOptions() {
this.options = [];
this.options.push({ text: 'All Spaces', value: 'all' });
Expand All @@ -91,6 +117,7 @@ export default {
});
},
async getActiveProposals() {
this.ready = false;
this.proposals = [];
if (this.selected === 'all') {
for (let space of this.spacesList) {
Expand All @@ -104,6 +131,7 @@ export default {
} else {
this.proposals = await getActiveProposals(this.selected);
}
this.ready = true;
},
},
components: { ProposalsList, AppFooter, KeysInput },
Expand Down

0 comments on commit fee7f12

Please sign in to comment.