forked from cerc-io/laconicd-deprecated
all: cleanup imports (#524)
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
@@ -40,7 +40,7 @@ func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*typ
|
||||
)
|
||||
}
|
||||
|
||||
addr := ethcmn.HexToAddress(req.Address)
|
||||
addr := common.HexToAddress(req.Address)
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
@@ -66,7 +66,7 @@ func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRe
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
|
||||
ethAddr := ethcmn.HexToAddress(req.Address)
|
||||
ethAddr := common.HexToAddress(req.Address)
|
||||
cosmosAddr := sdk.AccAddress(ethAddr.Bytes())
|
||||
|
||||
account := k.accountKeeper.GetAccount(ctx, cosmosAddr)
|
||||
@@ -134,7 +134,7 @@ func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*typ
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
|
||||
balanceInt := k.GetBalance(ethcmn.HexToAddress(req.Address))
|
||||
balanceInt := k.GetBalance(common.HexToAddress(req.Address))
|
||||
|
||||
return &types.QueryBalanceResponse{
|
||||
Balance: balanceInt.String(),
|
||||
@@ -157,8 +157,8 @@ func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*typ
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
|
||||
address := ethcmn.HexToAddress(req.Address)
|
||||
key := ethcmn.HexToHash(req.Key)
|
||||
address := common.HexToAddress(req.Address)
|
||||
key := common.HexToHash(req.Key)
|
||||
|
||||
state := k.GetState(address, key)
|
||||
stateHex := state.Hex()
|
||||
@@ -184,7 +184,7 @@ func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.Que
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
|
||||
address := ethcmn.HexToAddress(req.Address)
|
||||
address := common.HexToAddress(req.Address)
|
||||
code := k.GetCode(address)
|
||||
|
||||
return &types.QueryCodeResponse{
|
||||
@@ -208,7 +208,7 @@ func (k Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
k.WithContext(ctx)
|
||||
|
||||
hash := ethcmn.HexToHash(req.Hash)
|
||||
hash := common.HexToHash(req.Hash)
|
||||
logs := k.GetTxLogs(hash)
|
||||
|
||||
return &types.QueryTxLogsResponse{
|
||||
|
||||
@@ -8,10 +8,9 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
@@ -40,7 +39,7 @@ func (suite *KeeperTestSuite) TestQueryAccount() {
|
||||
func() {
|
||||
expAccount = &types.QueryAccountResponse{
|
||||
Balance: "0",
|
||||
CodeHash: common.BytesToHash(ethcrypto.Keccak256(nil)).Hex(),
|
||||
CodeHash: common.BytesToHash(crypto.Keccak256(nil)).Hex(),
|
||||
Nonce: 0,
|
||||
}
|
||||
req = &types.QueryAccountRequest{
|
||||
@@ -60,7 +59,7 @@ func (suite *KeeperTestSuite) TestQueryAccount() {
|
||||
|
||||
expAccount = &types.QueryAccountResponse{
|
||||
Balance: "100",
|
||||
CodeHash: common.BytesToHash(ethcrypto.Keccak256(nil)).Hex(),
|
||||
CodeHash: common.BytesToHash(crypto.Keccak256(nil)).Hex(),
|
||||
Nonce: 0,
|
||||
}
|
||||
req = &types.QueryAccountRequest{
|
||||
@@ -105,7 +104,7 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() {
|
||||
{"invalid address",
|
||||
func() {
|
||||
expAccount = &types.QueryCosmosAccountResponse{
|
||||
CosmosAddress: sdk.AccAddress(ethcmn.Address{}.Bytes()).String(),
|
||||
CosmosAddress: sdk.AccAddress(common.Address{}.Bytes()).String(),
|
||||
}
|
||||
req = &types.QueryCosmosAccountRequest{
|
||||
Address: invalidAddress,
|
||||
@@ -248,8 +247,8 @@ func (suite *KeeperTestSuite) TestQueryStorage() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
key := ethcmn.BytesToHash([]byte("key"))
|
||||
value := ethcmn.BytesToHash([]byte("value"))
|
||||
key := common.BytesToHash([]byte("key"))
|
||||
value := common.BytesToHash([]byte("value"))
|
||||
expValue = value.String()
|
||||
suite.app.EvmKeeper.SetState(suite.address, key, value)
|
||||
req = &types.QueryStorageRequest{
|
||||
@@ -350,14 +349,14 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() {
|
||||
{"empty hash",
|
||||
func() {
|
||||
req = &types.QueryTxLogsRequest{
|
||||
Hash: ethcmn.Hash{}.String(),
|
||||
Hash: common.Hash{}.String(),
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"logs not found",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("hash"))
|
||||
hash := common.BytesToHash([]byte("hash"))
|
||||
req = &types.QueryTxLogsRequest{
|
||||
Hash: hash.String(),
|
||||
}
|
||||
@@ -367,17 +366,17 @@ func (suite *KeeperTestSuite) TestQueryTxLogs() {
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("tx_hash"))
|
||||
hash := common.BytesToHash([]byte("tx_hash"))
|
||||
|
||||
expLogs = []*types.Log{
|
||||
{
|
||||
Address: suite.address.String(),
|
||||
Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()},
|
||||
Topics: []string{common.BytesToHash([]byte("topic")).String()},
|
||||
Data: []byte("data"),
|
||||
BlockNumber: 1,
|
||||
TxHash: hash.String(),
|
||||
TxIndex: 1,
|
||||
BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(),
|
||||
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
},
|
||||
@@ -427,14 +426,14 @@ func (suite *KeeperTestSuite) TestQueryBlockLogs() {
|
||||
{"empty hash",
|
||||
func() {
|
||||
req = &types.QueryBlockLogsRequest{
|
||||
Hash: ethcmn.Hash{}.String(),
|
||||
Hash: common.Hash{}.String(),
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"logs not found",
|
||||
func() {
|
||||
hash := ethcmn.BytesToHash([]byte("hash"))
|
||||
hash := common.BytesToHash([]byte("hash"))
|
||||
req = &types.QueryBlockLogsRequest{
|
||||
Hash: hash.String(),
|
||||
}
|
||||
@@ -445,46 +444,46 @@ func (suite *KeeperTestSuite) TestQueryBlockLogs() {
|
||||
"success",
|
||||
func() {
|
||||
|
||||
hash := ethcmn.BytesToHash([]byte("block_hash"))
|
||||
hash := common.BytesToHash([]byte("block_hash"))
|
||||
expLogs = []types.TransactionLogs{
|
||||
{
|
||||
Hash: ethcmn.BytesToHash([]byte("tx_hash_0")).String(),
|
||||
Hash: common.BytesToHash([]byte("tx_hash_0")).String(),
|
||||
Logs: []*types.Log{
|
||||
{
|
||||
Address: suite.address.String(),
|
||||
Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()},
|
||||
Topics: []string{common.BytesToHash([]byte("topic")).String()},
|
||||
Data: []byte("data"),
|
||||
BlockNumber: 1,
|
||||
TxHash: ethcmn.BytesToHash([]byte("tx_hash_0")).String(),
|
||||
TxHash: common.BytesToHash([]byte("tx_hash_0")).String(),
|
||||
TxIndex: 1,
|
||||
BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(),
|
||||
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Hash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
Hash: common.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
Logs: []*types.Log{
|
||||
{
|
||||
Address: suite.address.String(),
|
||||
Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()},
|
||||
Topics: []string{common.BytesToHash([]byte("topic")).String()},
|
||||
Data: []byte("data"),
|
||||
BlockNumber: 1,
|
||||
TxHash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
TxHash: common.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
TxIndex: 1,
|
||||
BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(),
|
||||
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
|
||||
Index: 1,
|
||||
Removed: false,
|
||||
},
|
||||
{
|
||||
Address: suite.address.String(),
|
||||
Topics: []string{ethcmn.BytesToHash([]byte("topic_1")).String()},
|
||||
Topics: []string{common.BytesToHash([]byte("topic_1")).String()},
|
||||
Data: []byte("data_1"),
|
||||
BlockNumber: 1,
|
||||
TxHash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
TxHash: common.BytesToHash([]byte("tx_hash_1")).String(),
|
||||
TxIndex: 1,
|
||||
BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(),
|
||||
BlockHash: common.BytesToHash([]byte("block_hash")).String(),
|
||||
Index: 2,
|
||||
Removed: false,
|
||||
},
|
||||
@@ -492,8 +491,8 @@ func (suite *KeeperTestSuite) TestQueryBlockLogs() {
|
||||
},
|
||||
}
|
||||
|
||||
suite.app.EvmKeeper.SetLogs(ethcmn.BytesToHash([]byte("tx_hash_0")), types.LogsToEthereum(expLogs[0].Logs))
|
||||
suite.app.EvmKeeper.SetLogs(ethcmn.BytesToHash([]byte("tx_hash_1")), types.LogsToEthereum(expLogs[1].Logs))
|
||||
suite.app.EvmKeeper.SetLogs(common.BytesToHash([]byte("tx_hash_0")), types.LogsToEthereum(expLogs[0].Logs))
|
||||
suite.app.EvmKeeper.SetLogs(common.BytesToHash([]byte("tx_hash_1")), types.LogsToEthereum(expLogs[1].Logs))
|
||||
|
||||
req = &types.QueryBlockLogsRequest{
|
||||
Hash: hash.String(),
|
||||
@@ -618,7 +617,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() {
|
||||
{"invalid address",
|
||||
func() {
|
||||
expAccount = &types.QueryValidatorAccountResponse{
|
||||
AccountAddress: sdk.AccAddress(ethcmn.Address{}.Bytes()).String(),
|
||||
AccountAddress: sdk.AccAddress(common.Address{}.Bytes()).String(),
|
||||
}
|
||||
req = &types.QueryValidatorAccountRequest{
|
||||
ConsAddress: "",
|
||||
|
||||
@@ -3,7 +3,7 @@ package keeper
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/tharsis/ethermint/x/evm/types"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks {
|
||||
}
|
||||
|
||||
// PostTxProcessing delegate the call to underlying hooks
|
||||
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, txHash ethcmn.Hash, logs []*ethtypes.Log) error {
|
||||
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, txHash common.Hash, logs []*ethtypes.Log) error {
|
||||
for i := range mh {
|
||||
if err := mh[i].PostTxProcessing(ctx, txHash, logs); err != nil {
|
||||
return sdkerrors.Wrapf(err, "EVM hook %T failed", mh[i])
|
||||
|
||||
@@ -28,11 +28,9 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
@@ -72,7 +70,7 @@ type KeeperTestSuite struct {
|
||||
ctx sdk.Context
|
||||
app *app.EthermintApp
|
||||
queryClient types.QueryClient
|
||||
address ethcmn.Address
|
||||
address common.Address
|
||||
consAddress sdk.ConsAddress
|
||||
|
||||
// for generate test tx
|
||||
@@ -90,7 +88,7 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
|
||||
// account key
|
||||
priv, err := ethsecp256k1.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
suite.address = ethcmn.BytesToAddress(priv.PubKey().Address().Bytes())
|
||||
suite.address = common.BytesToAddress(priv.PubKey().Address().Bytes())
|
||||
suite.signer = tests.NewSigner(priv)
|
||||
|
||||
// consensus key
|
||||
@@ -130,7 +128,7 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
|
||||
|
||||
acc := ðermint.EthAccount{
|
||||
BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0),
|
||||
CodeHash: common.BytesToHash(ethcrypto.Keccak256(nil)).String(),
|
||||
CodeHash: common.BytesToHash(crypto.Keccak256(nil)).String(),
|
||||
}
|
||||
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/tharsis/ethermint/tests"
|
||||
"github.com/tharsis/ethermint/x/evm/types"
|
||||
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestCreateAccount() {
|
||||
@@ -533,8 +532,8 @@ func (suite *KeeperTestSuite) TestSnapshot() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) CreateTestTx(msg *evmtypes.MsgEthereumTx, priv cryptotypes.PrivKey) authsigning.Tx {
|
||||
option, err := codectypes.NewAnyWithValue(&evmtypes.ExtensionOptionsEthereumTx{})
|
||||
func (suite *KeeperTestSuite) CreateTestTx(msg *types.MsgEthereumTx, priv cryptotypes.PrivKey) authsigning.Tx {
|
||||
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionsEthereumTx{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
txBuilder := suite.clientCtx.TxConfig.NewTxBuilder()
|
||||
@@ -558,14 +557,14 @@ func (suite *KeeperTestSuite) TestAddLog() {
|
||||
msg.From = addr.Hex()
|
||||
|
||||
tx := suite.CreateTestTx(msg, privKey)
|
||||
msg, _ = tx.GetMsgs()[0].(*evmtypes.MsgEthereumTx)
|
||||
msg, _ = tx.GetMsgs()[0].(*types.MsgEthereumTx)
|
||||
txHash := msg.AsTransaction().Hash()
|
||||
|
||||
msg2 := types.NewTx(big.NewInt(1), 1, &suite.address, big.NewInt(1), 100000, big.NewInt(1), []byte("test"), nil)
|
||||
msg2.From = addr.Hex()
|
||||
|
||||
tx2 := suite.CreateTestTx(msg2, privKey)
|
||||
msg2, _ = tx2.GetMsgs()[0].(*evmtypes.MsgEthereumTx)
|
||||
msg2, _ = tx2.GetMsgs()[0].(*types.MsgEthereumTx)
|
||||
txHash2 := msg2.AsTransaction().Hash()
|
||||
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user