Skip to content

Commit

Permalink
feat(lightclient): add an event when canonical channel is set (#1310)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Oct 11, 2024
1 parent 3f08435 commit 0cad2f1
Show file tree
Hide file tree
Showing 3 changed files with 394 additions and 1 deletion.
12 changes: 12 additions & 0 deletions proto/dymensionxyz/dymension/lightclient/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package dymensionxyz.dymension.lightclient;

import "gogoproto/gogo.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/lightclient/types";

// EventSetCanonicalChannel : when the canonical channel of the rollapp is set
message EventSetCanonicalChannel {
string rollapp_id = 1;
string channel_id = 2;
}
10 changes: 9 additions & 1 deletion x/lightclient/ante/ibc_msg_channel_open_ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/dymensionxyz/dymension/v3/x/lightclient/types"
"github.com/dymensionxyz/gerr-cosmos/gerrc"
"github.com/dymensionxyz/sdk-utils/utils/uevent"
)

func (i IBCMessagesDecorator) HandleMsgChannelOpenAck(ctx sdk.Context, msg *ibcchanneltypes.MsgChannelOpenAck) error {
Expand All @@ -31,9 +33,15 @@ func (i IBCMessagesDecorator) HandleMsgChannelOpenAck(ctx sdk.Context, msg *ibcc
return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "canonical channel already exists for the rollapp")
}
// Set this channel as the canonical channel for the rollapp
// TODO: emit event/log
rollapp.ChannelId = msg.ChannelId
i.rollappKeeper.SetRollapp(ctx, rollapp)

if err := uevent.EmitTypedEvent(ctx, &types.EventSetCanonicalChannel{
RollappId: rollappID,
ChannelId: rollapp.ChannelId,
}); err != nil {
return errorsmod.Wrap(err, "emit typed event")
}

return nil
}
Loading

0 comments on commit 0cad2f1

Please sign in to comment.