-
Notifications
You must be signed in to change notification settings - Fork 368
/
proposal.go
117 lines (96 loc) · 3.99 KB
/
proposal.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package types
import (
fmt "fmt"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
// ProposalTypeCommunityPoolDeposit defines the type for a CommunityPoolDepositProposal
ProposalTypeCommunityPoolDeposit = "CommunityPoolDeposit"
// ProposalTypeCommunityPoolWithdraw defines the type for a CommunityPoolDepositProposal
ProposalTypeCommunityPoolWithdraw = "CommunityPoolWithdraw"
)
// Assert CommunityPoolDepositProposal implements govtypes.Content at compile-time
var (
_ govtypes.Content = &CommunityPoolDepositProposal{}
_ govtypes.Content = &CommunityPoolWithdrawProposal{}
)
func init() {
govtypes.RegisterProposalType(ProposalTypeCommunityPoolDeposit)
govtypes.RegisterProposalTypeCodec(&CommunityPoolDepositProposal{}, "kava/CommunityPoolDepositProposal")
govtypes.RegisterProposalType(ProposalTypeCommunityPoolWithdraw)
govtypes.RegisterProposalTypeCodec(&CommunityPoolWithdrawProposal{}, "kava/CommunityPoolWithdrawProposal")
}
// NewCommunityPoolDepositProposal creates a new community pool deposit proposal.
func NewCommunityPoolDepositProposal(title, description string, amount sdk.Coin) *CommunityPoolDepositProposal {
return &CommunityPoolDepositProposal{
Title: title,
Description: description,
Amount: amount,
}
}
// GetTitle returns the title of a community pool deposit proposal.
func (cdp *CommunityPoolDepositProposal) GetTitle() string { return cdp.Title }
// GetDescription returns the description of a community pool deposit proposal.
func (cdp *CommunityPoolDepositProposal) GetDescription() string { return cdp.Description }
// GetDescription returns the routing key of a community pool deposit proposal.
func (cdp *CommunityPoolDepositProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of a community pool deposit proposal.
func (cdp *CommunityPoolDepositProposal) ProposalType() string {
return ProposalTypeCommunityPoolDeposit
}
// String implements fmt.Stringer
func (cdp *CommunityPoolDepositProposal) String() string {
var b strings.Builder
b.WriteString(fmt.Sprintf(`Community Pool Deposit Proposal:
Title: %s
Description: %s
Amount: %s
`, cdp.Title, cdp.Description, cdp.Amount))
return b.String()
}
// ValidateBasic stateless validation of a community pool multi-spend proposal.
func (cdp *CommunityPoolDepositProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(cdp)
if err != nil {
return err
}
return cdp.Amount.Validate()
}
// NewCommunityPoolWithdrawProposal creates a new community pool deposit proposal.
func NewCommunityPoolWithdrawProposal(title, description string, amount sdk.Coin) *CommunityPoolWithdrawProposal {
return &CommunityPoolWithdrawProposal{
Title: title,
Description: description,
Amount: amount,
}
}
// GetTitle returns the title of a community pool withdraw proposal.
func (cdp *CommunityPoolWithdrawProposal) GetTitle() string { return cdp.Title }
// GetDescription returns the description of a community pool withdraw proposal.
func (cdp *CommunityPoolWithdrawProposal) GetDescription() string { return cdp.Description }
// GetDescription returns the routing key of a community pool withdraw proposal.
func (cdp *CommunityPoolWithdrawProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of a community pool withdraw proposal.
func (cdp *CommunityPoolWithdrawProposal) ProposalType() string {
return ProposalTypeCommunityPoolWithdraw
}
// String implements fmt.Stringer
func (cdp *CommunityPoolWithdrawProposal) String() string {
var b strings.Builder
b.WriteString(fmt.Sprintf(`Community Pool Withdraw Proposal:
Title: %s
Description: %s
Amount: %s
`, cdp.Title, cdp.Description, cdp.Amount))
return b.String()
}
// ValidateBasic stateless validation of a community pool multi-spend proposal.
func (cdp *CommunityPoolWithdrawProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(cdp)
if err != nil {
return err
}
return cdp.Amount.Validate()
}