-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add MsgEmpty to auth module (#176)
* feat: add MsgEmpty to auth module * build: tidy go.mod * ci: ignore pb.go files when running codecov * ci: ignore pb.gw.go files when running codecov * test: add more tests * fix: fix lint errors * ci: fix codecov configs * build: update go.mod
- Loading branch information
Showing
15 changed files
with
923 additions
and
8 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
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
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,24 @@ | ||
syntax = "proto3"; | ||
package lbm.auth.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "lbm/auth/v1beta1/auth.proto"; | ||
|
||
option go_package = "github.com/line/lbm-sdk/v2/x/auth/types"; | ||
|
||
// Msg defines the auth Msg service. | ||
service Msg { | ||
// Empty defines a method that doesn't do anything. Used to measure performance. | ||
rpc Empty(MsgEmpty) returns (MsgEmptyResponse); | ||
} | ||
|
||
// MsgEmpty represents a message that doesn't do anything. Used to measure performance. | ||
message MsgEmpty { | ||
option (gogoproto.equal) = false; | ||
option (gogoproto.goproto_getters) = false; | ||
|
||
string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; | ||
} | ||
|
||
// MsgEmptyResponse defines the Msg/Empty response type. | ||
message MsgEmptyResponse {} |
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,53 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/line/lbm-sdk/v2/client" | ||
"github.com/line/lbm-sdk/v2/client/flags" | ||
"github.com/line/lbm-sdk/v2/client/tx" | ||
"github.com/line/lbm-sdk/v2/x/auth/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewTxCmd returns a root CLI command handler for all x/auth transaction commands. | ||
func NewTxCmd() *cobra.Command { | ||
txCmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: "Auth transaction subcommands", | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
txCmd.AddCommand(NewEmptyTxCmd()) | ||
|
||
return txCmd | ||
} | ||
|
||
// NewEmptyTxCmd returns a CLI command handler for creating a MsgEmpty transaction. | ||
func NewEmptyTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "empty [from_key_or_address]", | ||
Short: `Empty doesn't do anything. Used to measure performance.`, | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
err := cmd.Flags().Set(flags.FlagFrom, args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := types.NewServiceMsgEmpty(clientCtx.GetFromAddress()) | ||
if err := msg.ValidateBasic(); err != nil { | ||
return err | ||
} | ||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
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,31 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/line/lbm-sdk/v2/types" | ||
"github.com/line/lbm-sdk/v2/x/auth/types" | ||
) | ||
|
||
type msgServer struct { | ||
AccountKeeper | ||
} | ||
|
||
// NewMsgServerImpl returns an implementation of the auth MsgServer interface for the provided Keeper. | ||
func NewMsgServerImpl(keeper AccountKeeper) types.MsgServer { | ||
return &msgServer{AccountKeeper: keeper} | ||
} | ||
|
||
var _ types.MsgServer = msgServer{} | ||
|
||
func (k msgServer) Empty(goCtx context.Context, msg *types.MsgEmpty) (*types.MsgEmptyResponse, error) { | ||
sdk.UnwrapSDKContext(goCtx).EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeySender, msg.FromAddress), | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventEmpty), | ||
), | ||
) | ||
return &types.MsgEmptyResponse{}, nil | ||
} |
Oops, something went wrong.