Skip to content

Commit 4b2db91

Browse files
committed
add voting and refactor proposal card
1 parent 7269dae commit 4b2db91

11 files changed

+355
-35
lines changed

deploy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ version: "2.0"
33

44
services:
55
node:
6-
image: ghcr.io/stakefrites/website:v0.0.5
6+
image: ghcr.io/stakefrites/govmos:v0.0.2
77
expose:
88
- port: 80
99
accept:
10-
- stakefrites.co
10+
- govmos.stakefrites.co
1111
to:
1212
- global: true
1313

@@ -18,7 +18,7 @@ profiles:
1818
cpu:
1919
units: 1
2020
memory:
21-
size: 512Mi
21+
size: 256Mi
2222
storage:
2323
size: 100Mi
2424
placement:

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@vuetify/vite-plugin": "^1.0.0-alpha.0",
3131
"sass": "^1.38.0",
3232
"sass-loader": "^10.0.0",
33+
"ts-proto": "^1.110.4",
3334
"vite": "^2.9.0",
3435
"vue-cli-plugin-vuetify": "~2.4.8",
3536
"vuetify-loader": "^2.0.0-alpha.0"

src/App.vue

+17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
</div>
1111

1212
<v-spacer></v-spacer>
13+
<v-app-bar-title>
14+
<v-chip v-if="keplr" @click="disconnectKeplr()">{{ address }}</v-chip>
15+
<v-chip @click="connectKeplr()" v-else>Connect Wallet</v-chip>
16+
</v-app-bar-title>
1317
</v-app-bar>
1418
<v-container>
1519
<v-main>
@@ -39,6 +43,7 @@
3943

