/
proposal.go
51 lines (40 loc) · 1.5 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
package utils
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/anathatech/project-anatha/x/distribution/internal/types"
"io/ioutil"
)
type DevelopmentFundDistributionProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Amount sdk.Coins `json:"amount" yaml:"amount"`
Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"`
}
func ParseDevelopmentFundDistributionProposalJSON(cdc *codec.Codec, proposalFile string) (DevelopmentFundDistributionProposalJSON, error) {
proposal := DevelopmentFundDistributionProposalJSON{}
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
}
type SecurityTokenFundDistributionProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
Recipients []types.Recipients `json:"recipients" yaml:"recipients"`
}
func ParseSecurityTokenFundDistributionProposalJSON(cdc *codec.Codec, proposalFile string) (SecurityTokenFundDistributionProposalJSON, error) {
proposal := SecurityTokenFundDistributionProposalJSON{}
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
}