Skip to content

Commit

Permalink
Merge pull request cosmos#17 from crodriguezvega/carlos/sdk-module-fo…
Browse files Browse the repository at this point in the history
…lder-structure

chore: relocating files to follow sdk module folder structure
  • Loading branch information
misko9 authored Mar 4, 2023
2 parents 29140fb + 0f5896c commit e88662c
Show file tree
Hide file tree
Showing 41 changed files with 290 additions and 272 deletions.
3 changes: 0 additions & 3 deletions modules/core/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
connection "github.com/cosmos/ibc-go/v7/modules/core/03-connection"
channel "github.com/cosmos/ibc-go/v7/modules/core/04-channel"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
wasmcli "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/cli"
)

// GetTxCmd returns the transaction commands for this module
Expand All @@ -24,7 +23,6 @@ func GetTxCmd() *cobra.Command {
ibcTxCmd.AddCommand(
ibcclient.GetTxCmd(),
channel.GetTxCmd(),
wasmcli.NewTxCmd(),
)

return ibcTxCmd
Expand All @@ -45,7 +43,6 @@ func GetQueryCmd() *cobra.Command {
ibcclient.GetQueryCmd(),
connection.GetQueryCmd(),
channel.GetQueryCmd(),
wasmcli.GetQueryCmd(),
)

return ibcQueryCmd
Expand Down
6 changes: 0 additions & 6 deletions modules/core/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ import (
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
)

// WasmCode implements the IBC QueryServer interface
func (q Keeper) WasmCode(c context.Context, req *wasm.WasmCodeQuery) (*wasm.WasmCodeResponse, error) {
return q.WasmClientKeeper.WasmCode(c, req)
}

// ClientState implements the IBC QueryServer interface
func (q Keeper) ClientState(c context.Context, req *clienttypes.QueryClientStateRequest) (*clienttypes.QueryClientStateResponse, error) {
return q.ClientKeeper.ClientState(c, req)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
portkeeper "github.com/cosmos/ibc-go/v7/modules/core/05-port/keeper"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/types"
wasmkeeper "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
wasmkeeper "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/keeper"
)

var _ types.QueryServer = (*Keeper)(nil)
Expand Down
26 changes: 0 additions & 26 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"encoding/hex"

metrics "github.com/armon/go-metrics"
"github.com/cosmos/cosmos-sdk/telemetry"
Expand All @@ -14,39 +13,14 @@ import (
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
coretypes "github.com/cosmos/ibc-go/v7/modules/core/types"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
)

var (
_ clienttypes.MsgServer = Keeper{}
_ connectiontypes.MsgServer = Keeper{}
_ channeltypes.MsgServer = Keeper{}
_ wasm.MsgServer = Keeper{}
)

// PushNewWasmCode defines a rpc handler method for MsgPushNewWasmCode
func (k Keeper) PushNewWasmCode(goCtx context.Context, msg *wasm.MsgPushNewWasmCode) (*wasm.MsgPushNewWasmCodeResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

response, err := wasm.HandleMsgPushNewWasmCode(ctx, k.WasmClientKeeper, msg)
if err != nil {
return nil, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
clienttypes.EventTypePushWasmCode,
sdk.NewAttribute(clienttypes.AttributeKeyWasmCodeID, hex.EncodeToString(response.CodeId)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, clienttypes.AttributeValueCategory),
),
})

return response, nil
}

// CreateClient defines a rpc handler method for MsgCreateClient.
func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down
6 changes: 0 additions & 6 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/cosmos/ibc-go/v7/modules/core/simulation"
"github.com/cosmos/ibc-go/v7/modules/core/types"
wasmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
)

var (
Expand Down Expand Up @@ -78,10 +77,6 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
if err != nil {
panic(err)
}
err = wasmclient.RegisterQueryHandlerClient(context.Background(), mux, wasmclient.NewQueryClient(clientCtx))
if err != nil {
panic(err)
}
}

