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

feat(lightclient): add an event when canonical channel is set #1310

Merged
merged 1 commit into from
Oct 11, 2024
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
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
Loading