-
Notifications
You must be signed in to change notification settings - Fork 0
/
gov.go
70 lines (54 loc) · 1.61 KB
/
gov.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
package types
import (
"fmt"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
ProposalTypeUpdateFeeToken = "UpdateFeeToken"
)
func init() {
govtypes.RegisterProposalType(ProposalTypeUpdateFeeToken)
govtypes.RegisterProposalTypeCodec(&UpdateFeeTokenProposal{}, "merlins/UpdateFeeTokenProposal")
}
var _ govtypes.Content = &UpdateFeeTokenProposal{}
func NewUpdateFeeTokenProposal(title, description string, feeTokens []FeeToken) UpdateFeeTokenProposal {
return UpdateFeeTokenProposal{
Title: title,
Description: description,
Feetokens: feeTokens,
}
}
func (p *UpdateFeeTokenProposal) GetTitle() string { return p.Title }
func (p *UpdateFeeTokenProposal) GetDescription() string { return p.Description }
func (p *UpdateFeeTokenProposal) ProposalRoute() string { return RouterKey }
func (p *UpdateFeeTokenProposal) ProposalType() string {
return ProposalTypeUpdateFeeToken
}
func (p *UpdateFeeTokenProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}
for _, feeToken := range p.Feetokens {
if err := sdk.ValidateDenom(feeToken.Denom); err != nil {
return err
}
}
return nil
}
func (p UpdateFeeTokenProposal) String() string {
var b strings.Builder
for _, feeToken := range p.Feetokens {
b.WriteString(fmt.Sprintf("(Denom: %s, PoolID: %d) ", feeToken.Denom, feeToken.PoolID))
}
recordsStr := b.String()
b.Reset()
b.WriteString(fmt.Sprintf(`Update Fee Token Proposal:
Title: %s
Description: %s
Records: %s
`, p.Title, p.Description, recordsStr))
return b.String()
}