-
Notifications
You must be signed in to change notification settings - Fork 503
/
params.go
55 lines (44 loc) · 1.37 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
package deploy
import (
"errors"
"fmt"
"os"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/polybft"
)
const (
deployerKeyFlag = "deployer-key"
jsonRPCFlag = "json-rpc"
erc20AddrFlag = "erc20-token"
)
type deployParams struct {
genesisPath string
deployerKey string
jsonRPCAddress string
stakeTokenAddr string
rootERC20TokenAddr string
stakeManagerAddr string
proxyContractsAdmin string
isTestMode bool
}
func (ip *deployParams) validateFlags() error {
var err error
if _, err = os.Stat(ip.genesisPath); err != nil {
return fmt.Errorf("provided genesis path '%s' is invalid. Error: %w ", ip.genesisPath, err)
}
consensusCfg, err = polybft.LoadPolyBFTConfig(ip.genesisPath)
if err != nil {
return err
}
if consensusCfg.NativeTokenConfig == nil {
return errors.New("native token configuration is undefined")
}
// when using mintable native token, child native token on root chain gets mapped automatically
if consensusCfg.NativeTokenConfig.IsMintable && ip.rootERC20TokenAddr != "" {
return errors.New("if child chain native token is mintable, root native token must not pre-exist on root chain")
}
if params.stakeTokenAddr == "" {
return errors.New("stake token address is not provided")
}
return helper.ValidateProxyContractsAdmin(ip.proxyContractsAdmin)
}