aboutsummaryrefslogtreecommitdiffstats
path: root/ethclient
diff options
context:
space:
mode:
authorJhih-Ming Huang <jm@dexon.org>2019-04-10 22:29:35 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-10 22:29:35 +0800
commit675a9441784b14ee4bd996832c4431adc291c5af (patch)
tree58d76052f28fd5808605f592a52f297f862f9ef7 /ethclient
parentb102e88097d7555b776e95565355ab3dacced1f9 (diff)
downloaddexon-675a9441784b14ee4bd996832c4431adc291c5af.tar
dexon-675a9441784b14ee4bd996832c4431adc291c5af.tar.gz
dexon-675a9441784b14ee4bd996832c4431adc291c5af.tar.bz2
dexon-675a9441784b14ee4bd996832c4431adc291c5af.tar.lz
dexon-675a9441784b14ee4bd996832c4431adc291c5af.tar.xz
dexon-675a9441784b14ee4bd996832c4431adc291c5af.tar.zst
dexon-675a9441784b14ee4bd996832c4431adc291c5af.zip
fixup! Change import go github.com/dexon-foundation/dexon
Diffstat (limited to 'ethclient')
-rw-r--r--ethclient/ethclient.go32
-rw-r--r--ethclient/ethclient_test.go36
2 files changed, 34 insertions, 34 deletions
diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go
index c8a8e5eb5..ec2680188 100644
--- a/ethclient/ethclient.go
+++ b/ethclient/ethclient.go
@@ -90,7 +90,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
if err != nil {
return nil, err
} else if len(raw) == 0 {
- return nil, ethereum.NotFound
+ return nil, dexon.NotFound
}
// Decode header and transactions.
var head *types.Header
@@ -154,7 +154,7 @@ func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.He
var head *types.Header
err := ec.c.CallContext(ctx, &head, "eth_getBlockByHash", hash, false)
if err == nil && head == nil {
- err = ethereum.NotFound
+ err = dexon.NotFound
}
return head, err
}
@@ -165,7 +165,7 @@ func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.H
var head *types.Header
err := ec.c.CallContext(ctx, &head, "eth_getBlockByNumber", toBlockNumArg(number), false)
if err == nil && head == nil {
- err = ethereum.NotFound
+ err = dexon.NotFound
}
return head, err
}
@@ -195,7 +195,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
if err != nil {
return nil, false, err
} else if json == nil {
- return nil, false, ethereum.NotFound
+ return nil, false, dexon.NotFound
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
return nil, false, fmt.Errorf("server returned transaction without signature")
}
@@ -243,7 +243,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
err := ec.c.CallContext(ctx, &json, "eth_getTransactionByBlockHashAndIndex", blockHash, hexutil.Uint64(index))
if err == nil {
if json == nil {
- return nil, ethereum.NotFound
+ return nil, dexon.NotFound
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
return nil, fmt.Errorf("server returned transaction without signature")
}
@@ -261,7 +261,7 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*
err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash)
if err == nil {
if r == nil {
- return nil, ethereum.NotFound
+ return nil, dexon.NotFound
}
}
return r, err
@@ -284,7 +284,7 @@ type rpcProgress struct {
// SyncProgress retrieves the current progress of the sync algorithm. If there's
// no sync currently running, it returns nil.
-func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error) {
+func (ec *Client) SyncProgress(ctx context.Context) (*dexon.SyncProgress, error) {
var raw json.RawMessage
if err := ec.c.CallContext(ctx, &raw, "eth_syncing"); err != nil {
return nil, err
@@ -298,7 +298,7 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
if err := json.Unmarshal(raw, &progress); err != nil {
return nil, err
}
- return &ethereum.SyncProgress{
+ return &dexon.SyncProgress{
StartingBlock: uint64(progress.StartingBlock),
CurrentBlock: uint64(progress.CurrentBlock),
HighestBlock: uint64(progress.HighestBlock),
@@ -309,7 +309,7 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
// SubscribeNewHead subscribes to notifications about the current blockchain head
// on the given channel.
-func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
+func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (dexon.Subscription, error) {
return ec.c.EthSubscribe(ctx, ch, "newHeads")
}
@@ -363,7 +363,7 @@ func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumb
// Filters
// FilterLogs executes a filter query.
-func (ec *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
+func (ec *Client) FilterLogs(ctx context.Context, q dexon.FilterQuery) ([]types.Log, error) {
var result []types.Log
arg, err := toFilterArg(q)
if err != nil {
@@ -374,7 +374,7 @@ func (ec *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]typ
}
// SubscribeFilterLogs subscribes to the results of a streaming filter query.
-func (ec *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) {
+func (ec *Client) SubscribeFilterLogs(ctx context.Context, q dexon.FilterQuery, ch chan<- types.Log) (dexon.Subscription, error) {
arg, err := toFilterArg(q)
if err != nil {
return nil, err
@@ -382,7 +382,7 @@ func (ec *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuer
return ec.c.EthSubscribe(ctx, ch, "logs", arg)
}
-func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
+func toFilterArg(q dexon.FilterQuery) (interface{}, error) {
arg := map[string]interface{}{
"address": q.Addresses,
"topics": q.Topics,
@@ -451,7 +451,7 @@ func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error) {
// blockNumber selects the block height at which the call runs. It can be nil, in which
// case the code is taken from the latest known block. Note that state from very old
// blocks might not be available.
-func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
+func (ec *Client) CallContract(ctx context.Context, msg dexon.CallMsg, blockNumber *big.Int) ([]byte, error) {
var hex hexutil.Bytes
err := ec.c.CallContext(ctx, &hex, "eth_call", toCallArg(msg), toBlockNumArg(blockNumber))
if err != nil {
@@ -462,7 +462,7 @@ func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockN
// PendingCallContract executes a message call transaction using the EVM.
// The state seen by the contract call is the pending state.
-func (ec *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) {
+func (ec *Client) PendingCallContract(ctx context.Context, msg dexon.CallMsg) ([]byte, error) {
var hex hexutil.Bytes
err := ec.c.CallContext(ctx, &hex, "eth_call", toCallArg(msg), "pending")
if err != nil {
@@ -485,7 +485,7 @@ func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
// the current pending state of the backend blockchain. There is no guarantee that this is
// the true gas limit requirement as other transactions may be added or removed by miners,
// but it should provide a basis for setting a reasonable default.
-func (ec *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error) {
+func (ec *Client) EstimateGas(ctx context.Context, msg dexon.CallMsg) (uint64, error) {
var hex hexutil.Uint64
err := ec.c.CallContext(ctx, &hex, "eth_estimateGas", toCallArg(msg))
if err != nil {
@@ -522,7 +522,7 @@ func (ec *Client) SendTransactions(ctx context.Context, txs []*types.Transaction
return ec.c.CallContext(ctx, nil, "eth_sendRawTransactions", txData)
}
-func toCallArg(msg ethereum.CallMsg) interface{} {
+func toCallArg(msg dexon.CallMsg) interface{} {
arg := map[string]interface{}{
"from": msg.From,
"to": msg.To,
diff --git a/ethclient/ethclient_test.go b/ethclient/ethclient_test.go
index 46acf0dc0..b57d2505c 100644
--- a/ethclient/ethclient_test.go
+++ b/ethclient/ethclient_test.go
@@ -28,17 +28,17 @@ import (
// Verify that Client implements the ethereum interfaces.
var (
- _ = ethereum.ChainReader(&Client{})
- _ = ethereum.TransactionReader(&Client{})
- _ = ethereum.ChainStateReader(&Client{})
- _ = ethereum.ChainSyncReader(&Client{})
- _ = ethereum.ContractCaller(&Client{})
- _ = ethereum.GasEstimator(&Client{})
- _ = ethereum.GasPricer(&Client{})
- _ = ethereum.LogFilterer(&Client{})
- _ = ethereum.PendingStateReader(&Client{})
- // _ = ethereum.PendingStateEventer(&Client{})
- _ = ethereum.PendingContractCaller(&Client{})
+ _ = dexon.ChainReader(&Client{})
+ _ = dexon.TransactionReader(&Client{})
+ _ = dexon.ChainStateReader(&Client{})
+ _ = dexon.ChainSyncReader(&Client{})
+ _ = dexon.ContractCaller(&Client{})
+ _ = dexon.GasEstimator(&Client{})
+ _ = dexon.GasPricer(&Client{})
+ _ = dexon.LogFilterer(&Client{})
+ _ = dexon.PendingStateReader(&Client{})
+ // _ = dexon.PendingStateEventer(&Client{})
+ _ = dexon.PendingContractCaller(&Client{})
)
func TestToFilterArg(t *testing.T) {
@@ -52,13 +52,13 @@ func TestToFilterArg(t *testing.T) {
for _, testCase := range []struct {
name string
- input ethereum.FilterQuery
+ input dexon.FilterQuery
output interface{}
err error
}{
{
"without BlockHash",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
FromBlock: big.NewInt(1),
ToBlock: big.NewInt(2),
@@ -74,7 +74,7 @@ func TestToFilterArg(t *testing.T) {
},
{
"with nil fromBlock and nil toBlock",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
Topics: [][]common.Hash{},
},
@@ -88,7 +88,7 @@ func TestToFilterArg(t *testing.T) {
},
{
"with blockhash",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
BlockHash: &blockHash,
Topics: [][]common.Hash{},
@@ -102,7 +102,7 @@ func TestToFilterArg(t *testing.T) {
},
{
"with blockhash and from block",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
BlockHash: &blockHash,
FromBlock: big.NewInt(1),
@@ -113,7 +113,7 @@ func TestToFilterArg(t *testing.T) {
},
{
"with blockhash and to block",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
BlockHash: &blockHash,
ToBlock: big.NewInt(1),
@@ -124,7 +124,7 @@ func TestToFilterArg(t *testing.T) {
},
{
"with blockhash and both from / to block",
- ethereum.FilterQuery{
+ dexon.FilterQuery{
Addresses: addresses,
BlockHash: &blockHash,
FromBlock: big.NewInt(1),