Skip to content

Commit 3fed538

Browse files
committed
Fix up
1 parent 774fc55 commit 3fed538

File tree

20 files changed

+677
-531
lines changed

20 files changed

+677
-531
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// File: internal/interface.go
2-
package internal
1+
// File: api/blockchain_client.go
2+
package api
33

44
import (
55
"context"

sentinel/api/types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// File: api/types.go
2+
package api
3+
4+
import "github.com/ethereum/go-ethereum/common"
5+
6+
// FilterQuery represents the parameters to filter logs/events.
7+
type FilterQuery struct {
8+
FromBlock uint64
9+
ToBlock uint64
10+
Topics [][]common.Hash
11+
Addresses []common.Address
12+
}
13+
14+
// Log represents a single log event fetched from the blockchain.
15+
type Log struct {
16+
Address common.Address
17+
Topics []common.Hash
18+
Data []byte
19+
BlockNumber uint64
20+
TxHash common.Hash
21+
Index uint
22+
}

sentinel/blockchain_client_wrapper/seth_wrapper.go

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package sentinel

sentinel/chain_poller/chain_poller.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,56 @@ import (
66
"errors"
77

88
"github.com/rs/zerolog"
9-
"github.com/smartcontractkit/chainlink-testing-framework/sentinel/internal"
9+
"github.com/smartcontractkit/chainlink-testing-framework/sentinel/api"
1010
)
1111

1212
// ChainPollerConfig holds the configuration for the ChainPoller.
1313
type ChainPollerConfig struct {
14-
BlockchainClient internal.BlockchainClient
15-
Logger zerolog.Logger
14+
BlockchainClient api.BlockchainClient
15+
Logger *zerolog.Logger
1616
ChainID int64
1717
}
1818

1919
// ChainPoller is responsible for polling logs from the blockchain.
2020
type ChainPoller struct {
21-
Config ChainPollerConfig
21+
blockchainClient api.BlockchainClient
22+
logger zerolog.Logger
23+
chainID int64
2224
}
2325

2426
// NewChainPoller initializes a new ChainPoller.
2527
func NewChainPoller(cfg ChainPollerConfig) (*ChainPoller, error) {
2628
if cfg.BlockchainClient == nil {
2729
return nil, errors.New("blockchain client cannot be nil")
2830
}
29-
if cfg.Logger.GetLevel() == zerolog.NoLevel {
30-
return nil, errors.New("logger cannot be nil")
31+
if cfg.Logger == nil {
32+
return nil, errors.New("no logger passed")
33+
}
34+
if cfg.ChainID < 1 {
35+
return nil, errors.New("chain ID not set")
3136
}
3237

33-
cfg.Logger = cfg.Logger.With().Str("component", "ChainPoller").Logger().With().Int64("ChainID", cfg.ChainID).Logger()
38+
logger := cfg.Logger.With().Str("component", "ChainPoller").Logger().With().Int64("ChainID", cfg.ChainID).Logger()
3439

3540
return &ChainPoller{
36-
Config: cfg,
41+
blockchainClient: cfg.BlockchainClient,
42+
logger: logger,
43+
chainID: cfg.ChainID,
3744
}, nil
3845
}
3946

4047
// Poll fetches logs from the blockchain based on the provided filter queries.
41-
func (cp *ChainPoller) Poll(ctx context.Context, filterQueries []internal.FilterQuery) ([]internal.Log, error) {
42-
var allLogs []internal.Log
48+
func (cp *ChainPoller) FilterLogs(ctx context.Context, filterQueries []api.FilterQuery) ([]api.Log, error) {
49+
var allLogs []api.Log
4350

4451
for _, query := range filterQueries {
45-
logs, err := cp.Config.BlockchainClient.FilterLogs(ctx, query)
52+
logs, err := cp.blockchainClient.FilterLogs(ctx, query)
4653
if err != nil {
47-
cp.Config.Logger.Error().Err(err).Interface("query", query).Msg("Failed to filter logs")
54+
cp.logger.Error().Err(err).Interface("query", query).Msg("Failed to filter logs")
4855
continue
4956
}
5057
allLogs = append(allLogs, logs...)
5158
}
5259

5360
return allLogs, nil
5461
}
55-
56-
var _ ChainPollerInterface = (*ChainPoller)(nil)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// File: chain_poller/interface.go
1+
// File: chain_poller/chain_poller_interface.go
22
package chain_poller
33

44
import (
55
"context"
66

7-
"github.com/smartcontractkit/chainlink-testing-framework/sentinel/internal"
7+
"github.com/smartcontractkit/chainlink-testing-framework/sentinel/api"
88
)
99

1010
// ChainPollerInterface defines the methods that ChainPoller must implement.
1111
type ChainPollerInterface interface {
12-
Poll(ctx context.Context, filterQueries []internal.FilterQuery) ([]internal.Log, error)
12+
FilterLogs(ctx context.Context, filterQueries []api.FilterQuery) ([]api.Log, error)
1313
}

0 commit comments

Comments
 (0)