Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
5b0c08130c
commit
2f6573aef9
@@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
### API Breaking Changes
|
### API Breaking Changes
|
||||||
|
|
||||||
|
* (types) [#17358](https://github.com/cosmos/cosmos-sdk/pull/17358) Remove deprecated `sdk.Handler`, use `baseapp.MsgServiceHandler` instead.
|
||||||
* (client) [#17197](https://github.com/cosmos/cosmos-sdk/pull/17197) `keys.Commands` does not take a home directory anymore. It is inferred from the root command.
|
* (client) [#17197](https://github.com/cosmos/cosmos-sdk/pull/17197) `keys.Commands` does not take a home directory anymore. It is inferred from the root command.
|
||||||
* (x/staking) [#17098](https://github.com/cosmos/cosmos-sdk/pull/17098) `NewMsgCreateValidator`, `NewValidator`, `NewMsgCancelUnbondingDelegation`, `NewMsgUndelegate`, `NewMsgBeginRedelegate`, `NewMsgDelegate` and `NewMsgEditValidator` takes a string instead of `sdk.ValAddress` or `sdk.AccAddress`:
|
* (x/staking) [#17098](https://github.com/cosmos/cosmos-sdk/pull/17098) `NewMsgCreateValidator`, `NewValidator`, `NewMsgCancelUnbondingDelegation`, `NewMsgUndelegate`, `NewMsgBeginRedelegate`, `NewMsgDelegate` and `NewMsgEditValidator` takes a string instead of `sdk.ValAddress` or `sdk.AccAddress`:
|
||||||
* `NewMsgCreateValidator.Validate()` takes an address codec in order to decode the address.
|
* `NewMsgCreateValidator.Validate()` takes an address codec in order to decode the address.
|
||||||
|
|||||||
@@ -261,7 +261,6 @@ The module manager is used throughout the application whenever an action on a co
|
|||||||
* `SetOrderPrepareCheckStaters(moduleNames ...string)`: Sets the order in which the `PrepareCheckState()` function of each module will be called during commit of each block. This function is generally called from the application's main [constructor function](../basics/00-app-anatomy.md#constructor-function).
|
* `SetOrderPrepareCheckStaters(moduleNames ...string)`: Sets the order in which the `PrepareCheckState()` function of each module will be called during commit of each block. This function is generally called from the application's main [constructor function](../basics/00-app-anatomy.md#constructor-function).
|
||||||
* `SetOrderMigrations(moduleNames ...string)`: Sets the order of migrations to be run. If not set then migrations will be run with an order defined in `DefaultMigrationsOrder`.
|
* `SetOrderMigrations(moduleNames ...string)`: Sets the order of migrations to be run. If not set then migrations will be run with an order defined in `DefaultMigrationsOrder`.
|
||||||
* `RegisterInvariants(ir sdk.InvariantRegistry)`: Registers the [invariants](./07-invariants.md) of module implementing the `HasInvariants` interface.
|
* `RegisterInvariants(ir sdk.InvariantRegistry)`: Registers the [invariants](./07-invariants.md) of module implementing the `HasInvariants` interface.
|
||||||
* `RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter, legacyQuerierCdc *codec.LegacyAmino)`: Registers legacy [`Msg`](./02-messages-and-queries.md#messages) and [`querier`](./04-query-services.md#legacy-queriers) routes.
|
|
||||||
* `RegisterServices(cfg Configurator)`: Registers the services of modules implementing the `HasServices` interface.
|
* `RegisterServices(cfg Configurator)`: Registers the services of modules implementing the `HasServices` interface.
|
||||||
* `InitGenesis(ctx context.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage)`: Calls the [`InitGenesis`](./08-genesis.md#initgenesis) function of each module when the application is first started, in the order defined in `OrderInitGenesis`. Returns an `abci.ResponseInitChain` to the underlying consensus engine, which can contain validator updates.
|
* `InitGenesis(ctx context.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage)`: Calls the [`InitGenesis`](./08-genesis.md#initgenesis) function of each module when the application is first started, in the order defined in `OrderInitGenesis`. Returns an `abci.ResponseInitChain` to the underlying consensus engine, which can contain validator updates.
|
||||||
* `ExportGenesis(ctx context.Context, cdc codec.JSONCodec)`: Calls the [`ExportGenesis`](./08-genesis.md#exportgenesis) function of each module, in the order defined in `OrderExportGenesis`. The export constructs a genesis file from a previously existing state, and is mainly used when a hard-fork upgrade of the chain is required.
|
* `ExportGenesis(ctx context.Context, cdc codec.JSONCodec)`: Calls the [`ExportGenesis`](./08-genesis.md#exportgenesis) function of each module, in the order defined in `OrderExportGenesis`. The export constructs a genesis file from a previously existing state, and is mainly used when a hard-fork upgrade of the chain is required.
|
||||||
|
|||||||
@@ -96,14 +96,7 @@ ctx.EventManager().EmitEvent(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Module's `handler` function should also set a new `EventManager` to the `context` to isolate emitted Events per `message`:
|
Where the `EventManager` is accessed via the [`Context`](./02-context.md).
|
||||||
|
|
||||||
```go
|
|
||||||
func NewHandler(keeper Keeper) sdk.Handler {
|
|
||||||
return func(ctx context.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
||||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
||||||
switch msg := msg.(type) {
|
|
||||||
```
|
|
||||||
|
|
||||||
See the [`Msg` services](../building-modules/03-msg-services.md) concept doc for a more detailed
|
See the [`Msg` services](../building-modules/03-msg-services.md) concept doc for a more detailed
|
||||||
view on how to typically implement Events and use the `EventManager` in modules.
|
view on how to typically implement Events and use the `EventManager` in modules.
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ func NewApp(rootDir string, logger log.Logger) (servertypes.ABCI, error) {
|
|||||||
|
|
||||||
// KVStoreHandler is a simple handler that takes KVStoreTx and writes
|
// KVStoreHandler is a simple handler that takes KVStoreTx and writes
|
||||||
// them to the db.
|
// them to the db.
|
||||||
func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler {
|
func KVStoreHandler(storeKey storetypes.StoreKey) bam.MsgServiceHandler {
|
||||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||||
dTx, ok := msg.(*KVStoreTx)
|
dTx, ok := msg.(*KVStoreTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
// Handler defines the core of the state transition function of an application.
|
|
||||||
type Handler func(ctx Context, msg Msg) (*Result, error)
|
|
||||||
|
|
||||||
// AnteHandler authenticates transactions, before their internal messages are handled.
|
// AnteHandler authenticates transactions, before their internal messages are handled.
|
||||||
// If newCtx.IsZero(), ctx is used instead.
|
// If newCtx.IsZero(), ctx is used instead.
|
||||||
type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, err error)
|
type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, err error)
|
||||||
|
|||||||
Reference in New Issue
Block a user