Skip to content

Commit

Permalink
always import types as ethermint
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Oct 24, 2024
1 parent e228382 commit 19678f3
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
)

Expand All @@ -48,7 +48,7 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
chainCfg := evmParams.GetChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
signer := types.MakeSigner(ethCfg, blockNum)
signer := ethermint.MakeSigner(ethCfg, blockNum)

for _, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
Expand Down
3 changes: 2 additions & 1 deletion ethereum/eip712/encoding_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

apitypes "github.com/ethereum/go-ethereum/signer/core/apitypes"
"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
)

type aminoMessage struct {
Expand Down Expand Up @@ -178,7 +179,7 @@ func legacyDecodeProtobufSignDoc(signDocBytes []byte) (apitypes.TypedData, error

signerInfo := authInfo.SignerInfos[0]

chainID, err := types.ParseChainID(signDoc.ChainId)
chainID, err := ethermint.ParseChainID(signDoc.ChainId)
if err != nil {
return apitypes.TypedData{}, fmt.Errorf("invalid chain ID passed as argument: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ schema = 3
version = "v0.4.0"
hash = "sha256-Ol5bznli6Dh5uXi8GUGsjZo8DzCdF0hqsUMwDNUpxP0="
[mod."github.com/ethereum/go-ethereum"]
version = "v1.13.16-0.20241018211122-a3509360e99b"
hash = "sha256-ijnOmKYj308G5WOlFVkMFcQ7AqMdtxrWCadikdpTVkY="
version = "v1.13.16-0.20241022183758-422c6ef93ccc"
hash = "sha256-Nxipk3PKrfSb/IxBz6r69rPtcnFSDMYj0UWOC0WJibI="
replaced = "github.com/zeta-chain/go-ethereum"
[mod."github.com/felixge/httpsnoop"]
version = "v1.0.4"
Expand Down
4 changes: 2 additions & 2 deletions rpc/backend/sign_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/signer/core/apitypes"

"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, e
return common.Hash{}, err
}

signer := types.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(uint64(bn)))
signer := ethermint.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(uint64(bn)))

// Sign transaction
if err := msg.Sign(signer, b.clientCtx.Keyring); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/evm/keeper/state_transition_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
)

Expand Down Expand Up @@ -145,7 +145,7 @@ func newNativeMessage(
data []byte,
accessList ethtypes.AccessList,
) (*core.Message, error) {
msgSigner := types.MakeSigner(cfg, big.NewInt(blockHeight))
msgSigner := ethermint.MakeSigner(cfg, big.NewInt(blockHeight))

msg, baseFee, err := newEthMsgTx(nonce, blockHeight, address, cfg, krSigner, ethSigner, txType, data, accessList)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions x/evm/types/access_list_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
)

