Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor x/staking according to ADR 031 #7556

Merged
merged 8 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions proto/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@ package cosmos.staking.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/staking/v1beta1/staking.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types";

// MsgCreateValidator defines an SDK message for creating a new validator.
// Msg defines the staking Msg service.
service Msg {
// CreateValidator defines a method for creating a new validator.
rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse);

// EditValidator defines a method for editing an existing validator.
rpc EditValidator(MsgEditValidator) returns (MsgEditValidatorResponse);

// Delegate defines a method for performing a delegation of coins
// from a delegator to a validator.
rpc Delegate(MsgDelegate) returns (MsgDelegateResponse);

// BeginRedelegate defines a method for performing a redelegation
// of coins from a delegator and source validator to a destination validator.
rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse);

// Undelegate defines a method for performing an undelegation from a
// delegate and a validator.
rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse);
}

// MsgCreateValidator defines a SDK message for creating a new validator.
message MsgCreateValidator {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Expand All @@ -25,7 +47,10 @@ message MsgCreateValidator {
cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false];
}

// MsgEditValidator defines an SDK message for editing an existing validator.
// MsgCreateValidatorResponse defines the Msg/CreateValidator response type.
message MsgCreateValidatorResponse { }

// MsgEditValidator defines a SDK message for editing an existing validator.
message MsgEditValidator {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
Expand All @@ -48,7 +73,10 @@ message MsgEditValidator {
];
}

// MsgDelegate defines an SDK message for performing a delegation of coins
// MsgEditValidatorResponse defines the Msg/EditValidator response type.
message MsgEditValidatorResponse { }

// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message MsgDelegate {
option (gogoproto.equal) = false;
Expand All @@ -59,7 +87,10 @@ message MsgDelegate {
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}

// MsgBeginRedelegate defines an SDK message for performing a redelegation
// MsgDelegateResponse defines the Msg/Delegate response type.
message MsgDelegateResponse { }

// MsgBeginRedelegate defines a SDK message for performing a redelegation
// of coins from a delegator and source validator to a destination validator.
message MsgBeginRedelegate {
option (gogoproto.equal) = false;
Expand All @@ -71,7 +102,12 @@ message MsgBeginRedelegate {
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
}

// MsgUndelegate defines an SDK message for performing an undelegation from a
// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type.
message MsgBeginRedelegateResponse {
google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}

// MsgUndelegate defines a SDK message for performing an undelegation from a
// delegate and a validator.
message MsgUndelegate {
option (gogoproto.equal) = false;
Expand All @@ -80,4 +116,9 @@ message MsgUndelegate {
string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""];
string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
}
}

// MsgUndelegateResponse defines the Msg/Undelegate response type.
message MsgUndelegateResponse {
google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
4 changes: 2 additions & 2 deletions x/distribution/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
)

func NewHandler(k keeper.Keeper) sdk.Handler {
msgServer := keeper.NewMsgServerImpl(k)

return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())

msgServer := keeper.NewMsgServerImpl(k)

switch msg := msg.(type) {
case *types.MsgSetWithdrawAddress:
res, err := msgServer.SetWithdrawAddress(sdk.WrapSDKContext(ctx), msg)
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type msgServer struct {
Keeper
}

// NewMsgServerImpl returns an implementation of the bank MsgServer interface
// NewMsgServerImpl returns an implementation of the distribution MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{Keeper: keeper}
Expand Down
Loading