Skip to content

Commit

Permalink
fix and cleanup action tags (#4045)
Browse files Browse the repository at this point in the history
Closes: #3966 #3793
  • Loading branch information
fedekunze authored and alessio committed Apr 8, 2019
1 parent fbc6bda commit c0a607c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .pending/bugfixes/sdk/3966-fixed-multiple-
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#3966 fixed multiple assigns to action tags
#3793 add delegator tag for MsgCreateValidator and deleted unused moniker and identity tags
1 change: 0 additions & 1 deletion x/slashing/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)

Expand Down
7 changes: 0 additions & 7 deletions x/slashing/tags/tags.go
Original file line number Diff line number Diff line change
@@ -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"
)
13 changes: 0 additions & 13 deletions x/staking/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
)
5 changes: 0 additions & 5 deletions x/staking/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
19 changes: 8 additions & 11 deletions x/staking/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
}
}

Expand All @@ -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,
}
}

Expand All @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions x/staking/tags/tags.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// nolint
package tags

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// staking tags
var (
ActionCompleteUnbonding = "complete-unbonding"
ActionCompleteRedelegation = "complete-redelegation"
Expand All @@ -13,7 +13,5 @@ var (
SrcValidator = sdk.TagSrcValidator
DstValidator = sdk.TagDstValidator
Delegator = sdk.TagDelegator
Moniker = "moniker"
Identity = "identity"
EndTime = "end-time"
)

0 comments on commit c0a607c

Please sign in to comment.