@@ -31,9 +31,13 @@ type DataCommittee struct {
3131
3232// Etherman defines functions that should be implemented by Etherman
3333type Etherman interface {
34+ GetTx (ctx context.Context , txHash common.Hash ) (* types.Transaction , bool , error )
35+ HeaderByNumber (ctx context.Context , number * big.Int ) (* types.Header , error )
36+ BlockByNumber (ctx context.Context , number * big.Int ) (* types.Block , error )
37+ CodeAt (ctx context.Context , account common.Address , blockNumber * big.Int ) ([]byte , error )
38+
3439 GetCurrentDataCommittee () (* DataCommittee , error )
3540 GetCurrentDataCommitteeMembers () ([]DataCommitteeMember , error )
36- GetTx (ctx context.Context , txHash common.Hash ) (* types.Transaction , bool , error )
3741 TrustedSequencer (ctx context.Context ) (common.Address , error )
3842 WatchSetTrustedSequencer (
3943 ctx context.Context ,
@@ -44,7 +48,6 @@ type Etherman interface {
4448 ctx context.Context ,
4549 events chan * polygonvalidium.PolygonvalidiumSetTrustedSequencerURL ,
4650 ) (event.Subscription , error )
47- HeaderByNumber (ctx context.Context , number * big.Int ) (* types.Header , error )
4851 FilterSequenceBatches (
4952 opts * bind.FilterOpts ,
5053 numBatch []uint64 ,
@@ -63,9 +66,9 @@ func New(ctx context.Context, cfg config.L1Config) (Etherman, error) {
6366 ctx , cancel := context .WithTimeout (ctx , cfg .Timeout .Duration )
6467 defer cancel ()
6568
66- ethClient , err := ethclient .DialContext (ctx , cfg .WsURL )
69+ ethClient , err := ethclient .DialContext (ctx , cfg .RpcURL )
6770 if err != nil {
68- log .Errorf ("error connecting to %s: %+v" , cfg .WsURL , err )
71+ log .Errorf ("error connecting to %s: %+v" , cfg .RpcURL , err )
6972 return nil , err
7073 }
7174
@@ -97,6 +100,21 @@ func (e *etherman) GetTx(ctx context.Context, txHash common.Hash) (*types.Transa
97100 return e .EthClient .TransactionByHash (ctx , txHash )
98101}
99102
103+ // HeaderByNumber returns header by number from the eth client
104+ func (e * etherman ) HeaderByNumber (ctx context.Context , number * big.Int ) (* types.Header , error ) {
105+ return e .EthClient .HeaderByNumber (ctx , number )
106+ }
107+
108+ // BlockByNumber returns a block by the given number
109+ func (e * etherman ) BlockByNumber (ctx context.Context , number * big.Int ) (* types.Block , error ) {
110+ return e .EthClient .BlockByNumber (ctx , number )
111+ }
112+
113+ // CodeAt returns the contract code of the given account.
114+ func (e * etherman ) CodeAt (ctx context.Context , account common.Address , blockNumber * big.Int ) ([]byte , error ) {
115+ return e .EthClient .CodeAt (ctx , account , blockNumber )
116+ }
117+
100118// TrustedSequencer gets trusted sequencer address
101119func (e * etherman ) TrustedSequencer (ctx context.Context ) (common.Address , error ) {
102120 return e .CDKValidium .TrustedSequencer (& bind.CallOpts {
@@ -129,11 +147,6 @@ func (e *etherman) WatchSetTrustedSequencerURL(
129147 return e .CDKValidium .WatchSetTrustedSequencerURL (& bind.WatchOpts {Context : ctx }, events )
130148}
131149
132- // HeaderByNumber returns header by number from the eth client
133- func (e * etherman ) HeaderByNumber (ctx context.Context , number * big.Int ) (* types.Header , error ) {
134- return e .EthClient .HeaderByNumber (ctx , number )
135- }
136-
137150// FilterSequenceBatches retrieves filtered batches on CDK validium
138151func (e * etherman ) FilterSequenceBatches (opts * bind.FilterOpts ,
139152 numBatch []uint64 ) (* polygonvalidium.PolygonvalidiumSequenceBatchesIterator , error ) {
0 commit comments