forked from cerc-io/laconicd-deprecated
ante: move deduct gas to EVM keeper (#584)
This commit is contained in:
@@ -12,12 +12,9 @@ import (
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
// AccountKeeper defines an expected keeper interface for the auth module's AccountKeeper
|
||||
// DeductTxCostsFromUserBalance it calculates the tx costs and deducts the fees
|
||||
func DeductTxCostsFromUserBalance(
|
||||
func (k Keeper) DeductTxCostsFromUserBalance(
|
||||
ctx sdk.Context,
|
||||
bankKeeper evmtypes.BankKeeper,
|
||||
accountKeeper evmtypes.AccountKeeper,
|
||||
msgEthTx evmtypes.MsgEthereumTx,
|
||||
txData evmtypes.TxData,
|
||||
denom string,
|
||||
@@ -27,7 +24,7 @@ func DeductTxCostsFromUserBalance(
|
||||
isContractCreation := txData.GetTo() == nil
|
||||
|
||||
// fetch sender account from signature
|
||||
signerAcc, err := authante.GetSignerAcc(ctx, accountKeeper, msgEthTx.GetFrom())
|
||||
signerAcc, err := authante.GetSignerAcc(ctx, k.accountKeeper, msgEthTx.GetFrom())
|
||||
if err != nil {
|
||||
return nil, stacktrace.Propagate(err, "account not found for sender %s", msgEthTx.From)
|
||||
}
|
||||
@@ -62,7 +59,7 @@ func DeductTxCostsFromUserBalance(
|
||||
fees := sdk.Coins{sdk.NewCoin(denom, sdk.NewIntFromBigInt(feeAmt))}
|
||||
|
||||
// deduct the full gas cost from the user balance
|
||||
if err := authante.DeductFees(bankKeeper, ctx, signerAcc, fees); err != nil {
|
||||
if err := authante.DeductFees(k.bankKeeper, ctx, signerAcc, fees); err != nil {
|
||||
return nil, stacktrace.Propagate(
|
||||
err,
|
||||
"failed to deduct full gas cost %s from the user %s balance",
|
||||
|
||||
@@ -235,10 +235,8 @@ func (suite *KeeperTestSuite) TestDeductTxCostsFromUserBalance() {
|
||||
|
||||
txData, _ := evmtypes.UnpackTxData(tx.Data)
|
||||
|
||||
fees, err := evmkeeper.DeductTxCostsFromUserBalance(
|
||||
fees, err := suite.app.EvmKeeper.DeductTxCostsFromUserBalance(
|
||||
suite.app.EvmKeeper.Ctx(),
|
||||
suite.app.BankKeeper,
|
||||
suite.app.AccountKeeper,
|
||||
*tx,
|
||||
txData,
|
||||
evmtypes.DefaultEVMDenom,
|
||||
|
||||
Reference in New Issue
Block a user