@@ -2,85 +2,54 @@ package client
22
33import (
44 "context"
5- "github.com/ava-labs/avalanchego/ids"
6- "github.com/ava-labs/avalanchego/network/peer"
7- "github.com/ava-labs/avalanchego/utils/json"
85 "math/big"
96 "strings"
107
118 "github.com/ava-labs/avalanchego/api/info"
9+ "github.com/ava-labs/avalanchego/ids"
1210 "github.com/ava-labs/avalanchego/utils/rpc"
13- ethtypes "github.com/ava-labs/coreth/core/types"
11+ "github.com/ava-labs/coreth/core/types"
1412 "github.com/ava-labs/coreth/interfaces"
15- ethcommon "github.com/ethereum/go-ethereum/common"
13+ "github.com/ava-labs/coreth/plugin/evm"
14+ "github.com/ethereum/go-ethereum/common"
15+
16+ "github.com/ava-labs/avalanche-rosetta/constants"
1617)
1718
1819// Interface compliance
1920var _ Client = & client {}
2021
2122type Client interface {
22- IsBootstrapped (context.Context , string , ... rpc.Option ) (bool , error )
23+ // info.Client methods
24+ InfoClient
25+
2326 ChainID (context.Context ) (* big.Int , error )
24- BlockByHash (context.Context , ethcommon .Hash ) (* ethtypes .Block , error )
25- BlockByNumber (context.Context , * big.Int ) (* ethtypes .Block , error )
26- HeaderByHash (context.Context , ethcommon .Hash ) (* ethtypes .Header , error )
27- HeaderByNumber (context.Context , * big.Int ) (* ethtypes .Header , error )
28- TransactionByHash (context.Context , ethcommon .Hash ) (* ethtypes .Transaction , bool , error )
29- TransactionReceipt (context.Context , ethcommon .Hash ) (* ethtypes .Receipt , error )
27+ BlockByHash (context.Context , common .Hash ) (* types .Block , error )
28+ BlockByNumber (context.Context , * big.Int ) (* types .Block , error )
29+ HeaderByHash (context.Context , common .Hash ) (* types .Header , error )
30+ HeaderByNumber (context.Context , * big.Int ) (* types .Header , error )
31+ TransactionByHash (context.Context , common .Hash ) (* types .Transaction , bool , error )
32+ TransactionReceipt (context.Context , common .Hash ) (* types .Receipt , error )
3033 TraceTransaction (context.Context , string ) (* Call , []* FlatCall , error )
3134 TraceBlockByHash (context.Context , string ) ([]* Call , [][]* FlatCall , error )
32- SendTransaction (context.Context , * ethtypes .Transaction ) error
33- BalanceAt (context.Context , ethcommon .Address , * big.Int ) (* big.Int , error )
34- NonceAt (context.Context , ethcommon .Address , * big.Int ) (uint64 , error )
35+ SendTransaction (context.Context , * types .Transaction ) error
36+ BalanceAt (context.Context , common .Address , * big.Int ) (* big.Int , error )
37+ NonceAt (context.Context , common .Address , * big.Int ) (uint64 , error )
3538 SuggestGasPrice (context.Context ) (* big.Int , error )
3639 EstimateGas (context.Context , interfaces.CallMsg ) (uint64 , error )
3740 TxPoolContent (context.Context ) (* TxPoolContent , error )
38- GetNetworkName (context.Context , ... rpc.Option ) (string , error )
39- Peers (context.Context , ... rpc.Option ) ([]info.Peer , error )
40- // Peers_v1_11 enables info.peers RPC call compatible with v1.11.
41- // Once the dependencies are upgraded, this should be replaced with Peers.
42- Peers_v1_11 (context.Context , []ids.NodeID , ... rpc.Option ) ([]Peer_v1_11 , error )
43- GetContractInfo (ethcommon.Address , bool ) (string , uint8 , error )
41+ GetContractInfo (common.Address , bool ) (string , uint8 , error )
4442 CallContract (context.Context , interfaces.CallMsg , * big.Int ) ([]byte , error )
43+ IssueTx (ctx context.Context , txBytes []byte , options ... rpc.Option ) (ids.ID , error )
44+ GetAtomicUTXOs (ctx context.Context , addrs []ids.ShortID , sourceChain string , limit uint32 , startAddress ids.ShortID , startUTXOID ids.ID , options ... rpc.Option ) ([][]byte , ids.ShortID , ids.ID , error )
45+ EstimateBaseFee (ctx context.Context ) (* big.Int , error )
4546}
4647
47- type clientFix struct {
48- requester rpc.EndpointRequester
49- }
50-
51- func newClientFix (uri string ) * clientFix {
52- return & clientFix {
53- requester : rpc .NewEndpointRequester (
54- uri + "/ext/info" ,
55- "info" ,
56- ),
57- }
58- }
59-
60- type Peer_v1_11 struct {
61- peer.Info
62-
63- Benched []string `json:"benched"`
64- }
65-
66- type PeersReply_v1_11 struct {
67- // Number of elements in [Peers]
68- NumPeers json.Uint64 `json:"numPeers"`
69- // Each element is a peer
70- Peers []Peer_v1_11 `json:"peers"`
71- }
72-
73- func (cf * clientFix ) Peers_v1_11 (ctx context.Context , nodeIDs []ids.NodeID , options ... rpc.Option ) ([]Peer_v1_11 , error ) {
74- res := & PeersReply_v1_11 {}
75- err := cf .requester .SendRequest (ctx , "peers" , & info.PeersArgs {
76- NodeIDs : nodeIDs ,
77- }, res , options ... )
78- return res .Peers , err
79- }
48+ type EvmClient evm.Client
8049
8150type client struct {
8251 info.Client
83- * clientFix
52+ EvmClient
8453 * EthClient
8554 * ContractClient
8655}
@@ -94,10 +63,10 @@ func NewClient(ctx context.Context, endpoint string) (Client, error) {
9463 return nil , err
9564 }
9665
97- return client {
66+ return & client {
9867 Client : info .NewClient (endpoint ),
99- clientFix : newClientFix (endpoint ),
68+ EvmClient : evm . NewClient (endpoint , constants . CChain . String () ),
10069 EthClient : eth ,
10170 ContractClient : NewContractClient (eth .Client ),
10271 }, nil
103- }
72+ }
0 commit comments