diff --git a/pkg/solana/chain.go b/pkg/solana/chain.go index c47e1cf1b..39efabe1c 100644 --- a/pkg/solana/chain.go +++ b/pkg/solana/chain.go @@ -18,8 +18,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/chains" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/services" + "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/core" "github.com/smartcontractkit/chainlink-common/pkg/utils" @@ -49,6 +49,7 @@ const DefaultRequestTimeout = 30 * time.Second type ChainOpts struct { Logger logger.Logger KeyStore core.Keystore + DS sqlutil.DataSource } func (o *ChainOpts) Validate() (err error) { @@ -61,6 +62,9 @@ func (o *ChainOpts) Validate() (err error) { if o.KeyStore == nil { err = errors.Join(err, required("KeyStore")) } + if o.DS == nil { + err = errors.Join(err, required("DataSource")) + } return } @@ -72,7 +76,7 @@ func NewChain(cfg *config.TOMLConfig, opts ChainOpts) (Chain, error) { if !cfg.IsEnabled() { return nil, fmt.Errorf("cannot create new chain with ID %s: chain is disabled", *cfg.ChainID) } - c, err := newChain(*cfg.ChainID, cfg, opts.KeyStore, opts.Logger) + c, err := newChain(*cfg.ChainID, cfg, opts.KeyStore, opts.Logger, opts.DS) if err != nil { return nil, err } @@ -222,7 +226,7 @@ func (v *verifiedCachedClient) GetAccountInfoWithOpts(ctx context.Context, addr return v.ReaderWriter.GetAccountInfoWithOpts(ctx, addr, opts) } -func newChain(id string, cfg *config.TOMLConfig, ks loop.Keystore, lggr logger.Logger) (*chain, error) { +func newChain(id string, cfg *config.TOMLConfig, ks core.Keystore, lggr logger.Logger, ds sqlutil.DataSource) (*chain, error) { lggr = logger.With(lggr, "chainID", id, "chain", "solana") var ch = chain{ id: id, diff --git a/pkg/solana/chain_test.go b/pkg/solana/chain_test.go index b705860c9..b1008143a 100644 --- a/pkg/solana/chain_test.go +++ b/pkg/solana/chain_test.go @@ -17,14 +17,16 @@ import ( "github.com/gagliardetto/solana-go/programs/system" "github.com/gagliardetto/solana-go/rpc" "github.com/google/uuid" - "github.com/smartcontractkit/chainlink-common/pkg/config" - "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + "github.com/smartcontractkit/chainlink-common/pkg/config" + "github.com/smartcontractkit/chainlink-common/pkg/logger" + sqlutilmocks "github.com/smartcontractkit/chainlink-common/pkg/sqlutil/mocks" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" + "github.com/smartcontractkit/chainlink-solana/pkg/solana/client" mn "github.com/smartcontractkit/chainlink-solana/pkg/solana/client/multinode" solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" @@ -282,7 +284,7 @@ func TestChain_Transact(t *testing.T) { return sig[:] }, nil) - c, err := newChain("localnet", cfg, mkey, lgr) + c, err := newChain("localnet", cfg, mkey, lgr, sqlutilmocks.NewDataSource(t)) require.NoError(t, err) require.NoError(t, c.txm.Start(ctx)) @@ -356,7 +358,7 @@ func TestSolanaChain_MultiNode_GetClient(t *testing.T) { }, } - testChain, err := newChain("devnet", cfg, nil, logger.Test(t)) + testChain, err := newChain("devnet", cfg, nil, logger.Test(t), sqlutilmocks.NewDataSource(t)) require.NoError(t, err) err = testChain.Start(tests.Context(t)) @@ -398,7 +400,7 @@ func TestChain_MultiNode_TransactionSender(t *testing.T) { // mocked keystore mkey := mocks.NewSimpleKeystore(t) - c, err := newChain("localnet", cfg, mkey, lgr) + c, err := newChain("localnet", cfg, mkey, lgr, sqlutilmocks.NewDataSource(t)) require.NoError(t, err) require.NoError(t, c.Start(ctx)) defer func() { @@ -516,7 +518,7 @@ func TestSolanaChain_MultiNode_Txm(t *testing.T) { }, nil) mkey.On("Sign", mock.Anything, pubKeyReceiver.String(), mock.Anything).Return([]byte{}, config.KeyNotFoundError{ID: pubKeyReceiver.String(), KeyType: "Solana"}) - testChain, err := newChain("localnet", cfg, mkey, logger.Test(t)) + testChain, err := newChain("localnet", cfg, mkey, logger.Test(t), sqlutilmocks.NewDataSource(t)) require.NoError(t, err) err = testChain.Start(tests.Context(t))