diff --git a/baseapp/abci.go b/baseapp/abci.go index a0bc3aa9a..c112db5a7 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -327,6 +327,9 @@ func (app *BaseApp) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx, tx sdk resultStr = "failed" } } + for _, hook := range app.deliverTxHooks { + hook(ctx, tx, checksum, res) + } return } diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 57eeb072a..1b75579dd 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -75,6 +75,8 @@ type ( // an older version of the software. In particular, if a module changed the substore key name // (or removed a substore) between two versions of the software. StoreLoader func(ms sdk.CommitMultiStore) error + + DeliverTxHook func(sdk.Context, sdk.Tx, [32]byte, abci.ResponseDeliverTx) ) // BaseApp reflects the ABCI application implementation. @@ -172,6 +174,8 @@ type BaseApp struct { //nolint: maligned concurrencyWorkers int occEnabled bool + + deliverTxHooks []DeliverTxHook } type appStore struct { @@ -279,6 +283,7 @@ func NewBaseApp( }, commitLock: &sync.Mutex{}, checkTxStateLock: &sync.RWMutex{}, + deliverTxHooks: []DeliverTxHook{}, } app.TracingInfo.SetContext(context.Background()) @@ -1203,3 +1208,7 @@ func (app *BaseApp) GetCheckCtx() sdk.Context { defer app.checkTxStateLock.RUnlock() return app.checkState.ctx } + +func (app *BaseApp) RegisterDeliverTxHook(hook DeliverTxHook) { + app.deliverTxHooks = append(app.deliverTxHooks, hook) +}