From 21b55c5b13da95310f09ad47f360398787f800ef Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 3 Jul 2024 18:24:00 +0200 Subject: [PATCH] refactor!: remove HandleMsgExec --- modules/module.go | 14 ++------------ parser/worker.go | 22 ++-------------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/modules/module.go b/modules/module.go index 79012133..9eceda01 100644 --- a/modules/module.go +++ b/modules/module.go @@ -6,10 +6,9 @@ import ( tmctypes "github.com/cometbft/cometbft/rpc/core/types" tmtypes "github.com/cometbft/cometbft/types" - sdk "github.com/forbole/juno/v5/cosmos-sdk/types" "github.com/go-co-op/gocron" - "github.com/forbole/juno/v5/cosmos-sdk/x/authz" + codectypes "github.com/forbole/juno/v5/cosmos-sdk/codec/types" "github.com/forbole/juno/v5/types" ) @@ -96,14 +95,5 @@ type MessageModule interface { // are passed as well. // NOTE. The returned error will be logged using the MsgError method. All other modules' handlers // will still be called. - HandleMsg(index int, msg sdk.Msg, tx *types.Tx) error -} - -type AuthzMessageModule interface { - // HandleMsgExec handles a single message that is contained within an authz.MsgExec instance. - // For convenience of use, the index of the message inside the transaction and the transaction itself - // are passed as well. - // NOTE. The returned error will be logged using the MsgError method. All other modules' handlers - // will still be called. - HandleMsgExec(index int, msgExec *authz.MsgExec, authzMsgIndex int, executedMsg sdk.Msg, tx *types.Tx) error + HandleMsg(index int, msg *codectypes.Any, tx *types.Tx) error } diff --git a/parser/worker.go b/parser/worker.go index 1d9f7d72..1ecee47c 100644 --- a/parser/worker.go +++ b/parser/worker.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/forbole/juno/v5/cosmos-sdk/x/authz" "github.com/forbole/juno/v5/utils" "github.com/forbole/juno/v5/database" @@ -19,6 +18,7 @@ import ( tmtypes "github.com/cometbft/cometbft/types" sdk "github.com/forbole/juno/v5/cosmos-sdk/types" + codectypes "github.com/forbole/juno/v5/cosmos-sdk/codec/types" "github.com/forbole/juno/v5/node" "github.com/forbole/juno/v5/types" ) @@ -327,7 +327,7 @@ func (w Worker) handleTx(tx *types.Tx) error { // handleMessage accepts the transaction and handles messages contained // inside the transaction. -func (w Worker) handleMessage(index int, msg sdk.Msg, tx *types.Tx) error { +func (w Worker) handleMessage(index int, msg *codectypes.Any, tx *types.Tx) error { // Allow modules to handle the message for _, module := range w.modules { if messageModule, ok := module.(modules.MessageModule); ok { @@ -340,24 +340,6 @@ func (w Worker) handleMessage(index int, msg sdk.Msg, tx *types.Tx) error { } } - // If it's a MsgExecute, we need to make sure the included messages are handled as well - if msgExec, ok := msg.(*authz.MsgExec); ok { - for authzIndex, executedMsg := range msgExec.Msgs { - for _, module := range w.modules { - if messageModule, ok := module.(modules.AuthzMessageModule); ok { - err := messageModule.HandleMsgExec(index, msgExec, authzIndex, executedMsg, tx) - if err != nil { - if w.shouldReEnqueueWhenFailed() { - return err - } - - w.logger.MsgError(module, tx, executedMsg, err) - } - } - } - } - } - return nil }