-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_distr_proposal.go
82 lines (65 loc) · 2.74 KB
/
utils_distr_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
package cli
import (
"io/ioutil"
"github.com/brc20-collab/brczero/libs/cosmos-sdk/codec"
sdk "github.com/brc20-collab/brczero/libs/cosmos-sdk/types"
)
type (
// ChangeDistributionTypeProposalJSON defines a ChangeDistributionTypeProposal with a deposit
ChangeDistributionTypeProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Type uint32 `json:"type" yaml:"type"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
// WithdrawRewardEnabledProposalJSON defines a WithdrawRewardEnabledProposal with a deposit
WithdrawRewardEnabledProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Enabled bool `json:"enabled" yaml:"enabled"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
// RewardTruncatePrecisonProposalJSON defines a RewardTruncatePrecisionProposal with a deposit
RewardTruncatePrecisonProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
Precision int64 `json:"precision" yaml:"precision"`
}
)
// ParseChangeDistributionTypeProposalJSON reads and parses a ChangeDistributionTypeProposalJSON from a file.
func ParseChangeDistributionTypeProposalJSON(cdc *codec.Codec, proposalFile string) (ChangeDistributionTypeProposalJSON, error) {
proposal := ChangeDistributionTypeProposalJSON{}
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
}
// ParseWithdrawRewardEnabledProposalJSON reads and parses a WithdrawRewardEnabledProposalJSON from a file.
func ParseWithdrawRewardEnabledProposalJSON(cdc *codec.Codec, proposalFile string) (WithdrawRewardEnabledProposalJSON, error) {
proposal := WithdrawRewardEnabledProposalJSON{}
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
}
// ParseRewardTruncatePrecisionProposalJSON reads and parses a RewardTruncatePrecisonProposalJSON from a file.
func ParseRewardTruncatePrecisionProposalJSON(cdc *codec.Codec, proposalFile string) (RewardTruncatePrecisonProposalJSON, error) {
proposal := RewardTruncatePrecisonProposalJSON{}
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
}