fix and cleanup action tags (#4045)

Closes: #3966 #3793
This commit is contained in:
Federico Kunze 2019-04-09 00:51:02 +02:00 committed by Alessio Treglia
parent fbc6bdae18
commit c0a607ce74
7 changed files with 11 additions and 40 deletions

View File

@ -0,0 +1,2 @@
#3966 fixed multiple assigns to action tags
#3793 add delegator tag for MsgCreateValidator and deleted unused moniker and identity tags

View File

@ -61,7 +61,6 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) sdk.Result {
k.validatorSet.Unjail(ctx, consAddr)
tags := sdk.NewTags(
tags.Action, tags.ActionValidatorUnjailed,
tags.Validator, msg.ValidatorAddr.String(),
)

View File

@ -1,13 +1,6 @@
package tags
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Slashing tags
var (
ActionValidatorUnjailed = "validator-unjailed"
Action = sdk.TagAction
Validator = "validator"
)

View File

@ -4,7 +4,6 @@ package staking
import (
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/querier"
"github.com/cosmos/cosmos-sdk/x/staking/tags"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
@ -172,15 +171,3 @@ var (
ErrMinSelfDelegationDecreased = types.ErrMinSelfDelegationDecreased
ErrSelfDelegationBelowMinimum = types.ErrSelfDelegationBelowMinimum
)
var (
ActionCompleteUnbonding = tags.ActionCompleteUnbonding
ActionCompleteRedelegation = tags.ActionCompleteRedelegation
TagAction = tags.Action
TagSrcValidator = tags.SrcValidator
TagDstValidator = tags.DstValidator
TagDelegator = tags.Delegator
TagMoniker = tags.Moniker
TagIdentity = tags.Identity
)

View File

@ -9,7 +9,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/tags"
"github.com/gorilla/mux"
)
@ -143,16 +142,12 @@ func delegatorTxsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Han
actions = append(actions, staking.MsgDelegate{}.Type())
case isUnbondTx:
actions = append(actions, staking.MsgUndelegate{}.Type())
actions = append(actions, tags.ActionCompleteUnbonding)
case isRedTx:
actions = append(actions, staking.MsgBeginRedelegate{}.Type())
actions = append(actions, tags.ActionCompleteRedelegation)
case noQuery:
actions = append(actions, staking.MsgDelegate{}.Type())
actions = append(actions, staking.MsgUndelegate{}.Type())
actions = append(actions, tags.ActionCompleteUnbonding)
actions = append(actions, staking.MsgBeginRedelegate{}.Type())
actions = append(actions, tags.ActionCompleteRedelegation)
default:
w.WriteHeader(http.StatusNoContent)
return

View File

@ -60,7 +60,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, sdk.T
}
resTags.AppendTags(sdk.NewTags(
tags.Action, ActionCompleteUnbonding,
tags.Action, tags.ActionCompleteUnbonding,
tags.Delegator, dvPair.DelegatorAddress.String(),
tags.SrcValidator, dvPair.ValidatorAddress.String(),
))
@ -144,8 +144,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
tags := sdk.NewTags(
tags.DstValidator, msg.ValidatorAddress.String(),
tags.Moniker, msg.Description.Moniker,
tags.Identity, msg.Description.Identity,
tags.Delegator, msg.DelegatorAddress.String(),
)
return sdk.Result{
@ -192,14 +191,12 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
k.SetValidator(ctx, validator)
tags := sdk.NewTags(
resTags := sdk.NewTags(
tags.DstValidator, msg.ValidatorAddress.String(),
tags.Moniker, description.Moniker,
tags.Identity, description.Identity,
)
return sdk.Result{
Tags: tags,
Tags: resTags,
}
}
@ -218,13 +215,13 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
return err.Result()
}
tags := sdk.NewTags(
resTags := sdk.NewTags(
tags.Delegator, msg.DelegatorAddress.String(),
tags.DstValidator, msg.ValidatorAddress.String(),
)
return sdk.Result{
Tags: tags,
Tags: resTags,
}
}
@ -242,13 +239,13 @@ func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keep
}
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(completionTime)
tags := sdk.NewTags(
resTags := sdk.NewTags(
tags.Delegator, msg.DelegatorAddress.String(),
tags.SrcValidator, msg.ValidatorAddress.String(),
tags.EndTime, completionTime.Format(time.RFC3339),
)
return sdk.Result{Data: finishTime, Tags: tags}
return sdk.Result{Data: finishTime, Tags: resTags}
}
func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k keeper.Keeper) sdk.Result {

View File

@ -1,10 +1,10 @@
// nolint
package tags
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// staking tags
var (
ActionCompleteUnbonding = "complete-unbonding"
ActionCompleteRedelegation = "complete-redelegation"
@ -13,7 +13,5 @@ var (
SrcValidator = sdk.TagSrcValidator
DstValidator = sdk.TagDstValidator
Delegator = sdk.TagDelegator
Moniker = "moniker"
Identity = "identity"
EndTime = "end-time"
)