Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/relayinterface/lookups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/smartcontractkit/chainlink-solana/integration-tests/utils"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/chainwriter"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/txm"
keyMocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/mocks"
Expand Down
14 changes: 7 additions & 7 deletions pkg/solana/cap_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/smartcontractkit/chainlink-protos/cre/go/values"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
)

var (
Expand All @@ -32,17 +32,17 @@ func NewEncoder(config *values.Map) (consensustypes.Encoder, error) {
parsed := &solcommoncodec.ParsedTypes{
EncoderDefs: make(map[string]solcommoncodec.Entry),
}
idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, idl.Accounts[0].Name, idl)
idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, idl.Accounts[0].Name, idl)
if err != nil {
return nil, fmt.Errorf("failed to find definition: %w", err)
}

accountIDLDef, ok := idlDef.(codec.IdlTypeDef)
accountIDLDef, ok := idlDef.(codecv1.IdlTypeDef)
if !ok {
return nil, errors.New("invalid cast")
}

cEntry, err := codec.CreateCodecEntry(accountIDLDef, idl.Accounts[0].Name, idl, nil)
cEntry, err := codecv1.CreateCodecEntry(accountIDLDef, idl.Accounts[0].Name, idl, nil)
if err != nil {
return nil, fmt.Errorf("failed to create codec entry: %w", err)
}
Expand All @@ -57,8 +57,8 @@ func NewEncoder(config *values.Map) (consensustypes.Encoder, error) {
return &capEncoder{codec: c, itemType: itemType}, err
}

