forked from cerc-io/laconicd-deprecated
evm: implement ADR-002 EVM Hooks (#417)
* Allow evm to call native modules through logs Closes #416 comment add txHash parameter review suggestions add hooks test * Update x/evm/keeper/hooks.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * Update x/evm/keeper/hooks_test.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * Update x/evm/keeper/keeper.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * Update x/evm/keeper/keeper.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * Update x/evm/keeper/keeper.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * use table tests * update adr comment * update adr * changelog * Update CHANGELOG.md Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
parent
b76d024225
commit
089afe41a8
@@ -54,6 +54,9 @@ type Keeper struct {
|
||||
// trace EVM state transition execution. This value is obtained from the `--trace` flag.
|
||||
// For more info check https://geth.ethereum.org/docs/dapp/tracing
|
||||
debug bool
|
||||
|
||||
// EVM Hooks for tx post-processing
|
||||
hooks types.EvmHooks
|
||||
}
|
||||
|
||||
// NewKeeper generates new evm module keeper
|
||||
@@ -416,3 +419,21 @@ func (k Keeper) ResetAccount(addr common.Address) {
|
||||
k.DeleteCode(addr)
|
||||
k.DeleteAccountStorage(addr)
|
||||
}
|
||||
|
||||
// SetHooks sets the hooks for the EVM module
|
||||
func (k *Keeper) SetHooks(eh types.EvmHooks) *Keeper {
|
||||
if k.hooks != nil {
|
||||
panic("cannot set evm hooks twice")
|
||||
}
|
||||
|
||||
k.hooks = eh
|
||||
return k
|
||||
}
|
||||
|
||||
// PostTxProcessing delegate the call to the hooks. If no hook has been registered, this function returns with a `nil` error
|
||||
func (k *Keeper) PostTxProcessing(txHash common.Hash, logs []*ethtypes.Log) error {
|
||||
if k.hooks == nil {
|
||||
return nil
|
||||
}
|
||||
return k.hooks.PostTxProcessing(k.Ctx(), txHash, logs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user