Merge PR #3803: Validator Creation Updates

This commit is contained in:
Alexander Bezobchuk
2019-03-05 17:55:46 +01:00
committed by Christopher Goes
parent 57fe79ffbf
commit 51c03aa6fe
11 changed files with 52 additions and 239 deletions
-2
View File
@@ -8,7 +8,6 @@ import (
// nolint
const (
FlagAddressDelegator = "address-delegator"
FlagAddressValidator = "validator"
FlagAddressValidatorSrc = "addr-validator-source"
FlagAddressValidatorDst = "addr-validator-dest"
@@ -67,7 +66,6 @@ func init() {
fsDescriptionEdit.String(FlagWebsite, types.DoNotModifyDesc, "The validator's (optional) website")
fsDescriptionEdit.String(FlagDetails, types.DoNotModifyDesc, "The validator's (optional) details")
fsValidator.String(FlagAddressValidator, "", "The Bech32 address of the validator")
fsDelegator.String(FlagAddressDelegator, "", "The Bech32 address of the delegator")
fsRedelegation.String(FlagAddressValidatorSrc, "", "The Bech32 address of the source validator")
fsRedelegation.String(FlagAddressValidatorDst, "", "The Bech32 address of the destination validator")
}
+5 -18
View File
@@ -44,7 +44,7 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command {
cmd.Flags().AddFlagSet(fsDescriptionCreate)
cmd.Flags().AddFlagSet(FsCommissionCreate)
cmd.Flags().AddFlagSet(FsMinSelfDelegation)
cmd.Flags().AddFlagSet(fsDelegator)
cmd.Flags().String(FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", client.FlagGenerateOnly))
cmd.Flags().String(FlagNodeID, "", "The node's ID")
@@ -259,23 +259,9 @@ func BuildCreateValidatorMsg(cliCtx context.CLIContext, txBldr authtxb.TxBuilder
return txBldr, nil, fmt.Errorf(staking.ErrMinSelfDelegationInvalid(staking.DefaultCodespace).Error())
}
delAddr := viper.GetString(FlagAddressDelegator)
var msg sdk.Msg
if delAddr != "" {
delAddr, err := sdk.AccAddressFromBech32(delAddr)
if err != nil {
return txBldr, nil, err
}
msg = staking.NewMsgCreateValidatorOnBehalfOf(
delAddr, sdk.ValAddress(valAddr), pk, amount, description, commissionMsg, minSelfDelegation,
)
} else {
msg = staking.NewMsgCreateValidator(
sdk.ValAddress(valAddr), pk, amount, description, commissionMsg, minSelfDelegation,
)
}
msg := staking.NewMsgCreateValidator(
sdk.ValAddress(valAddr), pk, amount, description, commissionMsg, minSelfDelegation,
)
if viper.GetBool(client.FlagGenerateOnly) {
ip := viper.GetString(FlagIP)
@@ -284,5 +270,6 @@ func BuildCreateValidatorMsg(cliCtx context.CLIContext, txBldr authtxb.TxBuilder
txBldr = txBldr.WithMemo(fmt.Sprintf("%s@%s:26656", nodeID, ip))
}
}
return txBldr, msg, nil
}