From e5b974c6ab8a069f084d7cb3983bbbf879f52ca6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 8 Aug 2022 15:13:12 -0400 Subject: [PATCH] chore: fee payer event (#12850) (#12855) --- types/events.go | 1 + x/auth/ante/fee.go | 7 ++++--- x/auth/tx/service_test.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/events.go b/types/events.go index 4e49d07ba5ec..4b930490a65f 100644 --- a/types/events.go +++ b/types/events.go @@ -228,6 +228,7 @@ const ( AttributeKeyAccountSequence = "acc_seq" AttributeKeySignature = "signature" AttributeKeyFee = "fee" + AttributeKeyFeePayer = "fee_payer" EventTypeMessage = "message" diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index b6927eababe0..ea6be8e2c56c 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -109,9 +109,10 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee } } - events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx, - sdk.NewAttribute(sdk.AttributeKeyFee, fee.String()), - )} + events := sdk.Events{ + sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, fee.String())), + sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String())), + } ctx.EventManager().EmitEvents(events) return nil diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index ca1a0186e333..8ed9575388a6 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -151,7 +151,7 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() { // - tx.* events: tx.fee, tx.acc_seq, tx.signature // - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender= // - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend - s.Require().Equal(len(res.GetResult().GetEvents()), 13) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. + s.Require().Equal(len(res.GetResult().GetEvents()), 14) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. } }) @@ -193,7 +193,7 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { s.Require().NoError(err) // Check the result and gas used are correct. s.Require().Len(result.GetResult().MsgResponses, 1) - s.Require().Equal(len(result.GetResult().GetEvents()), 13) // See TestSimulateTx_GRPC for the 13 events. + s.Require().Equal(len(result.GetResult().GetEvents()), 14) // See TestSimulateTx_GRPC for the 13 events. s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, jus } })