feat: use sdk.Int for TxData (#208)

* feat: use sdk.Int for TxData

* c++

* fix

* fix test

* fix rpc

* lint
This commit is contained in:
Federico Kunze Küllmer
2021-06-30 15:28:38 +00:00
committed by GitHub
parent 0113b4d2c0
commit 86e30e8fa3
24 changed files with 359 additions and 1085 deletions
+2 -12
View File
@@ -215,12 +215,7 @@ func (e *PublicAPI) GetBalance(address common.Address, blockNum rpctypes.BlockNu
return nil, err
}
val, err := ethermint.UnmarshalBigInt(res.Balance)
if err != nil {
return nil, err
}
return (*hexutil.Big)(val), nil
return (*hexutil.Big)(big.NewInt(res.Balance)), nil
}
// GetStorageAt returns the contract storage at the given address, block number, and key.
@@ -997,15 +992,10 @@ func (e *PublicAPI) GetProof(address common.Address, storageKeys []string, block
accProofStr = proof.String()
}
balance, err := ethermint.UnmarshalBigInt(res.Balance)
if err != nil {
return nil, err
}
return &rpctypes.AccountResult{
Address: address,
AccountProof: []string{accProofStr},
Balance: (*hexutil.Big)(balance),
Balance: (*hexutil.Big)(big.NewInt(res.Balance)),
CodeHash: common.HexToHash(res.CodeHash),
Nonce: hexutil.Uint64(res.Nonce),
StorageHash: common.Hash{}, // NOTE: Ethermint doesn't have a storage hash. TODO: implement?
+6 -3
View File
@@ -6,6 +6,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
sdk "github.com/cosmos/cosmos-sdk/types"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
)
@@ -100,7 +103,7 @@ func (args *SendTxArgs) ToTransaction() *evmtypes.MsgEthereumTx {
}
if args.ChainID != nil {
data.ChainID = args.ChainID.ToInt().Bytes()
data.ChainID = sdk.NewIntFromBigInt(args.ChainID.ToInt())
}
if args.Nonce != nil {
@@ -112,11 +115,11 @@ func (args *SendTxArgs) ToTransaction() *evmtypes.MsgEthereumTx {
}
if args.GasPrice != nil {
data.GasPrice = args.GasPrice.ToInt().Bytes()
data.GasPrice = sdk.NewIntFromBigInt(args.GasPrice.ToInt())
}
if args.Value != nil {
data.Amount = args.Value.ToInt().Bytes()
data.Amount = sdk.NewIntFromBigInt(args.Value.ToInt())
}
if args.To != nil {
+8 -2
View File
@@ -270,14 +270,15 @@ func NewTransactionFromData(
}
rpcTx := &RPCTransaction{
Type: hexutil.Uint64(txData.Type()),
From: from,
Gas: hexutil.Uint64(txData.GasLimit),
GasPrice: (*hexutil.Big)(new(big.Int).SetBytes(txData.GasPrice)),
GasPrice: (*hexutil.Big)(txData.GasPrice.BigInt()),
Hash: txHash,
Input: hexutil.Bytes(txData.Input),
Nonce: hexutil.Uint64(txData.Nonce),
To: to,
Value: (*hexutil.Big)(new(big.Int).SetBytes(txData.Amount)),
Value: (*hexutil.Big)(txData.Amount.BigInt()),
V: (*hexutil.Big)(new(big.Int).SetBytes(txData.V)),
R: (*hexutil.Big)(new(big.Int).SetBytes(txData.R)),
S: (*hexutil.Big)(new(big.Int).SetBytes(txData.S)),
@@ -293,5 +294,10 @@ func NewTransactionFromData(
rpcTx.TransactionIndex = (*hexutil.Uint64)(&index)
}
if txData.Type() == ethtypes.AccessListTxType {
rpcTx.Accesses = txData.Accesses.ToEthAccessList()
rpcTx.ChainID = (*hexutil.Big)(txData.ChainID.BigInt())
}
return rpcTx, nil
}