forked from cerc-io/laconicd-deprecated
fix: revert changes from TypedEvents (#1600)
* fix: revert changes from TypedEvents * fix: formatter and linter * fix: double quote to prevent globbing and word splitting * fix: added token to codecov * fix: re-added events.proto for usage later
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
||||
@@ -13,5 +14,5 @@ func (suite *KeeperTestSuite) TestEndBlock() {
|
||||
|
||||
// should emit 1 EventTypeBlockBloom event on EndBlock
|
||||
suite.Require().Equal(1, len(em.Events()))
|
||||
suite.Require().Equal("ethermint.evm.v1.EventBlockBloom", em.Events()[0].Type)
|
||||
suite.Require().Equal(evmtypes.EventTypeBlockBloom, em.Events()[0].Type)
|
||||
}
|
||||
|
||||
@@ -147,14 +147,12 @@ func (k Keeper) ChainID() *big.Int {
|
||||
|
||||
// EmitBlockBloomEvent emit block bloom events
|
||||
func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
|
||||
err := ctx.EventManager().EmitTypedEvent(
|
||||
&types.EventBlockBloom{
|
||||
Bloom: string(bloom.Bytes()),
|
||||
},
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeBlockBloom,
|
||||
sdk.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
k.Logger(ctx).Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// GetAuthority returns the x/evm module authority address
|
||||
|
||||
+27
-23
@@ -89,52 +89,56 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
|
||||
}
|
||||
}()
|
||||
|
||||
eventEthereumTx := &types.EventEthereumTx{
|
||||
Amount: tx.Value().String(),
|
||||
attrs := []sdk.Attribute{
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, tx.Value().String()),
|
||||
// add event for ethereum transaction hash format
|
||||
EthHash: response.Hash,
|
||||
sdk.NewAttribute(types.AttributeKeyEthereumTxHash, response.Hash),
|
||||
// add event for index of valid ethereum tx
|
||||
Index: strconv.FormatUint(txIndex, 10),
|
||||
sdk.NewAttribute(types.AttributeKeyTxIndex, strconv.FormatUint(txIndex, 10)),
|
||||
// add event for eth tx gas used, we can't get it from cosmos tx result when it contains multiple eth tx msgs.
|
||||
GasUsed: strconv.FormatUint(response.GasUsed, 10),
|
||||
sdk.NewAttribute(types.AttributeKeyTxGasUsed, strconv.FormatUint(response.GasUsed, 10)),
|
||||
}
|
||||
|
||||
if len(ctx.TxBytes()) > 0 {
|
||||
// add event for tendermint transaction hash format
|
||||
hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash())
|
||||
eventEthereumTx.Hash = hash.String()
|
||||
attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyTxHash, hash.String()))
|
||||
}
|
||||
|
||||
if to := tx.To(); to != nil {
|
||||
eventEthereumTx.Recipient = to.Hex()
|
||||
attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyRecipient, to.Hex()))
|
||||
}
|
||||
|
||||
if response.Failed() {
|
||||
eventEthereumTx.EthTxFailed = response.VmError
|
||||
attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyEthereumTxFailed, response.VmError))
|
||||
}
|
||||
|
||||
eventTxLogs := &types.EventTxLog{TxLogs: make([]string, len(response.Logs))}
|
||||
txLogAttrs := make([]sdk.Attribute, len(response.Logs))
|
||||
for i, log := range response.Logs {
|
||||
value, err := json.Marshal(log)
|
||||
if err != nil {
|
||||
return nil, errorsmod.Wrap(err, "failed to encode log")
|
||||
}
|
||||
eventTxLogs.TxLogs[i] = string(value)
|
||||
txLogAttrs[i] = sdk.NewAttribute(types.AttributeKeyTxLog, string(value))
|
||||
}
|
||||
|
||||
err = ctx.EventManager().EmitTypedEvents(
|
||||
eventEthereumTx,
|
||||
eventTxLogs,
|
||||
&types.EventMessage{
|
||||
Module: types.AttributeValueCategory,
|
||||
Sender: sender,
|
||||
TxType: fmt.Sprintf("%d", tx.Type()),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
k.Logger(ctx).Error(err.Error())
|
||||
}
|
||||
// emit events
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeEthereumTx,
|
||||
attrs...,
|
||||
),
|
||||
sdk.NewEvent(
|
||||
types.EventTypeTxLog,
|
||||
txLogAttrs...,
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, sender),
|
||||
sdk.NewAttribute(types.AttributeKeyTxType, fmt.Sprintf("%d", tx.Type())),
|
||||
),
|
||||
})
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
Generated
-1264
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user