2021-09-02 12:36:33 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
2022-09-07 06:36:11 +00:00
|
|
|
"github.com/cerc-io/laconicd/x/evm/types"
|
2021-09-02 12:36:33 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
2022-10-10 10:38:33 +00:00
|
|
|
"github.com/ethereum/go-ethereum/core"
|
2021-09-02 12:36:33 +00:00
|
|
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
2021-09-05 11:03:06 +00:00
|
|
|
var _ types.EvmHooks = MultiEvmHooks{}
|
2021-09-02 12:36:33 +00:00
|
|
|
|
|
|
|
// MultiEvmHooks combine multiple evm hooks, all hook functions are run in array sequence
|
|
|
|
type MultiEvmHooks []types.EvmHooks
|
|
|
|
|
|
|
|
// NewMultiEvmHooks combine multiple evm hooks
|
|
|
|
func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks {
|
|
|
|
return hooks
|
|
|
|
}
|
|
|
|
|
|
|
|
// PostTxProcessing delegate the call to underlying hooks
|
2022-10-10 10:38:33 +00:00
|
|
|
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
2021-09-02 12:36:33 +00:00
|
|
|
for i := range mh {
|
2022-10-10 10:38:33 +00:00
|
|
|
if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil {
|
2021-09-02 12:36:33 +00:00
|
|
|
return sdkerrors.Wrapf(err, "EVM hook %T failed", mh[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|