-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
72 lines (57 loc) · 1.18 KB
/
params.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
package show
import (
"fmt"
"github.com/0xDaoChain/dao-chain/chain"
"github.com/0xDaoChain/dao-chain/command"
"github.com/0xDaoChain/dao-chain/helper/config"
"github.com/0xDaoChain/dao-chain/types"
)
const (
chainFlag = "chain"
)
var (
params = &showParams{}
)
type showParams struct {
// genesis file path
genesisPath string
// deployment whitelist
whitelists Whitelists
}
type Whitelists struct {
deployment []types.Address
}
func (p *showParams) initRawParams() error {
// init genesis configuration
if err := p.initWhitelists(); err != nil {
return err
}
return nil
}
func (p *showParams) initWhitelists() error {
// import genesis configuration
genesisConfig, err := chain.Import(p.genesisPath)
if err != nil {
return fmt.Errorf(
"failed to load chain config from %s: %w",
p.genesisPath,
err,
)
}
// fetch whitelists
deploymentWhitelist, err := config.GetDeploymentWhitelist(genesisConfig)
if err != nil {
return err
}
// set whitelists
p.whitelists = Whitelists{
deployment: deploymentWhitelist,
}
return nil
}
func (p *showParams) getResult() command.CommandResult {
result := &ShowResult{
Whitelists: p.whitelists,
}
return result
}