Skip to content

Commit

Permalink
Merge simulation/invariant, keep handler/keeper separate to avoid cir…
Browse files Browse the repository at this point in the history
…cular deps
  • Loading branch information
alessio committed Jun 9, 2019
1 parent 6c44e56 commit 75ab6ec
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions x/bank/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package bank
import (
"github.com/cosmos/cosmos-sdk/x/bank/internal/handler"
"github.com/cosmos/cosmos-sdk/x/bank/internal/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/internal/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/internal/invariants"
"github.com/cosmos/cosmos-sdk/x/bank/internal/types"
)

Expand Down Expand Up @@ -38,8 +38,8 @@ var (
ValidateInputsOutputs = types.ValidateInputsOutputs
ParamKeyTable = types.ParamKeyTable
NewHandler = handler.NewHandler
SimulateMsgSend = simulation.SimulateMsgSend
SimulateSingleInputMsgMultiSend = simulation.SimulateSingleInputMsgMultiSend
SimulateMsgSend = invariants.SimulateMsgSend
SimulateSingleInputMsgMultiSend = invariants.SimulateSingleInputMsgMultiSend

// variable aliases
ModuleCdc = types.ModuleCdc
Expand Down
9 changes: 4 additions & 5 deletions x/bank/internal/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/internal/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/internal/tags"
"github.com/cosmos/cosmos-sdk/x/bank/internal/types"
)

Expand Down Expand Up @@ -37,9 +36,9 @@ func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg types.MsgSend) sdk.Resu
}

resTags := sdk.NewTags(
tags.Category, tags.TxCategory,
tags.Sender, msg.FromAddress.String(),
tags.Recipient, msg.ToAddress.String(),
types.Category, types.TxCategory,
types.Sender, msg.FromAddress.String(),
types.Recipient, msg.ToAddress.String(),
)

return sdk.Result{
Expand All @@ -58,7 +57,7 @@ func handleMsgMultiSend(ctx sdk.Context, k keeper.Keeper, msg types.MsgMultiSend
return err.Result()
}

resTags = resTags.AppendTag(tags.Category, tags.TxCategory)
resTags = resTags.AppendTag(types.Category, types.TxCategory)
return sdk.Result{
Tags: resTags,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package simulation
package invariants

import (
"fmt"
Expand Down
9 changes: 4 additions & 5 deletions x/bank/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank/internal/tags"
"github.com/cosmos/cosmos-sdk/x/bank/internal/types"
"github.com/cosmos/cosmos-sdk/x/params"
)
Expand Down Expand Up @@ -340,7 +339,7 @@ func inputOutputCoins(ctx sdk.Context, am auth.AccountKeeper, inputs []types.Inp
}

allTags = allTags.AppendTag(
tags.Sender, in.Address.String(),
types.Sender, in.Address.String(),
)
}

Expand All @@ -350,7 +349,7 @@ func inputOutputCoins(ctx sdk.Context, am auth.AccountKeeper, inputs []types.Inp
return nil, err
}
allTags = allTags.AppendTag(
tags.Recipient, out.Address.String(),
types.Recipient, out.Address.String(),
)
}

Expand Down Expand Up @@ -386,7 +385,7 @@ func delegateCoins(
setAccount(ctx, ak, acc)

return sdk.NewTags(
sdk.TagAction, tags.ActionDelegateCoins,
sdk.TagAction, types.ActionDelegateCoins,
sdk.TagDelegator, addr.String(),
), nil
}
Expand All @@ -411,7 +410,7 @@ func undelegateCoins(
setAccount(ctx, ak, acc)

return sdk.NewTags(
sdk.TagAction, tags.ActionUndelegateCoins,
sdk.TagAction, types.ActionUndelegateCoins,
sdk.TagDelegator, addr.String(),
), nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tags
package types

import (
"github.com/cosmos/cosmos-sdk/types"
Expand Down

0 comments on commit 75ab6ec

Please sign in to comment.