// GetTxCmd returns the root tx command for the ibc module.
Expand Down Expand Up @@ -127,7 +122,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
wasmclient.RegisterMsgServer(cfg.MsgServer(), am.keeper)
types.RegisterQueryService(cfg.QueryServer(), am.keeper)

m := clientkeeper.NewMigrator(am.keeper.ClientKeeper)
Expand Down
3 changes: 0 additions & 3 deletions modules/core/types/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ import (
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channel "github.com/cosmos/ibc-go/v7/modules/core/04-channel"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
)

// QueryServer defines the IBC interfaces that the gRPC query server must implement
type QueryServer interface {
clienttypes.QueryServer
connectiontypes.QueryServer
channeltypes.QueryServer
wasm.QueryServer
}

// RegisterQueryService registers each individual IBC submodule query service
func RegisterQueryService(server grpc.Server, queryService QueryServer) {
client.RegisterQueryService(server, queryService)
connection.RegisterQueryService(server, queryService)
channel.RegisterQueryService(server, queryService)
wasm.RegisterQueryService(server, queryService)
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"

types "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
)

// GetQueryCmd returns the query commands for IBC channels
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: wasm.SubModuleName,
Use: types.SubModuleName,
Short: "IBC wasm manager module query subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

queryCmd.AddCommand(
GetCmdCode(),
getCmdCode(),
)

return queryCmd
Expand All @@ -26,15 +28,15 @@ func GetQueryCmd() *cobra.Command {
// NewTxCmd returns a CLI command handler for all x/ibc channel transaction commands.
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: wasm.SubModuleName,
Use: types.SubModuleName,
Short: "IBC wasm manager module transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

txCmd.AddCommand(
NewPushNewWasmCodeCmd(),
newPushNewWasmCodeCmd(),
)

return txCmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
"github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
"github.com/spf13/cobra"
)

// GetCmdCode defines the command to query wasm code for given code id
func GetCmdCode() *cobra.Command {
// getCmdCode defines the command to query wasm code for given code id
func getCmdCode() *cobra.Command {
cmd := &cobra.Command{
Use: "code [code-id]",
Short: "Query wasm code",
Long: "Query wasm code",
Example: fmt.Sprintf(
"%s query %s %s code [code-id]", version.AppName, host.SubModuleName, wasm.SubModuleName,
"%s query %s %s code [code-id]", version.AppName, host.SubModuleName, types.SubModuleName,
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := wasm.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx)

codeID := args[0]
req := wasm.WasmCodeQuery{
req := types.WasmCodeQuery{
CodeId: codeID,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm"
"github.com/spf13/cobra"

types "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
)

// NewPushNewWasmCodeCmd returns the command to create a PushNewWasmCode transaction
func NewPushNewWasmCodeCmd() *cobra.Command {
// newPushNewWasmCodeCmd returns the command to create a PushNewWasmCode transaction
func newPushNewWasmCodeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "push-wasm [wasm-file]",
Short: "Reads wasm code from the file and creates push transaction",
Expand All @@ -29,7 +30,7 @@ func NewPushNewWasmCodeCmd() *cobra.Command {
return err
}

msg := &wasm.MsgPushNewWasmCode{
msg := &types.MsgPushNewWasmCode{
Code: code,
Signer: clientCtx.GetFromAddress().String(),
}
Expand Down
22 changes: 0 additions & 22 deletions modules/light-clients/08-wasm/handler.go

This file was deleted.

14 changes: 14 additions & 0 deletions modules/light-clients/08-wasm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package keeper

import (
"context"

"github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
)

var _ types.QueryServer = Keeper{}

// WasmCode implements the IBC QueryServer interface
func (q Keeper) WasmCode(c context.Context, req *types.WasmCodeQuery) (*types.WasmCodeResponse, error) {
return q.getWasmCode(c, req)
}
Loading

0 comments on commit e88662c

Please sign in to comment.