chore: add message router interface (#15035)
This commit is contained in:
parent
b3f95061fa
commit
1dad6891e2
@ -146,6 +146,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/staking) [#14590](https://github.com/cosmos/cosmos-sdk/pull/14590) Return undelegate amount in MsgUndelegateResponse
|
||||
* (tools) [#14793](https://github.com/cosmos/cosmos-sdk/pull/14793) Dockerfile optimization.
|
||||
* (cli) [#14953](https://github.com/cosmos/cosmos-sdk/pull/14953) Enable profiling block replay during abci handshake with `--cpu-profile`.
|
||||
* (baseapp) [#15023](https://github.com/cosmos/cosmos-sdk/pull/15023) Add `MessageRouter` interface to baseapp and pass it to authz instead of concrete type.
|
||||
|
||||
### State Machine Breaking
|
||||
|
||||
|
||||
@ -13,6 +13,13 @@ import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// MessageRouter ADR 031 request type routing
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-031-msg-service.md
|
||||
type MessageRouter interface {
|
||||
Handler(msg sdk.Msg) MsgServiceHandler
|
||||
HandlerByTypeURL(typeURL string) MsgServiceHandler
|
||||
}
|
||||
|
||||
// MsgServiceRouter routes fully-qualified Msg service methods to their handler.
|
||||
type MsgServiceRouter struct {
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
|
||||
@ -27,12 +27,12 @@ const gasCostPerIteration = uint64(20)
|
||||
type Keeper struct {
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
router *baseapp.MsgServiceRouter
|
||||
router baseapp.MessageRouter
|
||||
authKeeper authz.AccountKeeper
|
||||
}
|
||||
|
||||
// NewKeeper constructs a message authorization Keeper
|
||||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router *baseapp.MsgServiceRouter, ak authz.AccountKeeper) Keeper {
|
||||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router baseapp.MessageRouter, ak authz.AccountKeeper) Keeper {
|
||||
return Keeper{
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
|
||||
@ -181,7 +181,7 @@ type AuthzInputs struct {
|
||||
AccountKeeper authz.AccountKeeper
|
||||
BankKeeper authz.BankKeeper
|
||||
Registry cdctypes.InterfaceRegistry
|
||||
MsgServiceRouter *baseapp.MsgServiceRouter
|
||||
MsgServiceRouter baseapp.MessageRouter
|
||||
}
|
||||
|
||||
//nolint:revive
|
||||
|
||||
@ -37,7 +37,7 @@ type Keeper struct {
|
||||
legacyRouter v1beta1.Router
|
||||
|
||||
// Msg server router
|
||||
router *baseapp.MsgServiceRouter
|
||||
router baseapp.MessageRouter
|
||||
|
||||
config types.Config
|
||||
|
||||
@ -126,7 +126,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
}
|
||||
|
||||
// Router returns the gov keeper's router
|
||||
func (k Keeper) Router() *baseapp.MsgServiceRouter {
|
||||
func (k Keeper) Router() baseapp.MessageRouter {
|
||||
return k.router
|
||||
}
|
||||
|
||||
|
||||
@ -76,13 +76,13 @@ type Keeper struct {
|
||||
voteByProposalIndex orm.Index
|
||||
voteByVoterIndex orm.Index
|
||||
|
||||
router *baseapp.MsgServiceRouter
|
||||
router baseapp.MessageRouter
|
||||
|
||||
config group.Config
|
||||
}
|
||||
|
||||
// NewKeeper creates a new group keeper.
|
||||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.Codec, router *baseapp.MsgServiceRouter, accKeeper group.AccountKeeper, config group.Config) Keeper {
|
||||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.Codec, router baseapp.MessageRouter, accKeeper group.AccountKeeper, config group.Config) Keeper {
|
||||
k := Keeper{
|
||||
key: storeKey,
|
||||
router: router,
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
|
||||
// doExecuteMsgs routes the messages to the registered handlers. Messages are limited to those that require no authZ or
|
||||
// by the account of group policy only. Otherwise this gives access to other peoples accounts as the sdk middlewares are bypassed
|
||||
func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *baseapp.MsgServiceRouter, proposal group.Proposal, groupPolicyAcc sdk.AccAddress, decisionPolicy group.DecisionPolicy) ([]sdk.Result, error) {
|
||||
func (s Keeper) doExecuteMsgs(ctx sdk.Context, router baseapp.MessageRouter, proposal group.Proposal, groupPolicyAcc sdk.AccAddress, decisionPolicy group.DecisionPolicy) ([]sdk.Result, error) {
|
||||
// Ensure it's not too early to execute the messages.
|
||||
minExecutionDate := proposal.SubmitTime.Add(decisionPolicy.GetMinExecutionPeriod())
|
||||
if ctx.BlockTime().Before(minExecutionDate) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user