From edd1c7107201bdf31ce4ec47c39801544194480a Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 4 Apr 2024 12:56:32 +0200 Subject: [PATCH] feat(core): add `TxValidator` interface (#19950) --- core/appmodule/v2/module.go | 4 ++-- core/appmodule/v2/tx_validator.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 core/appmodule/v2/tx_validator.go diff --git a/core/appmodule/v2/module.go b/core/appmodule/v2/module.go index 47d5812577..4a3dece06e 100644 --- a/core/appmodule/v2/module.go +++ b/core/appmodule/v2/module.go @@ -47,10 +47,10 @@ type HasEndBlocker interface { EndBlock(context.Context) error } -// HasTxValidation is the extension interface that modules should implement to run +// HasTxValidator is the extension interface that modules should implement to run // custom logic for validating transactions. // It was previously known as AnteHandler/Decorator. -type HasTxValidation[T transaction.Tx] interface { +type HasTxValidator[T transaction.Tx] interface { AppModule // TxValidator is a method that will be run on each transaction. diff --git a/core/appmodule/v2/tx_validator.go b/core/appmodule/v2/tx_validator.go new file mode 100644 index 0000000000..0ef877af00 --- /dev/null +++ b/core/appmodule/v2/tx_validator.go @@ -0,0 +1,13 @@ +package appmodule + +import ( + "context" + + "cosmossdk.io/core/transaction" +) + +// TxValidator represent the method that a TxValidator should implement. +// It was previously known as AnteHandler/Decorator.AnteHandle +type TxValidator[T transaction.Tx] interface { + ValidateTx(ctx context.Context, tx T) error +}