func getIDLFromConfig(config *values.Map) (codec.IDL, error) {
var idl codec.IDL
func getIDLFromConfig(config *values.Map) (codecv1.IDL, error) {
var idl codecv1.IDL
inputSchema, ok := config.Underlying[reportSchemaKey]
if !ok {
return idl, errors.New("missing field report_schema")
Expand Down
16 changes: 8 additions & 8 deletions pkg/solana/ccip/chainaccessor/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (

"github.com/smartcontractkit/chainlink-ccip/pkg/reader"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller"
logpollertypes "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/types"
Expand Down Expand Up @@ -221,14 +221,14 @@ func (a *SolanaAccessor) tryBindCPIFilters(ctx context.Context, contractName str
return nil
}

func extractEventIDL(eventName string, codecIDL codec.IDL) (codec.IdlEvent, error) {
idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, eventName, codecIDL)
func extractEventIDL(eventName string, codecIDL codecv1.IDL) (codecv1.IdlEvent, error) {
idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, eventName, codecIDL)
if err != nil {
return codec.IdlEvent{}, err
return codecv1.IdlEvent{}, err
}
eventIdl, isOk := idlDef.(codec.IdlEvent)
eventIdl, isOk := idlDef.(codecv1.IdlEvent)
if !isOk {
return codec.IdlEvent{}, fmt.Errorf("unexpected type from IDL definition for event read: %q", eventName)
return codecv1.IdlEvent{}, fmt.Errorf("unexpected type from IDL definition for event read: %q", eventName)
}
return eventIdl, nil
}
Expand All @@ -247,7 +247,7 @@ func (a *SolanaAccessor) registerFilterIfNotExists(

eventName := filterConfig.chainSpecificName

var codecIDL codec.IDL
var codecIDL codecv1.IDL
if err := json.Unmarshal([]byte(filterConfig.idl), &codecIDL); err != nil {
return fmt.Errorf("unexpected error: invalid CCIP OffRamp IDL, error: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/solana/ccip/config/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
idl "github.com/smartcontractkit/chainlink-ccip/chains/solana"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/chainwriter"
solanacodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
)

var (
Expand Down Expand Up @@ -152,12 +152,12 @@ func GetSolanaChainWriterConfig(offrampProgramAddress string, fromAddress string
}

// validate CCIP Offramp IDL, errors not expected
var offrampIDL solanacodec.IDL
var offrampIDL codecv1.IDL
if err = json.Unmarshal([]byte(ccipOfframpIDL), &offrampIDL); err != nil {
return chainwriter.ChainWriterConfig{}, fmt.Errorf("unexpected error: invalid CCIP Offramp IDL, error: %w", err)
}
// validate CCIP Router IDL, errors not expected
var routerIDL solanacodec.IDL
var routerIDL codecv1.IDL
if err = json.Unmarshal([]byte(ccipRouterIDL), &routerIDL); err != nil {
return chainwriter.ChainWriterConfig{}, fmt.Errorf("unexpected error: invalid CCIP Router IDL, error: %w", err)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/solana/chainreader/account_read_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/query"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)

Expand All @@ -25,18 +25,18 @@ type accountReadBinding struct {
prefix []byte // only used for PDA public key calculation
responseAddressHardCoder *commoncodec.HardCodeModifierConfig
readDefinition config.ReadDefinition
idl codec.IDL
idl codecv1.IDL
inputIDLType interface{}
outputIDLTypeDef codec.IdlTypeDef
outputIDLTypeDef codecv1.IdlTypeDef
}

func newAccountReadBinding(
namespace, genericName string,
isPda bool,
pdaPrefix []byte,
idl codec.IDL,
idl codecv1.IDL,
inputIDLType interface{},
outputIDLTypeDef codec.IdlTypeDef,
outputIDLTypeDef codecv1.IdlTypeDef,
readDefinition config.ReadDefinition,
) *accountReadBinding {
rb := &accountReadBinding{
Expand Down Expand Up @@ -110,7 +110,7 @@ func (b *accountReadBinding) GetReadDefinition() config.ReadDefinition {
return b.readDefinition
}

func (b *accountReadBinding) GetIDLInfo() (idl codec.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codec.IdlTypeDef) {
func (b *accountReadBinding) GetIDLInfo() (idl codecv1.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codecv1.IdlTypeDef) {
return b.idl, b.inputIDLType, b.outputIDLTypeDef
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/solana/chainreader/bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/query"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
logpollertypes "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/types"
)
Expand All @@ -29,7 +29,7 @@ type readBinding interface {
GetAddress(context.Context, any) (solana.PublicKey, error)
GetGenericName() string
GetReadDefinition() config.ReadDefinition
GetIDLInfo() (idl codec.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codec.IdlTypeDef)
GetIDLInfo() (idl codecv1.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codecv1.IdlTypeDef)
GetAddressResponseHardCoder() *commoncodec.HardCodeModifierConfig
SetCodec(types.RemoteCodec)
SetModifier(commoncodec.Modifier)
Expand Down
6 changes: 3 additions & 3 deletions pkg/solana/chainreader/bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/query"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
)

Expand Down Expand Up @@ -76,8 +76,8 @@ func (_m *mockBinding) GetReadDefinition() config.ReadDefinition {
return config.ReadDefinition{}
}

func (_m *mockBinding) GetIDLInfo() (idl codec.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codec.IdlTypeDef) {
return codec.IDL{}, codec.IdlTypeDef{}, codec.IdlTypeDef{}
func (_m *mockBinding) GetIDLInfo() (idl codecv1.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codecv1.IdlTypeDef) {
return codecv1.IDL{}, codecv1.IdlTypeDef{}, codecv1.IdlTypeDef{}
}

func (_m *mockBinding) GetAddressResponseHardCoder() *commoncodec.HardCodeModifierConfig {
Expand Down
36 changes: 18 additions & 18 deletions pkg/solana/chainreader/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives"
"github.com/smartcontractkit/chainlink-protos/cre/go/values"

"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec"
solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common"
codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
logpollertypes "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/types"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/utils"
Expand Down Expand Up @@ -403,13 +403,13 @@ func (s *ContractReaderService) CreateContractType(readIdentifier string, forEnc
return s.bdRegistry.CreateType(values.contract, values.reads[0].readName, forEncoding)
}

func (s *ContractReaderService) addCodecDef(parsed *solcommoncodec.ParsedTypes, forEncoding bool, namespace, genericName string, idl codec.IDL, idlDefinition interface{}, modCfg commoncodec.ModifiersConfig) error {
func (s *ContractReaderService) addCodecDef(parsed *solcommoncodec.ParsedTypes, forEncoding bool, namespace, genericName string, idl codecv1.IDL, idlDefinition interface{}, modCfg commoncodec.ModifiersConfig) error {
mod, err := modCfg.ToModifier(solcommoncodec.DecoderHooks...)
if err != nil {
return err
}

cEntry, err := codec.CreateCodecEntry(idlDefinition, genericName, idl, mod)
cEntry, err := codecv1.CreateCodecEntry(idlDefinition, genericName, idl, mod)
if err != nil {
return err
}
Expand All @@ -429,12 +429,12 @@ func (s *ContractReaderService) initNamespace(namespaces map[string]config.Chain

switch read.ReadType {
case config.Account:
idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, read.ChainSpecificName, nameSpaceDef.IDL)
idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, read.ChainSpecificName, nameSpaceDef.IDL)
if err != nil {
return err
}

accountIDLDef, isOk := idlDef.(codec.IdlTypeDef)
accountIDLDef, isOk := idlDef.(codecv1.IdlTypeDef)
if !isOk {
return fmt.Errorf("unexpected type %T from IDL definition for account read: %q, with chainSpecificName: %q, of type: %q", accountIDLDef, genericName, read.ChainSpecificName, read.ReadType)
}
Expand All @@ -460,7 +460,7 @@ func (s *ContractReaderService) initNamespace(namespaces map[string]config.Chain
return nil
}

func (s *ContractReaderService) addAccountRead(namespace string, genericName string, idl codec.IDL, outputIDLDef codec.IdlTypeDef, readDefinition config.ReadDefinition) error {
func (s *ContractReaderService) addAccountRead(namespace string, genericName string, idl codecv1.IDL, outputIDLDef codecv1.IdlTypeDef, readDefinition config.ReadDefinition) error {
reads := []read{{readName: genericName, useParams: true, errOnMissingAccountData: readDefinition.ErrOnMissingAccountData}}
if readDefinition.MultiReader != nil {
multiRead, err := s.addMultiAccountReadToCodec(namespace, readDefinition, idl)
Expand All @@ -470,7 +470,7 @@ func (s *ContractReaderService) addAccountRead(namespace string, genericName str
reads = append(reads, multiRead...)
}

var inputIDLDef interface{} = codec.NilIdlTypeDefTy
var inputIDLDef interface{} = codecv1.NilIdlTypeDefTy
isPDA := false

// Create PDA read binding if PDA prefix or seeds configs are populated
Expand All @@ -489,18 +489,18 @@ func (s *ContractReaderService) addAccountRead(namespace string, genericName str
return nil
}

func (s *ContractReaderService) addReadToCodec(parsed *solcommoncodec.ParsedTypes, namespace string, genericName string, idl codec.IDL, inputIDLDef interface{}, outputIDLDef interface{}, readDefinition config.ReadDefinition) error {
func (s *ContractReaderService) addReadToCodec(parsed *solcommoncodec.ParsedTypes, namespace string, genericName string, idl codecv1.IDL, inputIDLDef interface{}, outputIDLDef interface{}, readDefinition config.ReadDefinition) error {
if err := s.addCodecDef(parsed, true, namespace, genericName, idl, inputIDLDef, readDefinition.InputModifications); err != nil {
return err
}

return s.addCodecDef(parsed, false, namespace, genericName, idl, outputIDLDef, readDefinition.OutputModifications)
}

func (s *ContractReaderService) addMultiAccountReadToCodec(namespace string, readDefinition config.ReadDefinition, idl codec.IDL) ([]read, error) {
func (s *ContractReaderService) addMultiAccountReadToCodec(namespace string, readDefinition config.ReadDefinition, idl codecv1.IDL) ([]read, error) {
var reads []read
for _, mr := range readDefinition.MultiReader.Reads {
idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, mr.ChainSpecificName, idl)
idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, mr.ChainSpecificName, idl)
if err != nil {
return nil, err
}
Expand All @@ -509,12 +509,12 @@ func (s *ContractReaderService) addMultiAccountReadToCodec(namespace string, rea
return nil, fmt.Errorf("unexpected read type %q for dynamic hard coder read: %q in namespace: %q", mr.ReadType, mr.ChainSpecificName, namespace)
}

accountIDLDef, isOk := idlDef.(codec.IdlTypeDef)
accountIDLDef, isOk := idlDef.(codecv1.IdlTypeDef)
if !isOk {
return nil, fmt.Errorf("unexpected type %T from IDL definition for account read with chainSpecificName: %q, of type: %q", accountIDLDef, mr.ChainSpecificName, mr.ReadType)
}

var inputIDLDef interface{} = codec.NilIdlTypeDefTy
var inputIDLDef interface{} = codecv1.NilIdlTypeDefTy
isPDA := false

// Create PDA read binding if PDA prefix or seeds configs are populated
Expand Down Expand Up @@ -589,7 +589,7 @@ func (s *ContractReaderService) addAddressResponseHardCoderModifier(namespace st
func (s *ContractReaderService) addEventRead(
common *config.PollingFilter,
namespace, genericName string,
idl codec.IDL,
idl codecv1.IDL,
readDefinition config.ReadDefinition,
events EventsReader,
) error {
Expand All @@ -599,7 +599,7 @@ func (s *ContractReaderService) addEventRead(

conf := readDefinition.EventDefinitions

idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, readDefinition.ChainSpecificName, idl)
idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, readDefinition.ChainSpecificName, idl)
if err != nil {
return err
}
Expand All @@ -609,7 +609,7 @@ func (s *ContractReaderService) addEventRead(
return fmt.Errorf("failed to set polling filter overrides: %w", err)
}

eventIdl, isOk := idlDef.(codec.IdlEvent)
eventIdl, isOk := idlDef.(codecv1.IdlEvent)
if !isOk {
return fmt.Errorf(
"unexpected type from IDL definition for event read: %q, with chainSpecificName: %q, of type: %q",
Expand All @@ -624,7 +624,7 @@ func (s *ContractReaderService) addEventRead(
applyIndexedFieldTuple(subkeys, conf.IndexedField2, 2)
applyIndexedFieldTuple(subkeys, conf.IndexedField3, 3)

eventDef := codec.EventIDLTypes{Event: eventIdl, Types: idl.Types}
eventDef := codecv1.EventIDLTypes{Event: eventIdl, Types: idl.Types}

if err := s.addReadToCodec(s.parsed, namespace, genericName, idl, eventIdl, eventIdl, readDefinition); err != nil {
return err
Expand Down Expand Up @@ -667,7 +667,7 @@ func toLPFilter(
name string,
conf config.PollingFilter,
subKeyPaths [][]string,
eventIdl codec.EventIDLTypes,
eventIdl codecv1.EventIDLTypes,
) logpollertypes.Filter {
return logpollertypes.Filter{
EventName: name,
Expand Down
Loading
Loading