forked from cerc-io/laconicd-deprecated
refactor: updated to ante handlers support
This commit is contained in:
@@ -267,7 +267,7 @@ func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAdd
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
|
||||
}
|
||||
|
||||
updatedBalance, isNeg := bond.Balance.SafeSub(coins)
|
||||
updatedBalance, isNeg := bond.Balance.SafeSub(coins...)
|
||||
if isNeg {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance.")
|
||||
}
|
||||
@@ -336,7 +336,7 @@ func (k Keeper) TransferCoinsToModuleAccount(ctx sdk.Context, id, moduleAccount
|
||||
bondObj := k.GetBond(ctx, id)
|
||||
|
||||
// Deduct rent from bond.
|
||||
updatedBalance, isNeg := bondObj.Balance.SafeSub(coins)
|
||||
updatedBalance, isNeg := bondObj.Balance.SafeSub(coins...)
|
||||
|
||||
if isNeg {
|
||||
// Check if bond has sufficient funds.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
ethermint "github.com/tharsis/ethermint/types"
|
||||
"github.com/tharsis/ethermint/x/evm/types"
|
||||
@@ -67,7 +67,7 @@ func DoBenchmark(b *testing.B, txBuilder TxBuilder) {
|
||||
require.NoError(b, err)
|
||||
|
||||
fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
|
||||
err = authmiddleware.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
err = ante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
require.NoError(b, err)
|
||||
|
||||
rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
||||
@@ -134,7 +134,7 @@ func BenchmarkMessageCall(b *testing.B) {
|
||||
require.NoError(b, err)
|
||||
|
||||
fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
|
||||
err = authmiddleware.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
err = ante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
|
||||
require.NoError(b, err)
|
||||
|
||||
rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
|
||||
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
||||
|
||||
@@ -25,7 +25,7 @@ func (k Keeper) DeductTxCostsFromUserBalance(
|
||||
isContractCreation := txData.GetTo() == nil
|
||||
|
||||
// fetch sender account from signature
|
||||
signerAcc, err := authmiddleware.GetSignerAcc(ctx, k.accountKeeper, msgEthTx.GetFrom())
|
||||
signerAcc, err := ante.GetSignerAcc(ctx, k.accountKeeper, msgEthTx.GetFrom())
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrapf(err, "account not found for sender %s", msgEthTx.From)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (k Keeper) DeductTxCostsFromUserBalance(
|
||||
fees := sdk.Coins{sdk.NewCoin(denom, sdk.NewIntFromBigInt(feeAmt))}
|
||||
|
||||
// deduct the full gas cost from the user balance
|
||||
if err := authmiddleware.DeductFees(k.bankKeeper, ctx, signerAcc, fees); err != nil {
|
||||
if err := ante.DeductFees(k.bankKeeper, ctx, signerAcc, fees); err != nil {
|
||||
return nil, sdkerrors.Wrapf(
|
||||
err,
|
||||
"failed to deduct full gas cost %s from the user %s balance",
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
@@ -127,7 +128,7 @@ func SimulateEthCreateContract(ak types.AccountKeeper, k *keeper.Keeper) simtype
|
||||
from := common.BytesToAddress(simAccount.Address)
|
||||
nonce := k.GetNonce(ctx, from)
|
||||
|
||||
ctorArgs, err := types.ERC20Contract.ABI.Pack("", from, sdk.NewIntWithDecimal(1000, 18).BigInt())
|
||||
ctorArgs, err := types.ERC20Contract.ABI.Pack("", from, math.NewIntWithDecimal(1000, 18).BigInt())
|
||||
if err != nil {
|
||||
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "can not pack owner and supply"), nil, err
|
||||
}
|
||||
|
||||
+2
-4
@@ -11,7 +11,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
|
||||
@@ -23,9 +22,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = &MsgEthereumTx{}
|
||||
_ sdk.Tx = &MsgEthereumTx{}
|
||||
_ authmiddleware.GasTx = &MsgEthereumTx{}
|
||||
_ sdk.Msg = &MsgEthereumTx{}
|
||||
_ sdk.Tx = &MsgEthereumTx{}
|
||||
|
||||
_ codectypes.UnpackInterfacesMessage = MsgEthereumTx{}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user