sv-vue v0.0.6
SecureVote Light - Vue Components
Vue.js UI components used for SecureVote light
This this library of components has been designed to allow components created by SecureVote to be reused easily and extensibly across projects.
Usage
import {BallotTile} from 'sv-vue'
components: {
BallotTile
}The library exports a number of vue components that can be imported into Vue.js projects.
Components
NOTE - This library is in progress and more components are still being added
BallotTile
<ballot-tile :ballot="globalBallotObject" :showPointer="true" @ballotTileClicked="handleClickEvent()" />import {BallotTile} from 'sv-vue'Props
ballot- Object, passed in the format of a global ballot object, specified in the core concepts below. The component is used for displaying the ballot information it is passed only.showPointer- Boolean, used to specify if the hover state should be present or not.
Events
ballotTileClicked- Occurs when the component is clicked and passes it's ownballotobject back in the event. This can be used for routing, or whatever else is needed.
Component Styling
Styling on the components has been kept as minimal as possible. Where customisation is required, this should take place in a parent component.
Key concepts - Ballots
Ballots are one of the key data structures used within SV Light, there are two main formats that they are used within applications using SV Light.
The ballot spec
The ballot spec is standardised across ballot versions. We are currently on ballot version 2 which has the following specifications:
ballotVersionNumber, specifying the ballot spec versionballotInnerObject, containing all the relevant content: -ballotTitleString, self explanatory -shortDescString, a shorter version of the description -longDescString, a longer version of the description. In the future we may aim to support markdown here. -subGroupString, this is currently unused on the tokenvote platform, but is being used to create categories for the Swarm Fund liquid democracy voting module. Can benull-discussionLinkString, url for where the proposal can be discussed. Can benullif there is no link. -encryptionPKString, public key required for ballot encryption. Can benullfor unencrypted ballotsoptionsVersionNumber, specifies the type of ballot (1: Ranged ballot, 2: Binary ballot, 3: Petition)optionsInnerObject, containing -optionsObject (ornull). This is where ranged vote options are specified. Should benullin the case of a binary vote or petition. -auxObject (ornull) currently unused but included for future extensibility.
Note - All fields are required, even if they are not being used. If this is the case, then the value should be set to null
Example ballot spec:
{
"ballotVersion": 2,
"ballotInner": {
"ballotTitle": "Create a calculator for asset germination events",
"shortDesc": "It would be handy for users to see the expected return on their investments instantly in an easy to use calculator which shows them their profits or dividends from the investment. This may inspire more investment and accelerate renewable energy adoption.",
"longDesc": "It would be handy for users to see the expected return on their investments instantly in an easy to use calculator which shows them their profits or dividends from the investment. This may inspire more investment and accelerate renewable energy adoption.",
"subgroup": null,
"discussionLink": null,
"encryptionPK": null
},
"optionsVersion": 3,
"optionsInner": {
"options": null,
"aux": null
}
},The 'global' ballot object
In addition to the ballot spec, there are some additional values that are required to interact with ballots. The ballot spec is included as an object in the global ballot object.
The global ballot object includes the following:
indexNumber, the index of the ballot within the democracyerrorBoolean, flag to specify if there has been an error loading the ballot, or with the ballot contents itself.bbFarmAddressString, Ethereum address of the ballot box farm where votes on this particular ballot are stored and where results will be pulled from.ballotIdString, the ID of the ballot which can be used as a unique identifier,startTimeNumber, the starting time of the ballot. This is stored in the Index smart contract.endTimeNumber, the ending time of the ballot. Note: both of these are recorded as seconds, so multiply by 1000 to the milliseconds when creating javascript date object.ballotSpecObject, the ballot spec outlined in the section abovenVotesCastNumber, the number of votes castsubmissionBitsNumber, a number used to identify configuration of the ballot. TODO - Go into more detail here or link to the appropriate section.
{
"index": 0,
"error": false,
"bbFarmAddress": "0xB105035C563Ed14C17f6BeaCe07F4659C823322a",
"ballotId": "42364633109615598255588040701757143132188425043626538479181752808160",
"specHash": "0xae9ca2179246b7e880949f67f78c9508375d849540229e977bb244ebdbb9b2e0",
"startTime": 1530254801,
"endTime": 1531464178,
"ballotSpec": {
"ballotVersion": ...,
"ballotInner": ...,
"optionsVersion": ...,
"optionsInner": ...
},
"nVotesCast": 1,
"userHasVoted": false,
"submissionBits": 5
}