forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: decode tx is unnecessary in tx listener (#491)
* Problem: decode tx is unnecessary in tx listener * cleanup
- Loading branch information
Showing
6 changed files
with
56 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ante | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ethereum/go-ethereum/common" | ||
evmtypes "github.com/evmos/ethermint/x/evm/types" | ||
) | ||
|
||
type PendingTxListener func(common.Hash) | ||
|
||
type TxListenerDecorator struct { | ||
pendingTxListener PendingTxListener | ||
} | ||
|
||
// newTxListenerDecorator creates a new TxListenerDecorator with the provided PendingTxListener. | ||
// CONTRACT: must be put at the last of the chained decorators | ||
func newTxListenerDecorator(pendingTxListener PendingTxListener) TxListenerDecorator { | ||
return TxListenerDecorator{pendingTxListener} | ||
} | ||
|
||
func (d TxListenerDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { | ||
if ctx.IsReCheckTx() { | ||
return next(ctx, tx, simulate) | ||
} | ||
if ctx.IsCheckTx() && !simulate && d.pendingTxListener != nil { | ||
for _, msg := range tx.GetMsgs() { | ||
if ethTx, ok := msg.(*evmtypes.MsgEthereumTx); ok { | ||
d.pendingTxListener(ethTx.Hash()) | ||
} | ||
} | ||
} | ||
return next(ctx, tx, simulate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters