Skip to content

Commit

Permalink
DELETE channel from v2
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Jan 16, 2025
1 parent b632f4c commit 0ba8de7
Show file tree
Hide file tree
Showing 34 changed files with 335 additions and 5,055 deletions.
2 changes: 1 addition & 1 deletion modules/apps/transfer/v2/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacketTransfer() {
func() {
packet.SourceClient = ibctesting.InvalidID
},
channeltypes.ErrInvalidChannelIdentifier,
clienttypes.ErrInvalidCounterparty,
},
{
"failure: receive is disabled",
Expand Down
8 changes: 2 additions & 6 deletions modules/core/04-channel/v2/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ func GetQueryCmd() *cobra.Command {
}

queryCmd.AddCommand(
getCmdQueryChannel(),
getCmdQueryChannelClientState(),
getCmdQueryNextSequenceSend(),
getCmdQueryPacketCommitment(),
getCmdQueryPacketCommitments(),
Expand All @@ -43,10 +41,8 @@ func NewTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

txCmd.AddCommand(
newCreateChannelTxCmd(),
newRegisterCounterpartyTxCmd(),
)
// TODO: Add v2 packet commands
txCmd.AddCommand()

return txCmd
}
62 changes: 0 additions & 62 deletions modules/core/04-channel/v2/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,6 @@ const (
flagSequences = "sequences"
)

// getCmdQueryChannel defines the command to query the channel information (creator and channel) for the given channel ID.
func getCmdQueryChannel() *cobra.Command {
cmd := &cobra.Command{
Use: "channel [channel-id]",
Short: "Query the information of a channel.",
Long: "Query the channel information for the provided channel ID.",
Example: fmt.Sprintf("%s query %s %s channel [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

channelID := args[0]

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Channel(cmd.Context(), types.NewQueryChannelRequest(channelID))
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// getCmdQueryChannelClientState defines the command to query the channel client state for the given channel ID.
func getCmdQueryChannelClientState() *cobra.Command {
cmd := &cobra.Command{
Use: "client-state [channel-id]",
Short: "Query the client state associated with a channel.",
Long: "Query the client state associated with a channel for the provided channel ID.",
Example: fmt.Sprintf("%s query %s %s client-state [channel-id]", version.AppName, exported.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

channelID := args[0]
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.ChannelClientState(cmd.Context(), types.NewQueryChannelClientStateRequest(channelID))
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// getCmdQueryNextSequenceSend defines the command to query a next send sequence for a given client
func getCmdQueryNextSequenceSend() *cobra.Command {
cmd := &cobra.Command{
Expand Down
93 changes: 0 additions & 93 deletions modules/core/04-channel/v2/client/cli/tx.go

This file was deleted.

35 changes: 0 additions & 35 deletions modules/core/04-channel/v2/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,38 +142,3 @@ func emitTimeoutPacketEvents(ctx context.Context, packet types.Packet) {
),
})
}

// emitCreateChannelEvent emits a channel create event.
func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCreateChannel,
sdk.NewAttribute(types.AttributeKeyChannelID, channelID),
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
}

// emitRegisterCounterpartyEvent emits a register counterparty event.
func (*Keeper) emitRegisterCounterpartyEvent(ctx context.Context, channelID string, channel types.Channel) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRegisterCounterparty,
sdk.NewAttribute(types.AttributeKeyChannelID, channelID),
sdk.NewAttribute(types.AttributeKeyClientID, channel.ClientId),
sdk.NewAttribute(types.AttributeKeyCounterpartyChannelID, channel.CounterpartyChannelId),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
}
12 changes: 0 additions & 12 deletions modules/core/04-channel/v2/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ package keeper
import (
"context"

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

// ChannelStore is a wrapper around channelStore to allow its usage during testing.
func (k Keeper) ChannelStore(ctx context.Context) storetypes.KVStore {
return k.channelStore(ctx)
}

func (k *Keeper) SendPacketTest(
ctx context.Context,
sourceChannel string,
Expand Down Expand Up @@ -75,8 +68,3 @@ func (k *Keeper) TimeoutPacketTest(
proofHeight,
)
}

// AliasV1Channel is a wrapper around aliasV1Channel to allow its usage in tests.
func (k *Keeper) AliasV1Channel(ctx context.Context, portID, channelID string) (types.Channel, bool) {
return k.aliasV1Channel(ctx, portID, channelID)
}
76 changes: 0 additions & 76 deletions modules/core/04-channel/v2/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,82 +34,6 @@ func NewQueryServer(k *Keeper) types.QueryServer {
}
}

// Channel implements the Query/Channel gRPC method
func (q *queryServer) Channel(ctx context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

channel, found := q.GetChannel(ctx, req.ChannelId)
if !found {
return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error())
}

return types.NewQueryChannelResponse(channel), nil
}

// ChannelClientState implements the Query/ChannelClientState gRPC method
func (q *queryServer) ChannelClientState(ctx context.Context, req *types.QueryChannelClientStateRequest) (*types.QueryChannelClientStateResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

channel, found := q.GetChannel(ctx, req.ChannelId)
if !found {
return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error())
}

clientState, found := q.ClientKeeper.GetClientState(ctx, channel.ClientId)
if !found {
return nil, status.Error(codes.NotFound, errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client-id: %s", channel.ClientId).Error())
}

identifiedClientState := clienttypes.NewIdentifiedClientState(channel.ClientId, clientState)
res := types.NewQueryChannelClientStateResponse(identifiedClientState, nil, clienttypes.GetSelfHeight(ctx))

return res, nil
}

// ChannelConsensusState implements the Query/ChannelConsensusState gRPC method
func (q *queryServer) ChannelConsensusState(ctx context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

channel, found := q.GetChannel(ctx, req.ChannelId)
if !found {
return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error())
}

consHeight := clienttypes.NewHeight(req.RevisionNumber, req.RevisionHeight)
consensusState, found := q.ClientKeeper.GetClientConsensusState(ctx, channel.ClientId, consHeight)
if !found {
return nil, status.Error(
codes.NotFound,
errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "client-id: %s", channel.ClientId).Error(),
)
}

anyConsensusState, err := clienttypes.PackConsensusState(consensusState)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return types.NewQueryChannelConsensusStateResponse(channel.ClientId, anyConsensusState, nil, clienttypes.GetSelfHeight(ctx)), nil
}

// NextSequenceSend implements the Query/NextSequenceSend gRPC method
func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) {
if req == nil {
Expand Down
Loading

0 comments on commit 0ba8de7

Please sign in to comment.