/
proposaldetails.go
86 lines (74 loc) · 2.5 KB
/
proposaldetails.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2017-2019 The Fonero developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package commands
import (
"fmt"
"github.com/fonero-project/politeia/politeiawww/api/www/v1"
)
// ProposalDetailsCmd retrieves the details of a proposal.
type ProposalDetailsCmd struct {
Args struct {
Token string `positional-arg-name:"token" required:"true"` // Censorship token
Version string `positional-arg-name:"version"` // Proposal version
} `positional-args:"true"`
}
// Execute executes the proposal details command.
func (cmd *ProposalDetailsCmd) Execute(args []string) error {
// Get server's public key
vr, err := client.Version()
if err != nil {
return err
}
// Get proposal
pdr, err := client.ProposalDetails(cmd.Args.Token,
&v1.ProposalsDetails{
Version: cmd.Args.Version,
})
if err != nil {
return err
}
// Verify proposal censorship record
err = verifyProposal(pdr.Proposal, vr.PubKey)
if err != nil {
return fmt.Errorf("unable to verify proposal %v: %v",
pdr.Proposal.CensorshipRecord.Token, err)
}
// Print proposal details
return printJSON(pdr)
}
// proposalDetailsHelpMsg is the output for the help command when
// 'proposaldetails' is specified.
const proposalDetailsHelpMsg = `proposaldetails "token" "version"
Get a proposal.
Arguments:
1. token (string, required) Censorship token
2. version (string, optional) Proposal version
Result:
{
"proposal": {
"name": (string) Suggested short proposal name
"state": (PropStateT) Current state of proposal
"status": (PropStatusT) Current status of proposal
"timestamp": (int64) Timestamp of last update of proposal
"userid": (string) ID of user who submitted proposal
"username": (string) Username of user who submitted proposal
"publickey": (string) Public key used to sign proposal
"signature": (string) Signature of merkle root
"files": [
{
"name": (string) Filename
"mime": (string) Mime type
"digest": (string) File digest
"payload": (string) File payload
}
],
"numcomments": (uint) Number of comments on the proposal
"version": (string) Version of proposal
"censorshiprecord": {
"token": (string) Censorship token
"merkle": (string) Merkle root of proposal
"signature": (string) Server side signature of []byte(Merkle+Token)
}
}
}`