/
utils.go
59 lines (46 loc) · 1.73 KB
/
utils.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
package cli
import (
"io/ioutil"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type (
// TaxRateUpdateProposalJSON defines a TaxRateUpdateProposal with a deposit
TaxRateUpdateProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
TaxRate sdk.Dec `json:"tax_rate" yaml:"tax_rate"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
}
// RewardWeightUpdateProposalJSON defines a RewardWeightUpdateProposal with a deposit
RewardWeightUpdateProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
RewardWeight sdk.Dec `json:"tax_rate" yaml:"tax_rate"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
}
)
// ParseTaxRateUpdateProposalJSON reads and parses a TaxRateUpdateProposalJSON from a file.
func ParseTaxRateUpdateProposalJSON(cdc *codec.Codec, proposalFile string) (TaxRateUpdateProposalJSON, error) {
proposal := TaxRateUpdateProposalJSON{}
contents, err := ioutil.ReadFile(proposalFile)
if err != nil {
return proposal, err
}
if err := cdc.UnmarshalJSON(contents, &proposal); err != nil {
return proposal, err
}
return proposal, nil
}
// ParseRewardWeightUpdateProposalJSON reads and parses a RewardWeightUpdateProposalJSON from a file.
func ParseRewardWeightUpdateProposalJSON(cdc *codec.Codec, proposalFile string) (RewardWeightUpdateProposalJSON, error) {
proposal := RewardWeightUpdateProposalJSON{}
contents, err := ioutil.ReadFile(proposalFile)
if err != nil {
return proposal, err
}
if err := cdc.UnmarshalJSON(contents, &proposal); err != nil {
return proposal, err
}
return proposal, nil
}