func newAccessListTx(tx *ethtypes.Transaction) (*AccessListTx, error) {
Expand All @@ -41,15 +41,15 @@ func newAccessListTx(tx *ethtypes.Transaction) (*AccessListTx, error) {
}

if tx.Value() != nil {
amountInt, err := types.SafeNewIntFromBigInt(tx.Value())
amountInt, err := ethermint.SafeNewIntFromBigInt(tx.Value())
if err != nil {
return nil, err
}
txData.Amount = &amountInt
}

if tx.GasPrice() != nil {
gasPriceInt, err := types.SafeNewIntFromBigInt(tx.GasPrice())
gasPriceInt, err := ethermint.SafeNewIntFromBigInt(tx.GasPrice())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (tx AccessListTx) Validate() error {
if gasPrice == nil {
return errorsmod.Wrap(ErrInvalidGasPrice, "cannot be nil")
}
if !types.IsValidInt256(gasPrice) {
if !ethermint.IsValidInt256(gasPrice) {
return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
}

Expand All @@ -214,16 +214,16 @@ func (tx AccessListTx) Validate() error {
if amount != nil && amount.Sign() == -1 {
return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
}
if !types.IsValidInt256(amount) {
if !ethermint.IsValidInt256(amount) {
return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
}

if !types.IsValidInt256(tx.Fee()) {
if !ethermint.IsValidInt256(tx.Fee()) {
return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
}

if tx.To != "" {
if err := types.ValidateAddress(tx.To); err != nil {
if err := ethermint.ValidateAddress(tx.To); err != nil {
return errorsmod.Wrap(err, "invalid to address")
}
}
Expand Down
18 changes: 9 additions & 9 deletions x/evm/types/dynamic_fee_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
)

func newDynamicFeeTx(tx *ethtypes.Transaction) (*DynamicFeeTx, error) {
Expand All @@ -41,23 +41,23 @@ func newDynamicFeeTx(tx *ethtypes.Transaction) (*DynamicFeeTx, error) {
}

if tx.Value() != nil {
amountInt, err := types.SafeNewIntFromBigInt(tx.Value())
amountInt, err := ethermint.SafeNewIntFromBigInt(tx.Value())
if err != nil {
return nil, err
}
txData.Amount = &amountInt
}

if tx.GasFeeCap() != nil {
gasFeeCapInt, err := types.SafeNewIntFromBigInt(tx.GasFeeCap())
gasFeeCapInt, err := ethermint.SafeNewIntFromBigInt(tx.GasFeeCap())
if err != nil {
return nil, err
}
txData.GasFeeCap = &gasFeeCapInt
}

if tx.GasTipCap() != nil {
gasTipCapInt, err := types.SafeNewIntFromBigInt(tx.GasTipCap())
gasTipCapInt, err := ethermint.SafeNewIntFromBigInt(tx.GasTipCap())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -226,11 +226,11 @@ func (tx DynamicFeeTx) Validate() error {
return errorsmod.Wrapf(ErrInvalidGasCap, "gas fee cap cannot be negative %s", tx.GasFeeCap)
}

if !types.IsValidInt256(tx.GetGasTipCap()) {
if !ethermint.IsValidInt256(tx.GetGasTipCap()) {
return errorsmod.Wrap(ErrInvalidGasCap, "out of bound")
}

if !types.IsValidInt256(tx.GetGasFeeCap()) {
if !ethermint.IsValidInt256(tx.GetGasFeeCap()) {
return errorsmod.Wrap(ErrInvalidGasCap, "out of bound")
}

Expand All @@ -241,7 +241,7 @@ func (tx DynamicFeeTx) Validate() error {
)
}

if !types.IsValidInt256(tx.Fee()) {
if !ethermint.IsValidInt256(tx.Fee()) {
return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
}

Expand All @@ -250,12 +250,12 @@ func (tx DynamicFeeTx) Validate() error {
if amount != nil && amount.Sign() == -1 {
return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
}
if !types.IsValidInt256(amount) {
if !ethermint.IsValidInt256(amount) {
return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
}

if tx.To != "" {
if err := types.ValidateAddress(tx.To); err != nil {
if err := ethermint.ValidateAddress(tx.To); err != nil {
return errorsmod.Wrap(err, "invalid to address")
}
}
Expand Down
14 changes: 7 additions & 7 deletions x/evm/types/legacy_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
errorsmod "cosmossdk.io/errors"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
)

func newLegacyTx(tx *ethtypes.Transaction) (*LegacyTx, error) {
Expand All @@ -37,15 +37,15 @@ func newLegacyTx(tx *ethtypes.Transaction) (*LegacyTx, error) {
}

if tx.Value() != nil {
amountInt, err := types.SafeNewIntFromBigInt(tx.Value())
amountInt, err := ethermint.SafeNewIntFromBigInt(tx.Value())
if err != nil {
return nil, err
}
txData.Amount = &amountInt
}

if tx.GasPrice() != nil {
gasPriceInt, err := types.SafeNewIntFromBigInt(tx.GasPrice())
gasPriceInt, err := ethermint.SafeNewIntFromBigInt(tx.GasPrice())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -181,10 +181,10 @@ func (tx LegacyTx) Validate() error {
if gasPrice.Sign() == -1 {
return errorsmod.Wrapf(ErrInvalidGasPrice, "gas price cannot be negative %s", gasPrice)
}
if !types.IsValidInt256(gasPrice) {
if !ethermint.IsValidInt256(gasPrice) {
return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
}
if !types.IsValidInt256(tx.Fee()) {
if !ethermint.IsValidInt256(tx.Fee()) {
return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
}

Expand All @@ -193,12 +193,12 @@ func (tx LegacyTx) Validate() error {
if amount != nil && amount.Sign() == -1 {
return errorsmod.Wrapf(ErrInvalidAmount, "amount cannot be negative %s", amount)
}
if !types.IsValidInt256(amount) {
if !ethermint.IsValidInt256(amount) {
return errorsmod.Wrap(ErrInvalidAmount, "out of bound")
}

if tx.To != "" {
if err := types.ValidateAddress(tx.To); err != nil {
if err := ethermint.ValidateAddress(tx.To); err != nil {
return errorsmod.Wrap(err, "invalid to address")
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"

"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
Expand Down Expand Up @@ -182,7 +182,7 @@ func (msg MsgEthereumTx) Type() string { return TypeMsgEthereumTx }
// checks of a Transaction. If returns an error if validation fails.
func (msg MsgEthereumTx) ValidateBasic() error {
if msg.From != "" {
if err := types.ValidateAddress(msg.From); err != nil {
if err := ethermint.ValidateAddress(msg.From); err != nil {
return errorsmod.Wrap(err, "invalid from address")
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/zeta-chain/ethermint/types"
ethermint "github.com/zeta-chain/ethermint/types"
)

var (
// DefaultEVMDenom defines the default EVM denomination on Ethermint
DefaultEVMDenom = types.AttoPhoton
DefaultEVMDenom = ethermint.AttoPhoton
// DefaultAllowUnprotectedTxs rejects all unprotected txs (i.e false)
DefaultAllowUnprotectedTxs = false
// DefaultEnableCreate enables contract creation (i.e true)
Expand Down

0 comments on commit 19678f3

Please sign in to comment.