-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.go
56 lines (50 loc) · 1.16 KB
/
config.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
package cmd
import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/datachainlab/harmony-cosmos-bridge-demo/relayer/chains/tendermint"
"github.com/hyperledger-labs/yui-relayer/core"
"github.com/spf13/cobra"
)
func configCmd(m codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "manage configuration file",
}
cmd.AddCommand(
generateChainConfigCmd(m),
)
return cmd
}
func generateChainConfigCmd(m codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "generate",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
// TODO make it configurable
c := tendermint.ChainConfig{
Key: "testkey",
ChainId: args[0],
RpcAddr: "http://localhost:26557",
AccountPrefix: "cosmos",
GasAdjustment: 1.5,
GasPrices: "0.025stake",
}
p := tendermint.ProverConfig{
TrustingPeriod: "336h",
}
config, err := core.NewChainProverConfig(m, &c, &p)
if err != nil {
return err
}
bz, err := json.Marshal(config)
if err != nil {
return err
}
fmt.Println(string(bz))
return nil
},
}
return cmd
}