-
Notifications
You must be signed in to change notification settings - Fork 558
/
gov.go
68 lines (54 loc) · 1.91 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
package types
import (
"fmt"
"strings"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
const (
ProposalTypeDenomPairTakerFee = "DenomPairTakerFee"
)
func init() {
govtypesv1.RegisterProposalType(ProposalTypeDenomPairTakerFee)
}
var (
_ govtypesv1.Content = &DenomPairTakerFeeProposal{}
)
// NewDenomPairTakerFeeProposal returns a new instance of a denom pair taker fee proposal struct.
func NewDenomPairTakerFeeProposal(title, description string, records []DenomPairTakerFee) govtypesv1.Content {
return &DenomPairTakerFeeProposal{
Title: title,
Description: description,
DenomPairTakerFee: records,
}
}
func (p *DenomPairTakerFeeProposal) GetTitle() string { return p.Title }
// GetDescription gets the description of the proposal
func (p *DenomPairTakerFeeProposal) GetDescription() string { return p.Description }
// ProposalRoute returns the router key for the proposal
func (p *DenomPairTakerFeeProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of the proposal
func (p *DenomPairTakerFeeProposal) ProposalType() string {
return ProposalTypeDenomPairTakerFee
}
// ValidateBasic validates a governance proposal's abstract and basic contents
func (p *DenomPairTakerFeeProposal) ValidateBasic() error {
err := govtypesv1.ValidateAbstract(p)
if err != nil {
return err
}
return validateDenomPairTakerFees(p.DenomPairTakerFee)
}
// String returns a string containing the denom pair taker fee proposal.
func (p DenomPairTakerFeeProposal) String() string {
recordsStr := ""
for _, record := range p.DenomPairTakerFee {
recordsStr = recordsStr + fmt.Sprintf("(Denom0: %s, Denom1: %s, TakerFee: %s) ", record.Denom0, record.Denom1, record.TakerFee.String())
}
var b strings.Builder
b.WriteString(fmt.Sprintf(`Denom Pair Taker Fee Proposal:
Title: %s
Description: %s
Records: %s
`, p.Title, p.Description, recordsStr))
return b.String()
}