Skip to content

Commit

Permalink
refactor!: remove HandleMsgExec
Browse files Browse the repository at this point in the history
  • Loading branch information
manu0466 committed Jul 3, 2024
1 parent 5ade6d9 commit 21b55c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
14 changes: 2 additions & 12 deletions modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
22 changes: 2 additions & 20 deletions parser/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down

0 comments on commit 21b55c5

Please sign in to comment.