/
proposal.go
89 lines (68 loc) · 3.03 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
package types
import (
"fmt"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
// ProposalTypeColdStorageTransfer defines the type for a ColdStorageTransferProposal
ProposalTypeColdStorageTransfer = "ColdStorageTransfer"
ProposalTypeTokenInfosChange = "TokenInfosChange"
)
// Assert ColdStorageTransferProposal implements govtypes.Content at compile-time
var _ govtypes.Content = &ColdStorageTransferProposal{}
var _ govtypes.Content = &TokenInfosChangeProposal{}
func init() {
govtypes.RegisterProposalType(ProposalTypeColdStorageTransfer)
govtypes.RegisterProposalType(ProposalTypeTokenInfosChange)
govtypes.RegisterProposalTypeCodec(&ColdStorageTransferProposal{}, "mhub2/ColdStorageTransferProposal")
govtypes.RegisterProposalTypeCodec(&TokenInfosChangeProposal{}, "mhub2/TokenInfosChangeProposal")
}
func NewColdStorageTransferProposal(chainId ChainID, amount sdk.Coins) *ColdStorageTransferProposal {
return &ColdStorageTransferProposal{chainId.String(), amount}
}
func NewTokenInfosChangeProposal(tokenInfos *TokenInfos) *TokenInfosChangeProposal {
return &TokenInfosChangeProposal{NewInfos: tokenInfos}
}
// GetTitle returns the title of a community pool spend proposal.
func (csp *ColdStorageTransferProposal) GetTitle() string { return "ColdStorageTransferProposal" }
// GetDescription returns the description of a community pool spend proposal.
func (csp *ColdStorageTransferProposal) GetDescription() string { return "ColdStorageTransferProposal" }
// GetDescription returns the routing key of a community pool spend proposal.
func (csp *ColdStorageTransferProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of a community pool spend proposal.
func (csp *ColdStorageTransferProposal) ProposalType() string { return ProposalTypeColdStorageTransfer }
// ValidateBasic runs basic stateless validity checks
func (csp *ColdStorageTransferProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(csp)
if err != nil {
return err
}
return nil
}
// String implements the Stringer interface.
func (csp ColdStorageTransferProposal) String() string {
var b strings.Builder
b.WriteString(fmt.Sprintf(`Cold Storage Transfer Proposal:
Amount: %s`, csp.Amount))
return b.String()
}
func (tic *TokenInfosChangeProposal) GetTitle() string { return "TokenInfosChangeProposal" }
func (tic *TokenInfosChangeProposal) GetDescription() string { return "TokenInfosChangeProposal" }
func (tic *TokenInfosChangeProposal) ProposalRoute() string { return RouterKey }
func (tic *TokenInfosChangeProposal) ProposalType() string { return ProposalTypeTokenInfosChange }
func (tic *TokenInfosChangeProposal) ValidateBasic() error {
err := govtypes.ValidateAbstract(tic)
if err != nil {
return err
}
return nil
}
// String implements the Stringer interface.
func (tic TokenInfosChangeProposal) String() string {
var b strings.Builder
b.WriteString(fmt.Sprintf(`Token Infos Change Proposal:
New Tokens: %s`, tic.NewInfos))
return b.String()
}