Skip to content

Commit

Permalink
refactor(context): Pass EventManager to the context as an interface. (
Browse files Browse the repository at this point in the history
#14384)

(cherry picked from commit ebf1e86)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
itsdevbear authored and mergify[bot] committed Dec 22, 2022
1 parent 7d28bb1 commit b29a74d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,18 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

<<<<<<< HEAD
* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration.
=======
* (context)[#14384](https://github.com/cosmos/cosmos-sdk/pull/14384) refactor(context): Pass EventManager to the context as an interface.
* (types) [#14354](https://github.com/cosmos/cosmos-sdk/pull/14354) - improve performance on Context.KVStore and Context.TransientStore by 40%
* (crypto/keyring) [#14151](https://github.com/cosmos/cosmos-sdk/pull/14151) Move keys presentation from `crypto/keyring` to `client/keys`
* (types) [#14163](https://github.com/cosmos/cosmos-sdk/pull/14163) Refactor `(coins Coins) Validate()` to avoid unnecessary map.
* (signing) [#14087](https://github.com/cosmos/cosmos-sdk/pull/14087) Add SignModeHandlerWithContext interface with a new `GetSignBytesWithContext` to get the sign bytes using `context.Context` as an argument to access state.
* (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start.
* [13882] (https://github.com/cosmos/cosmos-sdk/pull/13882) Add tx `encode` and `decode` endpoints to amino tx service.
> Note: These endpoints encodes and decodes only amino txs.
>>>>>>> ebf1e86bd (refactor(context): Pass `EventManager` to the context as an interface. (#14384))
* (x/nft) [#13836](https://github.com/cosmos/cosmos-sdk/pull/13836) Remove the validation for `classID` and `nftID` from the NFT module.
* [#13789](https://github.com/cosmos/cosmos-sdk/pull/13789) Add tx `encode` and `decode` endpoints to tx service.
> Note: These endpoints will only encode and decode proto messages, Amino encoding and decoding is not supported.
Expand Down
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
11 changes: 11 additions & 0 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ 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
EmitEvent(event Event)
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

0 comments on commit b29a74d

Please sign in to comment.