From 3cd47364f3ac27ad779817338cd81c4656854f4b Mon Sep 17 00:00:00 2001 From: codchen Date: Fri, 10 May 2024 12:12:30 +0800 Subject: [PATCH] Emit signer event for all transactions (#1651) --- x/evm/ante/preprocess.go | 11 ++++++++++- x/evm/types/events.go | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/x/evm/ante/preprocess.go b/x/evm/ante/preprocess.go index 2b13571b61..1fb3415e76 100644 --- a/x/evm/ante/preprocess.go +++ b/x/evm/ante/preprocess.go @@ -65,6 +65,9 @@ func (p *EVMPreprocessDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate derived := msg.Derived seiAddr := derived.SenderSeiAddr evmAddr := derived.SenderEVMAddr + ctx.EventManager().EmitEvent(sdk.NewEvent(evmtypes.EventTypeSigner, + sdk.NewAttribute(evmtypes.AttributeKeyEvmAddress, evmAddr.Hex()), + sdk.NewAttribute(evmtypes.AttributeKeySeiAddress, seiAddr.String()))) pubkey := derived.PubKey isAssociateTx := derived.IsAssociate _, isAssociated := p.evmKeeper.GetEVMAddress(ctx, seiAddr) @@ -353,7 +356,10 @@ func (p *EVMAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } signers := sigTx.GetSigners() for _, signer := range signers { - if _, associated := p.evmKeeper.GetEVMAddress(ctx, signer); associated { + if evmAddr, associated := p.evmKeeper.GetEVMAddress(ctx, signer); associated { + ctx.EventManager().EmitEvent(sdk.NewEvent(evmtypes.EventTypeSigner, + sdk.NewAttribute(evmtypes.AttributeKeyEvmAddress, evmAddr.Hex()), + sdk.NewAttribute(evmtypes.AttributeKeySeiAddress, signer.String()))) continue } acc := p.accountKeeper.GetAccount(ctx, signer) @@ -371,6 +377,9 @@ func (p *EVMAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo ctx.Logger().Error(fmt.Sprintf("failed to get EVM address from pubkey due to %s", err)) continue } + ctx.EventManager().EmitEvent(sdk.NewEvent(evmtypes.EventTypeSigner, + sdk.NewAttribute(evmtypes.AttributeKeyEvmAddress, evmAddr.Hex()), + sdk.NewAttribute(evmtypes.AttributeKeySeiAddress, signer.String()))) p.evmKeeper.SetAddressMapping(ctx, signer, evmAddr) if err := migrateBalance(ctx, p.evmKeeper, evmAddr, signer); err != nil { ctx.Logger().Error(fmt.Sprintf("failed to migrate EVM address balance (%s) %s", evmAddr.Hex(), err)) diff --git a/x/evm/types/events.go b/x/evm/types/events.go index 45ec378d9c..92a8f171e7 100644 --- a/x/evm/types/events.go +++ b/x/evm/types/events.go @@ -3,6 +3,7 @@ package types const ( EventTypeAddressAssociated = "address_associated" EventTypePointerRegistered = "pointer_registered" + EventTypeSigner = "signer" AttributeKeySeiAddress = "sei_addr" AttributeKeyEvmAddress = "evm_addr"