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

refactor(context): Pass EventManager to the context as an interface. #14384

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Context struct {
recheckTx bool // if recheckTx == true, then checkTx must also be true
minGasPrice DecCoins
consParams *tmproto.ConsensusParams
eventManager *EventManager
eventManager EventManagerI
priority int64 // The tx priority, only relevant in CheckTx
kvGasConfig storetypes.GasConfig
transientKVGasConfig storetypes.GasConfig
Expand All @@ -60,7 +60,7 @@ func (c Context) BlockGasMeter() GasMeter { return c.blockGas
func (c Context) IsCheckTx() bool { return c.checkTx }
func (c Context) IsReCheckTx() bool { return c.recheckTx }
func (c Context) MinGasPrices() DecCoins { return c.minGasPrice }
func (c Context) EventManager() *EventManager { return c.eventManager }
func (c Context) EventManager() EventManagerI { return c.eventManager }
func (c Context) Priority() int64 { return c.priority }
func (c Context) KVGasConfig() storetypes.GasConfig { return c.kvGasConfig }
func (c Context) TransientKVGasConfig() storetypes.GasConfig { return c.transientKVGasConfig }
Expand Down
14 changes: 14 additions & 0 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,24 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
)

type EventManagerI interface {
Events() Events
ABCIEvents() []abci.Event
EmitTypedEvent(tev proto.Message) error
EmitTypedEvents(tevs ...proto.Message) error

// Deprecated: Use EmitTypedEvent
EmitEvent(event Event)
// Deprecated: Use EmitTypedEvents
EmitEvents(events Events)
}

// ----------------------------------------------------------------------------
// Event Manager
// ----------------------------------------------------------------------------

var _ EventManagerI = (*EventManager)(nil)

// EventManager implements a simple wrapper around a slice of Event objects that
// can be emitted from.
type EventManager struct {
Expand Down