4044
<script>
4145
import HelloWorld from "./components/HelloWorld.vue";
46+
import { mapGetters } from "vuex";
4247
4348
export default {
4449
name: "App",
@@ -48,6 +53,18 @@ export default {
4853
},
4954
async created() {
5055
await this.$store.dispatch("fetchNetworks");
56+
await this.$store.dispatch("fetchAddress");
57+
},
58+
computed: {
59+
...mapGetters({ address: "getAddress", keplr: "getKeplr" }),
60+
},
61+
methods: {
62+
async connectKeplr() {
63+
await this.$store.dispatch("connectKeplr");
64+
},
65+
async disconnectKeplr() {
66+
await this.$store.dispatch("disconnectKeplr");
67+
},
5168
},
5269
5370
data: () => ({

src/components/Proposal.vue

+123-26
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,98 @@
11
<template>
22
<v-col md="12" sm="12" xs="12" lg="6" xl="6">
3-
<v-card class="scroll" height="400">
4-
<v-card-title
5-
><v-chip small class="mr-3">{{ proposal.proposalId }}</v-chip
3+
<v-card height="500">
4+
<v-card-header>
5+
<v-chip small class="mr-3">{{ proposal.proposalId }}</v-chip>
6+
</v-card-header>
7+
<v-card-title class=""
68
>{{ content.title }}
7-
<v-chip color="primary" pill class="ml-3">{{
9+
<v-chip color="green" pill class="ml-3">{{
810
status
911
}}</v-chip></v-card-title
1012
>
1113
<v-card-subtitle>{{ type }}</v-card-subtitle>
12-
<v-list-item three-line>
13-
<v-list-item-content>
14-
<v-list-item-title class="text-h5"> Results </v-list-item-title>
15-
<v-list-item-subtitle>
16-
<strong>Yes</strong> -
17-
{{ proposal.finalTallyResult.yes }}
18-
</v-list-item-subtitle>
19-
<v-list-item-subtitle>
20-
<strong>No</strong> -
21-
{{ proposal.finalTallyResult.no }}
22-
</v-list-item-subtitle>
23-
<v-list-item-subtitle>
24-
<strong>No with veto</strong> -
25-
{{ proposal.finalTallyResult.noWithVeto }}
26-
</v-list-item-subtitle>
27-
<v-list-item-subtitle>
28-
<strong>Abstain</strong> -
29-
{{ proposal.finalTallyResult.abstain }}
30-
</v-list-item-subtitle>
31-
</v-list-item-content>
32-
</v-list-item>
33-
<v-card-text>{{ content.description }}</v-card-text>
14+
<v-card-text>
15+
<v-list-item-title class="text-h5 my-5"> Results </v-list-item-title>
16+
<v-row>
17+
<v-col>
18+
<v-chip>
19+
<strong class="mr-2">Yes</strong
20+
>{{ proposal.finalTallyResult.yes }}
21+
</v-chip>
22+
</v-col>
23+
<v-col>
24+
<v-chip>
25+
<strong class="mr-2">No</strong>
26+
{{ proposal.finalTallyResult.no }}
27+
</v-chip>
28+
</v-col>
29+
</v-row>
30+
<v-row>
31+
<v-col>
32+
<v-chip>
33+
<strong class="mr-2">No with veto</strong>
34+
{{ proposal.finalTallyResult.noWithVeto }}
35+
</v-chip>
36+
</v-col>
37+
<v-col>
38+
<v-chip>
39+
<strong class="mr-2">Abstain</strong
40+
>{{ proposal.finalTallyResult.abstain }}
41+
</v-chip>
42+
</v-col>
43+
</v-row>
44+
</v-card-text>
45+
46+
<v-card-text>{{ description }}</v-card-text>
47+
<v-card-actions>
48+
<v-btn variant="contained-text" color="primary"
49+
>Vote
50+
<v-dialog v-model="dialog" activator="parent">
51+
<v-card>
52+
<v-card-text> Cast your vote </v-card-text>
53+
<v-card-text>
54+
<v-radio-group v-model="vote" mandatory>
55+
<v-radio label="Yes" value="yes" v-model="vote"></v-radio>
56+
<v-radio label="No" value="no" v-model="vote"></v-radio>
57+
<v-radio
58+
label="No With Veto"
59+
value="noWithVeto"
60+
v-model="vote"
61+
></v-radio>
62+
<v-radio
63+
label="Abstain"
64+
value="abstain"
65+
v-model="vote"
66+
></v-radio>
67+
</v-radio-group>
68+
</v-card-text>
69+
70+
<v-card-actions>
71+
<v-btn
72+
@click="castVote()"
73+
variant="contained-text"
74+
color="primary"
75+
size="large"
76+
>
77+
Vote
78+
</v-btn>
79+
<v-btn @click="closeDialog()"> Close Dialog </v-btn>
80+
</v-card-actions>
81+
</v-card>
82+
</v-dialog></v-btn
83+
>
84+
<v-btn>See More</v-btn>
85+
</v-card-actions>
3486
</v-card>
3587
</v-col>
3688
</template>
3789

3890
<script>
91+
import { mapGetters } from "vuex";
3992
import Coin from "@/components/Coin.vue";
4093
import { Proposal, TextProposal } from "cosmjs-types/cosmos/gov/v1beta1/gov";
4194
import { Registry } from "@cosmjs/proto-signing";
95+
import { ClientUpdateProposal } from "cosmjs-types/ibc/core/client/v1/client";
4296
import { ParameterChangeProposal } from "cosmjs-types/cosmos/params/v1beta1/params";
4397
import { SoftwareUpgradeProposal } from "cosmjs-types/cosmos/upgrade/v1beta1/upgrade";
4498
import { CommunityPoolSpendProposal } from "cosmjs-types/cosmos/distribution/v1beta1/distribution";
@@ -83,16 +137,51 @@ const proposalType = (type) => {
83137
case "/cosmos.gov.v1beta1.SoftwareUpgradeProposal":
84138
return "Software Upgrade";
85139
break;
140+
case "/ibc.core.client.v1.ClientUpdateProposal":
141+
return "IBC Client Update";
142+
break;
86143
default:
87144
break;
88145
}
89146
};
147+
148+
const excerpt = (string) => {
149+
if (string.length > 350) {
150+
return string.substring(0, 350) + "...";
151+
} else {
152+
return string;
153+
}
154+
};
90155
export default {
91156
name: "Proposal",
92157
components: { Coin },
158+
data() {
159+
return {
160+
dialog: false,
161+
vote: "",
162+
};
163+
},
93164
props: {
94165
proposal: Object,
95166
},
167+
methods: {
168+
closeDialog() {
169+
this.dialog = false;
170+
this.vote = "";
171+
},
172+
castVote() {
173+
this.$store.dispatch("castVote", {
174+
proposalId: this.proposal.proposalId,
175+
option: this.vote,
176+
voter: this.$store.state.wallet.address,
177+
});
178+
},
179+
},
180+
methods: {
181+
...mapGetters({
182+
signingClient: "getSigningClient",
183+
}),
184+
},
96185
computed: {
97186
status() {
98187
return proposalStatus(this.$props.proposal.status);
@@ -112,8 +201,15 @@ export default {
112201
"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal",
113202
CommunityPoolSpendProposal
114203
);
204+
registry.register(
205+
"/ibc.core.client.v1.ClientUpdateProposal",
206+
ClientUpdateProposal
207+
);
115208
return registry;
116209
},
210+
description() {
211+
return excerpt(this.content.description);
212+
},
117213
content() {
118214
return this.registry.decode(this.$props.proposal.content);
119215
},
@@ -126,6 +222,7 @@ export default {
126222

127223
<style scoped>
128224
.scroll {
225+
max-height: 100px;
129226
overflow-y: scroll;
130227
}
131228
</style>

src/components/Vote.vue

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div>Vote</div>
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: "Vote",
8+
data: () => ({}),
9+
methods: {},
10+
computed: {},
11+
};
12+
</script>
13+
14+
<!-- Add "scoped" attribute to limit CSS to this component only -->
15+
<style scoped></style>

src/router/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const routes = [
33
{
44
path: "/",
55
name: "home",
6+
//component: () => import("../views/SelectChainsView.vue"),
67
component: () => import("../views/HomeView.vue"),
78
},
89
{

0 commit comments

Comments
 (0)