Skip to content

Commit

Permalink
chore: fee payer event (#12850)
Browse files Browse the repository at this point in the history
* updates

* updates

* updates

(cherry picked from commit a6159fe)

# Conflicts:
#	x/auth/ante/fee.go
#	x/auth/tx/service_test.go
  • Loading branch information
alexanderbez authored and mergify[bot] committed Aug 8, 2022
1 parent 4b31a06 commit 22ba482
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ var (
AttributeKeyAccountSequence = "acc_seq"
AttributeKeySignature = "signature"
AttributeKeyFee = "fee"
AttributeKeyFeePayer = "fee_payer"

EventTypeMessage = "message"

Expand Down
7 changes: 7 additions & 0 deletions x/auth/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,16 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
}
}

<<<<<<< HEAD
events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx,
sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()),
)}
=======
events := sdk.Events{
sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, fee.String())),
sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String())),
}
>>>>>>> a6159feab (chore: fee payer event (#12850))
ctx.EventManager().EmitEvents(events)

return next(ctx, tx, simulate)
Expand Down
17 changes: 17 additions & 0 deletions x/auth/tx/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,19 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() {
} else {
s.Require().NoError(err)
// Check the result and gas used are correct.
<<<<<<< HEAD
s.Require().Equal(len(res.GetResult().GetEvents()), 6) // 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.
=======
//
// The 13 events are:
// - Sending Fee to the pool: coin_spent, coin_received, transfer and message.sender=<val1>
// - tx.* events: tx.fee, tx.acc_seq, tx.signature
// - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender=<val1>
// - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend
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.
>>>>>>> a6159feab (chore: fee payer event (#12850))
}
})
}
Expand Down Expand Up @@ -185,8 +196,14 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() {
err = val.ClientCtx.Codec.UnmarshalJSON(res, &result)
s.Require().NoError(err)
// Check the result and gas used are correct.
<<<<<<< HEAD
s.Require().Equal(len(result.GetResult().GetEvents()), 6) // 1 coin recv, 1 coin spent,1 transfer, 3 messages.
s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
=======
s.Require().Len(result.GetResult().MsgResponses, 1)
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
>>>>>>> a6159feab (chore: fee payer event (#12850))
}
})
}
Expand Down

0 comments on commit 22ba482

Please sign in to comment.