forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[x/slashing] Implement Protobuf Msg Services (cosmos#7557)
* Update x/slashing to use proto msg service * Fix proto-gen Co-authored-by: Aaron Craelius <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
503b518
commit c59a04d
Showing
6 changed files
with
889 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/slashing/types" | ||
) | ||
|
||
type msgServer struct { | ||
Keeper | ||
} | ||
|
||
// NewMsgServerImpl returns an implementation of the slashing MsgServer interface | ||
// for the provided Keeper. | ||
func NewMsgServerImpl(keeper Keeper) types.MsgServer { | ||
return &msgServer{Keeper: keeper} | ||
} | ||
|
||
var _ types.MsgServer = msgServer{} | ||
|
||
// Unjail implements MsgServer.Unjail method. | ||
// Validators must submit a transaction to unjail itself after | ||
// having been jailed (and thus unbonded) for downtime | ||
func (k msgServer) Unjail(goCtx context.Context, msg *types.MsgUnjail) (*types.MsgUnjailResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
valAddr, valErr := sdk.ValAddressFromBech32(msg.ValidatorAddr) | ||
if valErr != nil { | ||
return nil, valErr | ||
} | ||
err := k.Keeper.Unjail(ctx, valAddr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddr), | ||
), | ||
) | ||
|
||
return &types.MsgUnjailResponse{}, nil | ||
} |
Oops, something went wrong.