From cf71f5cd604f4d5c94d9e9b12b121a614d662dc7 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 17 Dec 2016 15:39:55 +0100 Subject: rpc: remove HexNumber, replace all uses with hexutil types This change couldn't be automated because HexNumber was used for numbers of all sizes. --- eth/bind.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'eth/bind.go') diff --git a/eth/bind.go b/eth/bind.go index 747965d37..6f7aee4f7 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/rlp" @@ -86,13 +87,13 @@ func toCallArgs(msg ethereum.CallMsg) ethapi.CallArgs { Data: common.ToHex(msg.Data), } if msg.Gas != nil { - args.Gas = *rpc.NewHexNumber(msg.Gas) + args.Gas = hexutil.Big(*msg.Gas) } if msg.GasPrice != nil { - args.GasPrice = *rpc.NewHexNumber(msg.GasPrice) + args.GasPrice = hexutil.Big(*msg.GasPrice) } if msg.Value != nil { - args.Value = *rpc.NewHexNumber(msg.Value) + args.Value = hexutil.Big(*msg.Value) } return args } @@ -106,9 +107,12 @@ func toBlockNumber(num *big.Int) rpc.BlockNumber { // PendingAccountNonce implements bind.ContractTransactor retrieving the current // pending nonce associated with an account. -func (b *ContractBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) { +func (b *ContractBackend) PendingNonceAt(ctx context.Context, account common.Address) (nonce uint64, err error) { out, err := b.txapi.GetTransactionCount(ctx, account, rpc.PendingBlockNumber) - return out.Uint64(), err + if out != nil { + nonce = uint64(*out) + } + return nonce, err } // SuggestGasPrice implements bind.ContractTransactor retrieving the currently @@ -124,7 +128,7 @@ func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) // should provide a basis for setting a reasonable default. func (b *ContractBackend) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (*big.Int, error) { out, err := b.bcapi.EstimateGas(ctx, toCallArgs(msg)) - return out.BigInt(), err + return out.ToInt(), err } // SendTransaction implements bind.ContractTransactor injects the transaction -- cgit v1.2.3 From 12c964b2b7c70949ae5a8c54cf73be7bbd8c97b4 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 20 Dec 2016 14:31:10 +0100 Subject: internal/ethapi: fix hex handling for eth_call input and eth_sendRawTransaction --- eth/bind.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'eth/bind.go') diff --git a/eth/bind.go b/eth/bind.go index 6f7aee4f7..a9864b367 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -84,7 +84,7 @@ func toCallArgs(msg ethereum.CallMsg) ethapi.CallArgs { args := ethapi.CallArgs{ To: msg.To, From: msg.From, - Data: common.ToHex(msg.Data), + Data: msg.Data, } if msg.Gas != nil { args.Gas = hexutil.Big(*msg.Gas) @@ -135,6 +135,6 @@ func (b *ContractBackend) EstimateGas(ctx context.Context, msg ethereum.CallMsg) // into the pending pool for execution. func (b *ContractBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error { raw, _ := rlp.EncodeToBytes(tx) - _, err := b.txapi.SendRawTransaction(ctx, common.ToHex(raw)) + _, err := b.txapi.SendRawTransaction(ctx, raw) return err } -- cgit v1.2.3