-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
108 lines (94 loc) · 4.5 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package utils
import (
"github.com/evoblockchain/evochain/x/evm/types"
"io/ioutil"
"github.com/evoblockchain/evochain/libs/cosmos-sdk/codec"
sdk "github.com/evoblockchain/evochain/libs/cosmos-sdk/types"
)
type (
// ManageContractDeploymentWhitelistProposalJSON defines a ManageContractDeploymentWhitelistProposal with a deposit used
// to parse manage whitelist proposals from a JSON file.
ManageContractDeploymentWhitelistProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
DistributorAddrs types.AddressList `json:"distributor_addresses" yaml:"distributor_addresses"`
IsAdded bool `json:"is_added" yaml:"is_added"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
// ManageContractBlockedListProposalJSON defines a ManageContractBlockedListProposal with a deposit used to parse
// manage blocked list proposals from a JSON file.
ManageContractBlockedListProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
ContractAddrs types.AddressList `json:"contract_addresses" yaml:"contract_addresses"`
IsAdded bool `json:"is_added" yaml:"is_added"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
// ManageContractMethodBlockedListProposalJSON defines a ManageContractMethodBlockedListProposal with a deposit used to parse
// manage contract method blocked list proposals from a JSON file.
ManageContractMethodBlockedListProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
ContractList types.BlockedContractList `json:"contract_addresses" yaml:"contract_addresses"`
IsAdded bool `json:"is_added" yaml:"is_added"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
// ManageSysContractAddressProposalJSON defines a ManageSysContractAddressProposal with a deposit used to parse
// manage system contract address proposals from a JSON file.
ManageSysContractAddressProposalJSON struct {
Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
// Contract Address
ContractAddr sdk.AccAddress `json:"contract_address" yaml:"contract_address"`
IsAdded bool `json:"is_added" yaml:"is_added"`
Deposit sdk.SysCoins `json:"deposit" yaml:"deposit"`
}
ResponseBlockContract struct {
Address string `json:"address" yaml:"address"`
BlockMethods types.ContractMethods `json:"block_methods" yaml:"block_methods"`
}
ResponseSysContractAddress struct {
Address string `json:"address" yaml:"address"`
}
)
// ParseManageContractDeploymentWhitelistProposalJSON parses json from proposal file to ManageContractDeploymentWhitelistProposalJSON
// struct
func ParseManageContractDeploymentWhitelistProposalJSON(cdc *codec.Codec, proposalFilePath string) (
proposal ManageContractDeploymentWhitelistProposalJSON, err error) {
contents, err := ioutil.ReadFile(proposalFilePath)
if err != nil {
return
}
cdc.MustUnmarshalJSON(contents, &proposal)
return
}
// ParseManageContractBlockedListProposalJSON parses json from proposal file to ManageContractBlockedListProposalJSON struct
func ParseManageContractBlockedListProposalJSON(cdc *codec.Codec, proposalFilePath string) (
proposal ManageContractBlockedListProposalJSON, err error) {
contents, err := ioutil.ReadFile(proposalFilePath)
if err != nil {
return
}
cdc.MustUnmarshalJSON(contents, &proposal)
return
}
// ParseManageContractMethodBlockedListProposalJSON parses json from proposal file to ManageContractBlockedListProposalJSON struct
func ParseManageContractMethodBlockedListProposalJSON(cdc *codec.Codec, proposalFilePath string) (
proposal ManageContractMethodBlockedListProposalJSON, err error) {
contents, err := ioutil.ReadFile(proposalFilePath)
if err != nil {
return
}
cdc.MustUnmarshalJSON(contents, &proposal)
return
}
// ManageSysContractAddressProposalJSON parses json from proposal file to ManageSysContractAddressProposal struct
func ParseManageSysContractAddressProposalJSON(cdc *codec.Codec, proposalFilePath string) (
proposal ManageSysContractAddressProposalJSON, err error) {
contents, err := ioutil.ReadFile(proposalFilePath)
if err != nil {
return
}
cdc.MustUnmarshalJSON(contents, &proposal)
return
}