arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/eth/client.go
eth/client.goRaw
 1package eth
 2
 3import (
 4	"fmt"
 5
 6	"github.com/ethereum/go-ethereum/accounts"
 7	ethKeystore "github.com/ethereum/go-ethereum/accounts/keystore"
 8	"github.com/ethereum/go-ethereum/ethclient"
 9)
10
11var errTODO = fmt.Errorf("TODO: Not implemented yet")
12
13// ClientInterface is the eth Client interface used by hermez-node modules to
14// interact with Ethereum Blockchain and smart contracts.
15type ClientInterface interface {
16	EthereumInterface
17	RollupInterface
18	AuctionInterface
19}
20
21//
22// Implementation
23//
24
25// Client is used to interact with Ethereum and the Hermez smart contracts.
26type Client struct {
27	EthereumClient
28	AuctionClient
29	RollupClient
30}
31
32// NewClient creates a new Client to interact with Ethereum and the Hermez smart contracts.
33func NewClient(client *ethclient.Client, account *accounts.Account, ks *ethKeystore.KeyStore, config *EthereumConfig) *Client {
34	ethereumClient := NewEthereumClient(client, account, ks, config)
35	auctionClient := &AuctionClient{}
36	rollupCient := &RollupClient{}
37	return &Client{
38		EthereumClient: *ethereumClient,
39		AuctionClient:  *auctionClient,
40		RollupClient:   *rollupCient,
41	}
42}