-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* WIP move emissions * refactor events emission * update typo and code clean up following review * Update modules/core/03-connection/keeper/events.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/core/03-connection/keeper/events.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * refactore based on code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> (cherry picked from commit 81b619d) Co-authored-by: nir1218 <nir1218@users.noreply.github.com>
- Loading branch information
1 parent
3262969
commit c53829f
Showing
8 changed files
with
315 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/v3/modules/core/02-client/types" | ||
"github.com/cosmos/ibc-go/v3/modules/core/exported" | ||
) | ||
|
||
// EmitCreateClientEvent emits a create client event | ||
func EmitCreateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeCreateClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientEvent emits an update client event | ||
func EmitUpdateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState, consensusHeight exported.Height, headerStr string) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeUpdateClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()), | ||
sdk.NewAttribute(types.AttributeKeyHeader, headerStr), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientEvent emits an upgrade client event | ||
func EmitUpgradeClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeUpgradeClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientProposalEvent emits an update client proposal event | ||
func EmitUpdateClientProposalEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeUpdateClientProposal, | ||
sdk.NewAttribute(types.AttributeKeySubjectClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
) | ||
} | ||
|
||
// EmitSubmitMisbehaviourEvent emits a client misbehaviour event | ||
func EmitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeSubmitMisbehaviour, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
), | ||
) | ||
} | ||
|
||
// EmitSubmitMisbehaviourEventOnUpdate emits a client misbehaviour event on a client update event | ||
func EmitSubmitMisbehaviourEventOnUpdate(ctx sdk.Context, clientID string, clientState exported.ClientState, consensusHeight exported.Height, headerStr string) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeSubmitMisbehaviour, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()), | ||
sdk.NewAttribute(types.AttributeKeyHeader, headerStr), | ||
), | ||
) | ||
} |
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,75 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" | ||
) | ||
|
||
// EmitConnectionOpenInitEvent emits a connection open init event | ||
func EmitConnectionOpenInitEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeConnectionOpenInit, | ||
sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, counterparty.ConnectionId), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitConnectionOpenTryEvent emits a connection open try event | ||
func EmitConnectionOpenTryEvent(ctx sdk.Context, connectionID string, clientID string, counterparty types.Counterparty) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeConnectionOpenTry, | ||
sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, counterparty.ConnectionId), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitConnectionOpenAckEvent emits a connection open acknowledge event | ||
func EmitConnectionOpenAckEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeConnectionOpenAck, | ||
sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), | ||
sdk.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitConnectionOpenConfirmEvent emits a connection open confirm event | ||
func EmitConnectionOpenConfirmEvent(ctx sdk.Context, connectionID string, connectionEnd types.ConnectionEnd) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeConnectionOpenConfirm, | ||
sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), | ||
sdk.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), | ||
sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} |
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
Oops, something went wrong.