forked from eoscanada/eos-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvote.go
32 lines (29 loc) · 869 Bytes
/
vote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package forum
import (
eos "github.com/eoscanada/eos-go"
)
// NewVote is an action representing a simple vote to be broadcast
// through the chain network.
func NewVote(voter eos.AccountName, proposalName eos.Name, voteValue uint8, voteJSON string) *eos.Action {
a := &eos.Action{
Account: ForumAN,
Name: ActN("vote"),
Authorization: []eos.PermissionLevel{
{Actor: voter, Permission: eos.PermissionName("active")},
},
ActionData: eos.NewActionData(Vote{
Voter: voter,
ProposalName: proposalName,
Vote: voteValue,
VoteJSON: voteJSON,
}),
}
return a
}
// Vote represents the `eosio.forum::vote` action.
type Vote struct {
Voter eos.AccountName `json:"voter"`
ProposalName eos.Name `json:"proposal_name"`
Vote uint8 `json:"vote"`
VoteJSON string `json:"vote_json"`
}