Allow JSON input for proof specs in tendermint client (#6506)
* Allow JSON input for proof specs in tendermint client * fix build
This commit is contained in:
parent
01b89bd9b3
commit
dcd578183d
|
@ -42,8 +42,8 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
Short: "create new tendermint client",
|
Short: "create new tendermint client",
|
||||||
Long: `Create a new tendermint IBC client.
|
Long: `Create a new tendermint IBC client.
|
||||||
- 'trust-level' flag can be a fraction (eg: '1/3') or 'default'
|
- 'trust-level' flag can be a fraction (eg: '1/3') or 'default'
|
||||||
- 'proof-specs' flag can be a comma-separated list of strings (eg: 'ics23:simple,ics23:iavl') or 'default'`,
|
- 'proof-specs' flag can be JSON input, a path to a .json file or 'default'`,
|
||||||
Example: fmt.Sprintf("%s tx ibc %s create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --trust-level default --from node0 --home ../node0/<app>cli --chain-id $CID", version.ClientName, ibctmtypes.SubModuleName),
|
Example: fmt.Sprintf("%s tx ibc %s create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --trust-level default --proof-specs [path/to/proof-specs.json] --from node0 --home ../node0/<app>cli --chain-id $CID", version.ClientName, ibctmtypes.SubModuleName),
|
||||||
Args: cobra.ExactArgs(5),
|
Args: cobra.ExactArgs(5),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
inBuf := bufio.NewReader(cmd.InOrStdin())
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||||
|
@ -57,7 +57,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
// check for file path if JSON input is not provided
|
// check for file path if JSON input is not provided
|
||||||
contents, err := ioutil.ReadFile(args[1])
|
contents, err := ioutil.ReadFile(args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("neither JSON input nor path to .json file were provided")
|
return errors.New("neither JSON input nor path to .json file were provided for consensus header")
|
||||||
}
|
}
|
||||||
if err := cdc.UnmarshalJSON(contents, &header); err != nil {
|
if err := cdc.UnmarshalJSON(contents, &header); err != nil {
|
||||||
return errors.Wrap(err, "error unmarshalling consensus header file")
|
return errors.Wrap(err, "error unmarshalling consensus header file")
|
||||||
|
@ -97,15 +97,17 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
spc := viper.GetString(flagProofSpecs)
|
spc := viper.GetString(flagProofSpecs)
|
||||||
|
if spc == "default" {
|
||||||
// Currently supports SDK chain or simple kvstore tendermint chain
|
|
||||||
switch spc {
|
|
||||||
case "default":
|
|
||||||
specs = commitmenttypes.GetSDKSpecs()
|
specs = commitmenttypes.GetSDKSpecs()
|
||||||
case "simple":
|
} else if err := cdc.UnmarshalJSON([]byte(spc), &specs); err != nil {
|
||||||
specs = []*ics23.ProofSpec{ics23.TendermintSpec}
|
// check for file path if JSON input not provided
|
||||||
default:
|
contents, err := ioutil.ReadFile(spc)
|
||||||
return fmt.Errorf("proof spec: %s isn't supported", spc)
|
if err != nil {
|
||||||
|
return errors.New("neither JSON input nor path to .json file was provided for proof specs flag")
|
||||||
|
}
|
||||||
|
if err := cdc.UnmarshalJSON(contents, &specs); err != nil {
|
||||||
|
return errors.Wrap(err, "error unmarshalling proof specs file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := ibctmtypes.NewMsgCreateClient(
|
msg := ibctmtypes.NewMsgCreateClient(
|
||||||
|
|
Loading…
Reference in New Issue