diff --git a/integration-tests/relayinterface/lookups_test.go b/integration-tests/relayinterface/lookups_test.go index cc35dc5a4..bf71bf023 100644 --- a/integration-tests/relayinterface/lookups_test.go +++ b/integration-tests/relayinterface/lookups_test.go @@ -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" diff --git a/pkg/solana/cap_encoder.go b/pkg/solana/cap_encoder.go index a846f7e7e..181ac7818 100644 --- a/pkg/solana/cap_encoder.go +++ b/pkg/solana/cap_encoder.go @@ -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 ( @@ -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) } @@ -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") diff --git a/pkg/solana/ccip/chainaccessor/event.go b/pkg/solana/ccip/chainaccessor/event.go index fd187b2c5..b8876a0c7 100644 --- a/pkg/solana/ccip/chainaccessor/event.go +++ b/pkg/solana/ccip/chainaccessor/event.go @@ -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" @@ -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 } @@ -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) } diff --git a/pkg/solana/ccip/config/chain_writer.go b/pkg/solana/ccip/config/chain_writer.go index 373fd6162..b4cca4d5a 100644 --- a/pkg/solana/ccip/config/chain_writer.go +++ b/pkg/solana/ccip/config/chain_writer.go @@ -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 ( @@ -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) } diff --git a/pkg/solana/chainreader/account_read_binding.go b/pkg/solana/chainreader/account_read_binding.go index 964a45fd3..24b24188d 100644 --- a/pkg/solana/chainreader/account_read_binding.go +++ b/pkg/solana/chainreader/account_read_binding.go @@ -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" ) @@ -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{ @@ -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 } diff --git a/pkg/solana/chainreader/bindings.go b/pkg/solana/chainreader/bindings.go index 15d15916f..4dc38ba89 100644 --- a/pkg/solana/chainreader/bindings.go +++ b/pkg/solana/chainreader/bindings.go @@ -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" ) @@ -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) diff --git a/pkg/solana/chainreader/bindings_test.go b/pkg/solana/chainreader/bindings_test.go index 333d64c30..07c6eb939 100644 --- a/pkg/solana/chainreader/bindings_test.go +++ b/pkg/solana/chainreader/bindings_test.go @@ -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" ) @@ -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 { diff --git a/pkg/solana/chainreader/chain_reader.go b/pkg/solana/chainreader/chain_reader.go index 3e72c72fb..9602f0b1e 100644 --- a/pkg/solana/chainreader/chain_reader.go +++ b/pkg/solana/chainreader/chain_reader.go @@ -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" @@ -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 } @@ -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) } @@ -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) @@ -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 @@ -489,7 +489,7 @@ 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 } @@ -497,10 +497,10 @@ func (s *ContractReaderService) addReadToCodec(parsed *solcommoncodec.ParsedType 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 } @@ -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 @@ -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 { @@ -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 } @@ -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", @@ -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 @@ -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, diff --git a/pkg/solana/chainreader/chain_reader_test.go b/pkg/solana/chainreader/chain_reader_test.go index 7bbaec38d..d7944e962 100644 --- a/pkg/solana/chainreader/chain_reader_test.go +++ b/pkg/solana/chainreader/chain_reader_test.go @@ -36,8 +36,8 @@ import ( "github.com/smartcontractkit/chainlink-solana/pkg/solana/chainreader" "github.com/smartcontractkit/chainlink-solana/pkg/solana/chainreader/mocks" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/testutils" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" + "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1/testutils" "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller" lpmocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/mocks" @@ -143,7 +143,7 @@ func TestSolanaChainReaderService_Start(t *testing.T) { {Name: "failed to register filter", ReadDef: eventReadDef, RegisterFilterError: fmt.Errorf("failed to register filter"), ExpectError: true}, } - boolType := codec.IdlType{} + boolType := codecv1.IdlType{} require.NoError(t, boolType.UnmarshalJSON([]byte("\"bool\""))) for _, tt := range testCases { @@ -151,12 +151,12 @@ func TestSolanaChainReaderService_Start(t *testing.T) { cfg := config.ContractReader{ Namespaces: map[string]config.ChainContractReader{ "myChainReader": { - IDL: codec.IDL{ - Accounts: []codec.IdlTypeDef{{Name: "myAccount", - Type: codec.IdlTypeDefTy{ - Kind: codec.IdlTypeDefTyKindStruct, - Fields: &[]codec.IdlField{}}}}, - Events: []codec.IdlEvent{{Name: "myEvent", Fields: []codec.IdlEventField{{Name: "a", Type: boolType}}}}, + IDL: codecv1.IDL{ + Accounts: []codecv1.IdlTypeDef{{Name: "myAccount", + Type: codecv1.IdlTypeDefTy{ + Kind: codecv1.IdlTypeDefTyKindStruct, + Fields: &[]codecv1.IdlField{}}}}, + Events: []codecv1.IdlEvent{{Name: "myEvent", Fields: []codecv1.IdlEventField{{Name: "a", Type: boolType}}}}, }, Reads: map[string]config.ReadDefinition{ "myRead": tt.ReadDef}, @@ -413,23 +413,23 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { testCases := []struct { name string - pdaDefinition codec.PDATypeDef + pdaDefinition codecv1.PDATypeDef inputModifier codeccommon.ModifiersConfig expected solana.PublicKey params map[string]any }{ { name: "happy path", - pdaDefinition: codec.PDATypeDef{ + pdaDefinition: codecv1.PDATypeDef{ Prefix: prefixBytes, - Seeds: []codec.PDASeed{ + Seeds: []codecv1.PDASeed{ { Name: "PubKey", - Type: codec.IdlType{AsString: codec.IdlTypePublicKey}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypePublicKey}, }, { Name: "Uint64Seed", - Type: codec.IdlType{AsString: codec.IdlTypeU64}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypeU64}, }, }, }, @@ -441,16 +441,16 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }, { name: "with modifier and random field", - pdaDefinition: codec.PDATypeDef{ + pdaDefinition: codecv1.PDATypeDef{ Prefix: prefixBytes, - Seeds: []codec.PDASeed{ + Seeds: []codecv1.PDASeed{ { Name: "PubKey", - Type: codec.IdlType{AsString: codec.IdlTypePublicKey}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypePublicKey}, }, { Name: "Uint64Seed", - Type: codec.IdlType{AsString: codec.IdlTypeU64}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypeU64}, }, }, }, @@ -466,7 +466,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }, { name: "only prefix", - pdaDefinition: codec.PDATypeDef{ + pdaDefinition: codecv1.PDATypeDef{ Prefix: prefixBytes, }, expected: mustFindProgramAddress(t, programID, [][]byte{prefixBytes}), @@ -474,16 +474,16 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }, { name: "no prefix", - pdaDefinition: codec.PDATypeDef{ + pdaDefinition: codecv1.PDATypeDef{ Prefix: nil, - Seeds: []codec.PDASeed{ + Seeds: []codecv1.PDASeed{ { Name: "PubKey", - Type: codec.IdlType{AsString: codec.IdlTypePublicKey}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypePublicKey}, }, { Name: "Uint64Seed", - Type: codec.IdlType{AsString: codec.IdlTypeU64}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypeU64}, }, }, }, @@ -495,12 +495,12 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }, { name: "public key seed provided as bytes", - pdaDefinition: codec.PDATypeDef{ + pdaDefinition: codecv1.PDATypeDef{ Prefix: prefixBytes, - Seeds: []codec.PDASeed{ + Seeds: []codecv1.PDASeed{ { Name: "PubKey", - Type: codec.IdlType{AsString: codec.IdlTypePublicKey}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypePublicKey}, }, }, }, @@ -555,12 +555,12 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { readDef := config.ReadDefinition{ ChainSpecificName: testutils.TestStructWithNestedStruct, ReadType: config.Account, - PDADefinition: codec.PDATypeDef{ + PDADefinition: codecv1.PDATypeDef{ Prefix: prefixBytes, - Seeds: []codec.PDASeed{ + Seeds: []codecv1.PDASeed{ { Name: "PubKey", - Type: codec.IdlType{AsString: codec.IdlTypePublicKey}, + Type: codecv1.IdlType{AsString: codecv1.IdlTypePublicKey}, }, }, }, @@ -594,16 +594,16 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }) } -func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, types.RemoteCodec) { +func newTestIDLAndCodec(t *testing.T) (string, codecv1.IDL, types.RemoteCodec) { t.Helper() - var idl codec.IDL + var idl codecv1.IDL if err := json.Unmarshal([]byte(testutils.JSONIDLWithAllTypes), &idl); err != nil { t.Logf("failed to unmarshal test IDL: %s", err.Error()) t.FailNow() } - entry, err := codec.NewIDLAccountCodec(idl, binary.LittleEndian()) + entry, err := codecv1.NewIDLAccountCodec(idl, binary.LittleEndian()) if err != nil { t.Logf("failed to create new codec from test IDL: %s", err.Error()) t.FailNow() @@ -1079,7 +1079,7 @@ func (r *chainReaderInterfaceTester) MaxWaitTimeForEvents() time.Duration { func makeTestCodec(t *testing.T, rawIDL string) types.RemoteCodec { t.Helper() - testCodec, err := codec.NewIDLAccountCodec(mustUnmarshalIDL(t, rawIDL), binary.LittleEndian()) + testCodec, err := codecv1.NewIDLAccountCodec(mustUnmarshalIDL(t, rawIDL), binary.LittleEndian()) if err != nil { t.Logf("failed to create new codec from test IDL: %s", err.Error()) t.FailNow() @@ -1261,8 +1261,8 @@ func (s *skipEventsChainReader) QueryKey(_ context.Context, _ types.BoundContrac return nil, nil } -func mustUnmarshalIDL(t *testing.T, rawIDL string) codec.IDL { - var idl codec.IDL +func mustUnmarshalIDL(t *testing.T, rawIDL string) codecv1.IDL { + var idl codecv1.IDL if err := json.Unmarshal([]byte(rawIDL), &idl); err != nil { t.Logf("failed to unmarshal test IDL: %s", err.Error()) t.FailNow() diff --git a/pkg/solana/chainreader/event_read_binding.go b/pkg/solana/chainreader/event_read_binding.go index c7600c768..bde99aaae 100644 --- a/pkg/solana/chainreader/event_read_binding.go +++ b/pkg/solana/chainreader/event_read_binding.go @@ -15,8 +15,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types/query" "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" - "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" @@ -202,8 +202,8 @@ func (b *eventReadBinding) GetReadDefinition() config.ReadDefinition { return b.readDefinition } -func (b *eventReadBinding) GetIDLInfo() (idl codec.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codec.IdlTypeDef) { - return codec.IDL{}, codec.IdlTypeDef{}, codec.IdlTypeDef{} +func (b *eventReadBinding) GetIDLInfo() (idl codecv1.IDL, inputIDLTypeDef interface{}, outputIDLTypeDef codecv1.IdlTypeDef) { + return codecv1.IDL{}, codecv1.IdlTypeDef{}, codecv1.IdlTypeDef{} } func (b *eventReadBinding) GetAddressResponseHardCoder() *commoncodec.HardCodeModifierConfig { diff --git a/pkg/solana/chainreader/event_read_binding_test.go b/pkg/solana/chainreader/event_read_binding_test.go index 38ca7eefe..9cf54ef22 100644 --- a/pkg/solana/chainreader/event_read_binding_test.go +++ b/pkg/solana/chainreader/event_read_binding_test.go @@ -16,8 +16,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types/query" "github.com/smartcontractkit/chainlink-solana/pkg/solana/chainreader/mocks" - "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" ) @@ -248,14 +248,14 @@ func newTestCodec(t *testing.T) *solcommoncodec.ParsedTypes { rawIDL := fmt.Sprintf(basicEventIDL, testParamType) - var IDL codec.IDL + var IDL codecv1.IDL require.NoError(t, json.Unmarshal([]byte(rawIDL), &IDL)) - idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, "EventType", IDL) + idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, "EventType", IDL) require.NoError(t, err) - entry, err := codec.CreateCodecEntry(idlDef, "GenericName", IDL, commoncodec.NewPathTraverseRenamer(map[string]string{"W": "A", "X": "B", "Y": "C", "Z": "D"}, true)) + entry, err := codecv1.CreateCodecEntry(idlDef, "GenericName", IDL, commoncodec.NewPathTraverseRenamer(map[string]string{"W": "A", "X": "B", "Y": "C", "Z": "D"}, true)) require.NoError(t, err) diff --git a/pkg/solana/chainwriter/chain_writer.go b/pkg/solana/chainwriter/chain_writer.go index 2088bb959..4134aed0b 100644 --- a/pkg/solana/chainwriter/chain_writer.go +++ b/pkg/solana/chainwriter/chain_writer.go @@ -18,9 +18,9 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-solana/pkg/solana/client" - solcodecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - solcodecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codecv2" - 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" + codecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v2" "github.com/smartcontractkit/chainlink-solana/pkg/solana/fees" "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm" txmutils "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/utils" @@ -110,7 +110,7 @@ func (s *SolanaChainWriterService) parsePrograms(config ChainWriterConfig) error } } else { // Fall back to codec IDL - var codecIDL solcodecv1.IDL + var codecIDL codecv1.IDL if err := json.Unmarshal([]byte(programConfig.IDL), &codecIDL); err != nil { return fmt.Errorf("failed to unmarshal IDL for program %s (tried both codecv2 and codec), error: %w", program, err) } @@ -123,10 +123,10 @@ func (s *SolanaChainWriterService) parsePrograms(config ChainWriterConfig) error return nil } -func (s *SolanaChainWriterService) parseProgramCodec(program string, programConfig ProgramConfig, idl solcodecv1.IDL) error { +func (s *SolanaChainWriterService) parseProgramCodec(program string, programConfig ProgramConfig, idl codecv1.IDL) error { for method, methodConfig := range programConfig.Methods { utils.InjectAddressModifier(methodConfig.InputModifications, nil) - idlDef, err := solcodecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeInstructionDef, methodConfig.ChainSpecificName, idl) + idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeInstructionDef, methodConfig.ChainSpecificName, idl) if err != nil { return err } @@ -136,7 +136,7 @@ func (s *SolanaChainWriterService) parseProgramCodec(program string, programConf return fmt.Errorf("failed to create input modifications for method %s.%s, error: %w", program, method, err) } - input, err := solcodecv1.CreateCodecEntry(idlDef, methodConfig.ChainSpecificName, idl, inputMod) + input, err := codecv1.CreateCodecEntry(idlDef, methodConfig.ChainSpecificName, idl, inputMod) if err != nil { return fmt.Errorf("failed to create codec entry for method %s.%s, error: %w", program, method, err) } @@ -149,7 +149,7 @@ func (s *SolanaChainWriterService) parseProgramCodec(program string, programConf func (s *SolanaChainWriterService) parseProgramCodecv2(program string, programConfig ProgramConfig, idl anchoridl.Idl) error { for method, methodConfig := range programConfig.Methods { utils.InjectAddressModifier(methodConfig.InputModifications, nil) - idlDef, err := solcodecv2.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeInstructionDef, methodConfig.ChainSpecificName, idl) + idlDef, err := codecv2.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeInstructionDef, methodConfig.ChainSpecificName, idl) if err != nil { return err } @@ -159,7 +159,7 @@ func (s *SolanaChainWriterService) parseProgramCodecv2(program string, programCo return fmt.Errorf("failed to create input modifications for method %s.%s, error: %w", program, method, err) } - input, err := solcodecv2.CreateCodecEntry(idlDef, methodConfig.ChainSpecificName, idl, inputMod) + input, err := codecv2.CreateCodecEntry(idlDef, methodConfig.ChainSpecificName, idl, inputMod) if err != nil { return fmt.Errorf("failed to create codec entry for method %s.%s, error: %w", program, method, err) } diff --git a/pkg/solana/chainwriter/chain_writer_test.go b/pkg/solana/chainwriter/chain_writer_test.go index 900597cba..3e5ddc0d3 100644 --- a/pkg/solana/chainwriter/chain_writer_test.go +++ b/pkg/solana/chainwriter/chain_writer_test.go @@ -30,9 +30,9 @@ import ( "github.com/smartcontractkit/chainlink-solana/pkg/solana/chainwriter" "github.com/smartcontractkit/chainlink-solana/pkg/solana/client" clientmocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/client/mocks" - solcodecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - codecTestUtils "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/testutils" - solcodecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codecv2" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" + codecv1TestUtils "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1/testutils" + codecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v2" feemocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/fees/mocks" txmMocks "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/mocks" txmutils "github.com/smartcontractkit/chainlink-solana/pkg/solana/txm/utils" @@ -1369,7 +1369,7 @@ func TestChainWriter_ParsePrograms(t *testing.T) { cwConfig := chainwriter.ChainWriterConfig{ Programs: map[string]chainwriter.ProgramConfig{ "testIDLv1": { - IDL: solcodecv1.FetchChainWriterTestIDL(), + IDL: codecv1.FetchChainWriterTestIDL(), Methods: map[string]chainwriter.MethodConfig{ "TestItemArray1Type": { ChainSpecificName: "TestItemArray1Type", @@ -1377,7 +1377,7 @@ func TestChainWriter_ParsePrograms(t *testing.T) { }, }, "testIDLv2": { - IDL: solcodecv2.FetchChainWriterTestIDL(), + IDL: codecv2.FetchChainWriterTestIDL(), Methods: map[string]chainwriter.MethodConfig{ "TestItemArray1Type": { ChainSpecificName: "test_item_array1_type", @@ -1392,16 +1392,16 @@ func TestChainWriter_ParsePrograms(t *testing.T) { require.NoError(t, err) // Test v1 encoding - use codecTestUtils.TestItemAsArgs which has PascalCase field names - testArrayV1 := [1]codecTestUtils.TestItemAsArgs{{ + testArrayV1 := [1]codecv1TestUtils.TestItemAsArgs{{ Field: 1, OracleID: 2, OracleIDs: [32]uint8{3}, - AccountStruct: codecTestUtils.AccountStruct{}, + AccountStruct: codecv1TestUtils.AccountStruct{}, Accounts: []solana.PublicKey{}, DifferentField: "test", BigField: ag_binary.Int128{Lo: 5}, - NestedDynamicStruct: codecTestUtils.NestedDynamic{FixedBytes: [2]uint8{6, 7}, Inner: codecTestUtils.InnerDynamic{IntVal: 8, S: "inner"}}, - NestedStaticStruct: codecTestUtils.NestedStatic{FixedBytes: [2]uint8{9, 10}, Inner: codecTestUtils.InnerStatic{IntVal: 11}}, + NestedDynamicStruct: codecv1TestUtils.NestedDynamic{FixedBytes: [2]uint8{6, 7}, Inner: codecv1TestUtils.InnerDynamic{IntVal: 8, S: "inner"}}, + NestedStaticStruct: codecv1TestUtils.NestedStatic{FixedBytes: [2]uint8{9, 10}, Inner: codecv1TestUtils.InnerStatic{IntVal: 11}}, }} encodedPayloadv1, err := cw.EncodePayload(ctx, testArrayV1, chainwriter.MethodConfig{ diff --git a/pkg/solana/chainwriter/lookups.go b/pkg/solana/chainwriter/lookups.go index 247e263f0..27870327e 100644 --- a/pkg/solana/chainwriter/lookups.go +++ b/pkg/solana/chainwriter/lookups.go @@ -10,8 +10,8 @@ import ( "github.com/gagliardetto/solana-go/rpc" "github.com/smartcontractkit/chainlink-solana/pkg/solana/client" - "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 ( @@ -285,19 +285,19 @@ func (pda PDALookups) Resolve(ctx context.Context, args any, derivedTableMap map return nil, lookupErrWithName(pda.Name, fmt.Errorf("error fetching account info for PDA account: %s, error: %w", accountMeta.PublicKey.String(), err)) } - var idlCodec codec.IDL + var idlCodec codecv1.IDL if err = json.Unmarshal([]byte(pda.InternalField.IDL), &idlCodec); err != nil { return nil, lookupErrWithName(pda.Name, fmt.Errorf("failed to unmarshal IDL: %w", err)) } internalType := pda.InternalField.TypeName - idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, internalType, idlCodec) + idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeAccountDef, internalType, idlCodec) if err != nil { return nil, lookupErrWithName(pda.Name, fmt.Errorf("error finding definition for type %s: %w", internalType, err)) } - input, err := codec.CreateCodecEntry(idlDef, internalType, idlCodec, nil) + input, err := codecv1.CreateCodecEntry(idlDef, internalType, idlCodec, nil) if err != nil { return nil, lookupErrWithName(pda.Name, fmt.Errorf("failed to create codec entry for type %s, error: %w", internalType, err)) } diff --git a/pkg/solana/commoncodec/byte_string_modifier.go b/pkg/solana/codec/common/byte_string_modifier.go similarity index 100% rename from pkg/solana/commoncodec/byte_string_modifier.go rename to pkg/solana/codec/common/byte_string_modifier.go diff --git a/pkg/solana/commoncodec/byte_string_modifier_test.go b/pkg/solana/codec/common/byte_string_modifier_test.go similarity index 99% rename from pkg/solana/commoncodec/byte_string_modifier_test.go rename to pkg/solana/codec/common/byte_string_modifier_test.go index 307e7fbd5..08494c81c 100644 --- a/pkg/solana/commoncodec/byte_string_modifier_test.go +++ b/pkg/solana/codec/common/byte_string_modifier_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) func TestSolanaAddressModifier(t *testing.T) { diff --git a/pkg/solana/commoncodec/codec_entry.go b/pkg/solana/codec/common/codec_entry.go similarity index 100% rename from pkg/solana/commoncodec/codec_entry.go rename to pkg/solana/codec/common/codec_entry.go diff --git a/pkg/solana/commoncodec/cross_chain_amount.go b/pkg/solana/codec/common/cross_chain_amount.go similarity index 100% rename from pkg/solana/commoncodec/cross_chain_amount.go rename to pkg/solana/codec/common/cross_chain_amount.go diff --git a/pkg/solana/commoncodec/cross_chain_amount_test.go b/pkg/solana/codec/common/cross_chain_amount_test.go similarity index 98% rename from pkg/solana/commoncodec/cross_chain_amount_test.go rename to pkg/solana/codec/common/cross_chain_amount_test.go index e4277750e..37915d540 100644 --- a/pkg/solana/commoncodec/cross_chain_amount_test.go +++ b/pkg/solana/codec/common/cross_chain_amount_test.go @@ -8,7 +8,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) func TestSolanaCrossChainAmountCodec(t *testing.T) { diff --git a/pkg/solana/commoncodec/decoder.go b/pkg/solana/codec/common/decoder.go similarity index 100% rename from pkg/solana/commoncodec/decoder.go rename to pkg/solana/codec/common/decoder.go diff --git a/pkg/solana/commoncodec/decoder_test.go b/pkg/solana/codec/common/decoder_test.go similarity index 100% rename from pkg/solana/commoncodec/decoder_test.go rename to pkg/solana/codec/common/decoder_test.go diff --git a/pkg/solana/commoncodec/discriminator.go b/pkg/solana/codec/common/discriminator.go similarity index 100% rename from pkg/solana/commoncodec/discriminator.go rename to pkg/solana/codec/common/discriminator.go diff --git a/pkg/solana/commoncodec/discriminator_extractor_test.go b/pkg/solana/codec/common/discriminator_extractor_test.go similarity index 100% rename from pkg/solana/commoncodec/discriminator_extractor_test.go rename to pkg/solana/codec/common/discriminator_extractor_test.go diff --git a/pkg/solana/commoncodec/discriminator_test.go b/pkg/solana/codec/common/discriminator_test.go similarity index 97% rename from pkg/solana/commoncodec/discriminator_test.go rename to pkg/solana/codec/common/discriminator_test.go index aa4b4b4e4..6dacbfc90 100644 --- a/pkg/solana/commoncodec/discriminator_test.go +++ b/pkg/solana/codec/common/discriminator_test.go @@ -10,7 +10,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + commoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) func TestDiscriminator(t *testing.T) { diff --git a/pkg/solana/commoncodec/duration.go b/pkg/solana/codec/common/duration.go similarity index 100% rename from pkg/solana/commoncodec/duration.go rename to pkg/solana/codec/common/duration.go diff --git a/pkg/solana/commoncodec/encoder.go b/pkg/solana/codec/common/encoder.go similarity index 100% rename from pkg/solana/commoncodec/encoder.go rename to pkg/solana/codec/common/encoder.go diff --git a/pkg/solana/commoncodec/encoder_test.go b/pkg/solana/codec/common/encoder_test.go similarity index 100% rename from pkg/solana/commoncodec/encoder_test.go rename to pkg/solana/codec/common/encoder_test.go diff --git a/pkg/solana/commoncodec/option.go b/pkg/solana/codec/common/option.go similarity index 100% rename from pkg/solana/commoncodec/option.go rename to pkg/solana/codec/common/option.go diff --git a/pkg/solana/commoncodec/parsed_types.go b/pkg/solana/codec/common/parsed_types.go similarity index 100% rename from pkg/solana/commoncodec/parsed_types.go rename to pkg/solana/codec/common/parsed_types.go diff --git a/pkg/solana/commoncodec/parsed_types_test.go b/pkg/solana/codec/common/parsed_types_test.go similarity index 86% rename from pkg/solana/commoncodec/parsed_types_test.go rename to pkg/solana/codec/common/parsed_types_test.go index 78a28ade4..1be594c0c 100644 --- a/pkg/solana/commoncodec/parsed_types_test.go +++ b/pkg/solana/codec/common/parsed_types_test.go @@ -10,8 +10,8 @@ import ( commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" - "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" ) func TestEncodeDecodeBigInt(t *testing.T) { @@ -49,10 +49,10 @@ func newTestCodec(t *testing.T) *solcommoncodec.ParsedTypes { rawIDL := fmt.Sprintf(basicEventIDL, testParamType) - var IDL codec.IDL + var IDL codecv1.IDL require.NoError(t, json.Unmarshal([]byte(rawIDL), &IDL)) - idlDef, err := codec.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, "EventType", IDL) + idlDef, err := codecv1.FindDefinitionFromIDL(solcommoncodec.ChainConfigTypeEventDef, "EventType", IDL) require.NoError(t, err) @@ -60,7 +60,7 @@ func newTestCodec(t *testing.T) *solcommoncodec.ParsedTypes { commoncodec.NewRenamer(map[string]string{"X": "A", "Y": "B"}), } - entry, err := codec.CreateCodecEntry(idlDef, "GenericName", IDL, mods) + entry, err := codecv1.CreateCodecEntry(idlDef, "GenericName", IDL, mods) require.NoError(t, err) diff --git a/pkg/solana/commoncodec/solana.go b/pkg/solana/codec/common/solana.go similarity index 100% rename from pkg/solana/commoncodec/solana.go rename to pkg/solana/codec/common/solana.go diff --git a/pkg/solana/commoncodec/types.go b/pkg/solana/codec/common/types.go similarity index 100% rename from pkg/solana/commoncodec/types.go rename to pkg/solana/codec/common/types.go diff --git a/pkg/solana/codec/compat_v1.go b/pkg/solana/codec/compat_v1.go index 3ddc78660..c1cbf46a1 100644 --- a/pkg/solana/codec/compat_v1.go +++ b/pkg/solana/codec/compat_v1.go @@ -1,166 +1,166 @@ package codec -// import ( -// commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" -// "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" -// commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - -// solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" -// codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" -// ) - -// // Backward-compatible aliases for the old pkg/solana/codec public API. -// // The underlying implementation now lives in pkg/solana/codec/v1 and pkg/solana/codec/common. - -// type ChainConfigType = solcommoncodec.ChainConfigType - -// const ( -// ChainConfigTypeAccountDef = solcommoncodec.ChainConfigTypeAccountDef -// ChainConfigTypeInstructionDef = solcommoncodec.ChainConfigTypeInstructionDef -// ChainConfigTypeEventDef = solcommoncodec.ChainConfigTypeEventDef -// ) - -// type Config = solcommoncodec.Config -// type ChainConfig = solcommoncodec.ChainConfig -// type Entry = solcommoncodec.Entry -// type ParsedTypes = solcommoncodec.ParsedTypes - -// var DecoderHooks = solcommoncodec.DecoderHooks - -// func WrapItemType(forEncoding bool, contractName, itemType string) string { -// return solcommoncodec.WrapItemType(forEncoding, contractName, itemType) -// } - -// func AddEntries(defs map[string]Entry, modByTypeName map[string]map[string]commoncodec.Modifier) error { -// return solcommoncodec.AddEntries(defs, modByTypeName) -// } - -// func EntryAsModifierRemoteCodec(entry Entry, itemType string) (commontypes.RemoteCodec, error) { -// return solcommoncodec.EntryAsModifierRemoteCodec(entry, itemType) -// } - -// type IDL = codecv1.IDL -// type IdlConstant = codecv1.IdlConstant -// type IdlTypeDefSlice = codecv1.IdlTypeDefSlice -// type IdlEvent = codecv1.IdlEvent -// type IdlEventField = codecv1.IdlEventField -// type IdlInstruction = codecv1.IdlInstruction -// type IdlAccountItemSlice = codecv1.IdlAccountItemSlice -// type IdlAccountItem = codecv1.IdlAccountItem -// type IdlAccount = codecv1.IdlAccount -// type IdlAccounts = codecv1.IdlAccounts -// type IdlField = codecv1.IdlField -// type PDATypeDef = codecv1.PDATypeDef -// type PDASeed = codecv1.PDASeed -// type IdlTypeAsString = codecv1.IdlTypeAsString -// type IdlTypeVec = codecv1.IdlTypeVec -// type IdlTypeOption = codecv1.IdlTypeOption -// type IdlTypeDefined = codecv1.IdlTypeDefined -// type IdlTypeArray = codecv1.IdlTypeArray -// type IdlType = codecv1.IdlType -// type IdlTypeDef = codecv1.IdlTypeDef -// type IdlTypeDefTyKind = codecv1.IdlTypeDefTyKind -// type IdlTypeDefTyStruct = codecv1.IdlTypeDefTyStruct -// type IdlTypeDefTyEnum = codecv1.IdlTypeDefTyEnum -// type IdlTypeDefTy = codecv1.IdlTypeDefTy -// type IdlEnumVariantSlice = codecv1.IdlEnumVariantSlice -// type IdlTypeDefStruct = codecv1.IdlTypeDefStruct -// type IdlEnumVariant = codecv1.IdlEnumVariant -// type IdlEnumFields = codecv1.IdlEnumFields -// type IdlEnumFieldsNamed = codecv1.IdlEnumFieldsNamed -// type IdlEnumFieldsTuple = codecv1.IdlEnumFieldsTuple -// type IdlErrorCode = codecv1.IdlErrorCode - -// const ( -// IdlTypeDefTyKindStruct = codecv1.IdlTypeDefTyKindStruct -// IdlTypeDefTyKindEnum = codecv1.IdlTypeDefTyKindEnum -// IdlTypeDefTyKindCustom = codecv1.IdlTypeDefTyKindCustom -// ) - -// const ( -// IdlTypeBool = codecv1.IdlTypeBool -// IdlTypeU8 = codecv1.IdlTypeU8 -// IdlTypeI8 = codecv1.IdlTypeI8 -// IdlTypeU16 = codecv1.IdlTypeU16 -// IdlTypeI16 = codecv1.IdlTypeI16 -// IdlTypeU32 = codecv1.IdlTypeU32 -// IdlTypeI32 = codecv1.IdlTypeI32 -// IdlTypeU64 = codecv1.IdlTypeU64 -// IdlTypeI64 = codecv1.IdlTypeI64 -// IdlTypeU128 = codecv1.IdlTypeU128 -// IdlTypeI128 = codecv1.IdlTypeI128 -// IdlTypeBytes = codecv1.IdlTypeBytes -// IdlTypeString = codecv1.IdlTypeString -// IdlTypePublicKey = codecv1.IdlTypePublicKey -// IdlTypeUnixTimestamp = codecv1.IdlTypeUnixTimestamp -// IdlTypeHash = codecv1.IdlTypeHash -// IdlTypeDuration = codecv1.IdlTypeDuration -// ) - -// const DefaultHashBitLength = codecv1.DefaultHashBitLength - -// var NilIdlTypeDefTy = codecv1.NilIdlTypeDefTy - -// func NewIdlStringType(asString IdlTypeAsString) IdlType { -// return codecv1.NewIdlStringType(asString) -// } - -// type AccountIDLTypes = codecv1.AccountIDLTypes -// type InstructionArgsIDLTypes = codecv1.InstructionArgsIDLTypes -// type EventIDLTypes = codecv1.EventIDLTypes - -// func NewAccountEntry(offchainName string, idlTypes AccountIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { -// return codecv1.NewAccountEntry(offchainName, idlTypes, includeDiscriminator, mod, builder) -// } - -// func NewPDAEntry(offchainName string, pdaTypeDef PDATypeDef, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { -// return codecv1.NewPDAEntry(offchainName, pdaTypeDef, mod, builder) -// } - -// func NewInstructionArgsEntry(offChainName string, idlTypes InstructionArgsIDLTypes, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { -// return codecv1.NewInstructionArgsEntry(offChainName, idlTypes, mod, builder) -// } +import ( + commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" + "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" + + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" +) + +// Backward-compatible aliases for the old pkg/solana/codec public API. +// The underlying implementation now lives in pkg/solana/codec/v1 and pkg/solana/codec/common. + +type ChainConfigType = solcommoncodec.ChainConfigType + +const ( + ChainConfigTypeAccountDef = solcommoncodec.ChainConfigTypeAccountDef + ChainConfigTypeInstructionDef = solcommoncodec.ChainConfigTypeInstructionDef + ChainConfigTypeEventDef = solcommoncodec.ChainConfigTypeEventDef +) + +type Config = solcommoncodec.Config +type ChainConfig = solcommoncodec.ChainConfig +type Entry = solcommoncodec.Entry +type ParsedTypes = solcommoncodec.ParsedTypes + +var DecoderHooks = solcommoncodec.DecoderHooks + +func WrapItemType(forEncoding bool, contractName, itemType string) string { + return solcommoncodec.WrapItemType(forEncoding, contractName, itemType) +} + +func AddEntries(defs map[string]Entry, modByTypeName map[string]map[string]commoncodec.Modifier) error { + return solcommoncodec.AddEntries(defs, modByTypeName) +} + +func EntryAsModifierRemoteCodec(entry Entry, itemType string) (commontypes.RemoteCodec, error) { + return solcommoncodec.EntryAsModifierRemoteCodec(entry, itemType) +} + +type IDL = codecv1.IDL +type IdlConstant = codecv1.IdlConstant +type IdlTypeDefSlice = codecv1.IdlTypeDefSlice +type IdlEvent = codecv1.IdlEvent +type IdlEventField = codecv1.IdlEventField +type IdlInstruction = codecv1.IdlInstruction +type IdlAccountItemSlice = codecv1.IdlAccountItemSlice +type IdlAccountItem = codecv1.IdlAccountItem +type IdlAccount = codecv1.IdlAccount +type IdlAccounts = codecv1.IdlAccounts +type IdlField = codecv1.IdlField +type PDATypeDef = codecv1.PDATypeDef +type PDASeed = codecv1.PDASeed +type IdlTypeAsString = codecv1.IdlTypeAsString +type IdlTypeVec = codecv1.IdlTypeVec +type IdlTypeOption = codecv1.IdlTypeOption +type IdlTypeDefined = codecv1.IdlTypeDefined +type IdlTypeArray = codecv1.IdlTypeArray +type IdlType = codecv1.IdlType +type IdlTypeDef = codecv1.IdlTypeDef +type IdlTypeDefTyKind = codecv1.IdlTypeDefTyKind +type IdlTypeDefTyStruct = codecv1.IdlTypeDefTyStruct +type IdlTypeDefTyEnum = codecv1.IdlTypeDefTyEnum +type IdlTypeDefTy = codecv1.IdlTypeDefTy +type IdlEnumVariantSlice = codecv1.IdlEnumVariantSlice +type IdlTypeDefStruct = codecv1.IdlTypeDefStruct +type IdlEnumVariant = codecv1.IdlEnumVariant +type IdlEnumFields = codecv1.IdlEnumFields +type IdlEnumFieldsNamed = codecv1.IdlEnumFieldsNamed +type IdlEnumFieldsTuple = codecv1.IdlEnumFieldsTuple +type IdlErrorCode = codecv1.IdlErrorCode + +const ( + IdlTypeDefTyKindStruct = codecv1.IdlTypeDefTyKindStruct + IdlTypeDefTyKindEnum = codecv1.IdlTypeDefTyKindEnum + IdlTypeDefTyKindCustom = codecv1.IdlTypeDefTyKindCustom +) + +const ( + IdlTypeBool = codecv1.IdlTypeBool + IdlTypeU8 = codecv1.IdlTypeU8 + IdlTypeI8 = codecv1.IdlTypeI8 + IdlTypeU16 = codecv1.IdlTypeU16 + IdlTypeI16 = codecv1.IdlTypeI16 + IdlTypeU32 = codecv1.IdlTypeU32 + IdlTypeI32 = codecv1.IdlTypeI32 + IdlTypeU64 = codecv1.IdlTypeU64 + IdlTypeI64 = codecv1.IdlTypeI64 + IdlTypeU128 = codecv1.IdlTypeU128 + IdlTypeI128 = codecv1.IdlTypeI128 + IdlTypeBytes = codecv1.IdlTypeBytes + IdlTypeString = codecv1.IdlTypeString + IdlTypePublicKey = codecv1.IdlTypePublicKey + IdlTypeUnixTimestamp = codecv1.IdlTypeUnixTimestamp + IdlTypeHash = codecv1.IdlTypeHash + IdlTypeDuration = codecv1.IdlTypeDuration +) + +const DefaultHashBitLength = codecv1.DefaultHashBitLength + +var NilIdlTypeDefTy = codecv1.NilIdlTypeDefTy + +func NewIdlStringType(asString IdlTypeAsString) IdlType { + return codecv1.NewIdlStringType(asString) +} + +type AccountIDLTypes = codecv1.AccountIDLTypes +type InstructionArgsIDLTypes = codecv1.InstructionArgsIDLTypes +type EventIDLTypes = codecv1.EventIDLTypes + +func NewAccountEntry(offchainName string, idlTypes AccountIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { + return codecv1.NewAccountEntry(offchainName, idlTypes, includeDiscriminator, mod, builder) +} + +func NewPDAEntry(offchainName string, pdaTypeDef PDATypeDef, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { + return codecv1.NewPDAEntry(offchainName, pdaTypeDef, mod, builder) +} + +func NewInstructionArgsEntry(offChainName string, idlTypes InstructionArgsIDLTypes, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { + return codecv1.NewInstructionArgsEntry(offChainName, idlTypes, mod, builder) +} // func NewEventArgsEntryWrapper(offChainName string, contractIdl string, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { // return codecv1.NewEventArgsEntryWrapper(offChainName, contractIdl, includeDiscriminator, mod, builder) // } -// func NewEventArgsEntry(offChainName string, idlTypes EventIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { -// return codecv1.NewEventArgsEntry(offChainName, idlTypes, includeDiscriminator, mod, builder) -// } +func NewEventArgsEntry(offChainName string, idlTypes EventIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { + return codecv1.NewEventArgsEntry(offChainName, idlTypes, includeDiscriminator, mod, builder) +} -// func NewOnRampAddress(builder encodings.Builder) encodings.TypeCodec { -// return codecv1.NewOnRampAddress(builder) -// } +func NewOnRampAddress(builder encodings.Builder) encodings.TypeCodec { + return codecv1.NewOnRampAddress(builder) +} -// func NewCodec(conf Config) (commontypes.RemoteCodec, error) { -// return codecv1.NewCodec(conf) -// } +func NewCodec(conf Config) (commontypes.RemoteCodec, error) { + return codecv1.NewCodec(conf) +} -// func CreateCodecEntry(idlDefinition interface{}, offChainName string, idl IDL, mod commoncodec.Modifier) (entry Entry, err error) { -// return codecv1.CreateCodecEntry(idlDefinition, offChainName, idl, mod) -// } +func CreateCodecEntry(idlDefinition interface{}, offChainName string, idl IDL, mod commoncodec.Modifier) (entry Entry, err error) { + return codecv1.CreateCodecEntry(idlDefinition, offChainName, idl, mod) +} // func CreateCodecEntryWrapper(cfgType ChainConfigType, mod commoncodec.Modifier, onChainName, offChainName, idlString string) (entry Entry, err error) { // return codecv1.CreateCodecEntryWrapper(cfgType, mod, onChainName, offChainName, idlString) // } -// func FindDefinitionFromIDL(cfgType ChainConfigType, chainSpecificName string, idl IDL) (interface{}, error) { -// return codecv1.FindDefinitionFromIDL(cfgType, chainSpecificName, idl) -// } +func FindDefinitionFromIDL(cfgType ChainConfigType, chainSpecificName string, idl IDL) (interface{}, error) { + return codecv1.FindDefinitionFromIDL(cfgType, chainSpecificName, idl) +} -// func ExtractEventIDL(eventName string, idl IDL) (IdlEvent, error) { -// return codecv1.ExtractEventIDL(eventName, idl) -// } +func ExtractEventIDL(eventName string, idl IDL) (IdlEvent, error) { + return codecv1.ExtractEventIDL(eventName, idl) +} -// func NewIDLAccountCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { -// return codecv1.NewIDLAccountCodec(idl, builder) -// } +func NewIDLAccountCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { + return codecv1.NewIDLAccountCodec(idl, builder) +} -// func NewNamedModifierCodec(original commontypes.RemoteCodec, itemType string, modifier commoncodec.Modifier) (commontypes.RemoteCodec, error) { -// return codecv1.NewNamedModifierCodec(original, itemType, modifier) -// } +func NewNamedModifierCodec(original commontypes.RemoteCodec, itemType string, modifier commoncodec.Modifier) (commontypes.RemoteCodec, error) { + return codecv1.NewNamedModifierCodec(original, itemType, modifier) +} -// func NewIDLDefinedTypesCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { -// return codecv1.NewIDLDefinedTypesCodec(idl, builder) -// } +func NewIDLDefinedTypesCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { + return codecv1.NewIDLDefinedTypesCodec(idl, builder) +} diff --git a/pkg/solana/codec/compat_v1_test.go b/pkg/solana/codec/compat_v1_test.go index 46a447cd2..39142f331 100644 --- a/pkg/solana/codec/compat_v1_test.go +++ b/pkg/solana/codec/compat_v1_test.go @@ -1,50 +1,50 @@ package codec_test -// import ( -// "testing" +import ( + "testing" -// solanacodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" -// codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" -// ) + solanacodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" +) -// func TestCompatV1IdlTypeConstants(t *testing.T) { -// t.Parallel() +func TestCompatV1IdlTypeConstants(t *testing.T) { + t.Parallel() -// tests := []struct { -// name string -// got codecv1.IdlTypeAsString -// want codecv1.IdlTypeAsString -// }{ -// {name: "IdlTypeBool", got: solanacodec.IdlTypeBool, want: codecv1.IdlTypeBool}, -// {name: "IdlTypeU8", got: solanacodec.IdlTypeU8, want: codecv1.IdlTypeU8}, -// {name: "IdlTypeI8", got: solanacodec.IdlTypeI8, want: codecv1.IdlTypeI8}, -// {name: "IdlTypeU16", got: solanacodec.IdlTypeU16, want: codecv1.IdlTypeU16}, -// {name: "IdlTypeI16", got: solanacodec.IdlTypeI16, want: codecv1.IdlTypeI16}, -// {name: "IdlTypeU32", got: solanacodec.IdlTypeU32, want: codecv1.IdlTypeU32}, -// {name: "IdlTypeI32", got: solanacodec.IdlTypeI32, want: codecv1.IdlTypeI32}, -// {name: "IdlTypeU64", got: solanacodec.IdlTypeU64, want: codecv1.IdlTypeU64}, -// {name: "IdlTypeI64", got: solanacodec.IdlTypeI64, want: codecv1.IdlTypeI64}, -// {name: "IdlTypeU128", got: solanacodec.IdlTypeU128, want: codecv1.IdlTypeU128}, -// {name: "IdlTypeI128", got: solanacodec.IdlTypeI128, want: codecv1.IdlTypeI128}, -// {name: "IdlTypeBytes", got: solanacodec.IdlTypeBytes, want: codecv1.IdlTypeBytes}, -// {name: "IdlTypeString", got: solanacodec.IdlTypeString, want: codecv1.IdlTypeString}, -// {name: "IdlTypePublicKey", got: solanacodec.IdlTypePublicKey, want: codecv1.IdlTypePublicKey}, -// {name: "IdlTypeUnixTimestamp", got: solanacodec.IdlTypeUnixTimestamp, want: codecv1.IdlTypeUnixTimestamp}, -// {name: "IdlTypeHash", got: solanacodec.IdlTypeHash, want: codecv1.IdlTypeHash}, -// {name: "IdlTypeDuration", got: solanacodec.IdlTypeDuration, want: codecv1.IdlTypeDuration}, -// } + tests := []struct { + name string + got codecv1.IdlTypeAsString + want codecv1.IdlTypeAsString + }{ + {name: "IdlTypeBool", got: solanacodec.IdlTypeBool, want: codecv1.IdlTypeBool}, + {name: "IdlTypeU8", got: solanacodec.IdlTypeU8, want: codecv1.IdlTypeU8}, + {name: "IdlTypeI8", got: solanacodec.IdlTypeI8, want: codecv1.IdlTypeI8}, + {name: "IdlTypeU16", got: solanacodec.IdlTypeU16, want: codecv1.IdlTypeU16}, + {name: "IdlTypeI16", got: solanacodec.IdlTypeI16, want: codecv1.IdlTypeI16}, + {name: "IdlTypeU32", got: solanacodec.IdlTypeU32, want: codecv1.IdlTypeU32}, + {name: "IdlTypeI32", got: solanacodec.IdlTypeI32, want: codecv1.IdlTypeI32}, + {name: "IdlTypeU64", got: solanacodec.IdlTypeU64, want: codecv1.IdlTypeU64}, + {name: "IdlTypeI64", got: solanacodec.IdlTypeI64, want: codecv1.IdlTypeI64}, + {name: "IdlTypeU128", got: solanacodec.IdlTypeU128, want: codecv1.IdlTypeU128}, + {name: "IdlTypeI128", got: solanacodec.IdlTypeI128, want: codecv1.IdlTypeI128}, + {name: "IdlTypeBytes", got: solanacodec.IdlTypeBytes, want: codecv1.IdlTypeBytes}, + {name: "IdlTypeString", got: solanacodec.IdlTypeString, want: codecv1.IdlTypeString}, + {name: "IdlTypePublicKey", got: solanacodec.IdlTypePublicKey, want: codecv1.IdlTypePublicKey}, + {name: "IdlTypeUnixTimestamp", got: solanacodec.IdlTypeUnixTimestamp, want: codecv1.IdlTypeUnixTimestamp}, + {name: "IdlTypeHash", got: solanacodec.IdlTypeHash, want: codecv1.IdlTypeHash}, + {name: "IdlTypeDuration", got: solanacodec.IdlTypeDuration, want: codecv1.IdlTypeDuration}, + } -// for _, tt := range tests { -// if tt.got != tt.want { -// t.Fatalf("%s mismatch: got %q, want %q", tt.name, tt.got, tt.want) -// } -// } -// } + for _, tt := range tests { + if tt.got != tt.want { + t.Fatalf("%s mismatch: got %q, want %q", tt.name, tt.got, tt.want) + } + } +} -// func TestCompatV1DefaultHashBitLength(t *testing.T) { -// t.Parallel() +func TestCompatV1DefaultHashBitLength(t *testing.T) { + t.Parallel() -// if solanacodec.DefaultHashBitLength != codecv1.DefaultHashBitLength { -// t.Fatalf("DefaultHashBitLength mismatch: got %d, want %d", solanacodec.DefaultHashBitLength, codecv1.DefaultHashBitLength) -// } -// } + if solanacodec.DefaultHashBitLength != codecv1.DefaultHashBitLength { + t.Fatalf("DefaultHashBitLength mismatch: got %d, want %d", solanacodec.DefaultHashBitLength, codecv1.DefaultHashBitLength) + } +} diff --git a/pkg/solana/codec/anchoridl.go b/pkg/solana/codec/v1/anchoridl.go similarity index 99% rename from pkg/solana/codec/anchoridl.go rename to pkg/solana/codec/v1/anchoridl.go index 97856a528..d6ab77be3 100644 --- a/pkg/solana/codec/anchoridl.go +++ b/pkg/solana/codec/v1/anchoridl.go @@ -1,4 +1,4 @@ -package codec +package codecv1 /* copied from https://github.com/gagliardetto/anchor-go where the IDL definition is not importable due to being defined diff --git a/pkg/solana/codec/anchoridl_test.go b/pkg/solana/codec/v1/anchoridl_test.go similarity index 99% rename from pkg/solana/codec/anchoridl_test.go rename to pkg/solana/codec/v1/anchoridl_test.go index 144f67a28..425769b06 100644 --- a/pkg/solana/codec/anchoridl_test.go +++ b/pkg/solana/codec/v1/anchoridl_test.go @@ -1,4 +1,4 @@ -package codec +package codecv1 import ( "encoding/json" diff --git a/pkg/solana/codec/codec_entry.go b/pkg/solana/codec/v1/codec_entry.go similarity index 98% rename from pkg/solana/codec/codec_entry.go rename to pkg/solana/codec/v1/codec_entry.go index 3f41b8713..9cabddb2e 100644 --- a/pkg/solana/codec/codec_entry.go +++ b/pkg/solana/codec/v1/codec_entry.go @@ -1,9 +1,9 @@ -package codec +package codecv1 import ( "github.com/smartcontractkit/chainlink-common/pkg/codec" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) type AccountIDLTypes struct { diff --git a/pkg/solana/codec/codec_test.go b/pkg/solana/codec/v1/codec_test.go similarity index 97% rename from pkg/solana/codec/codec_test.go rename to pkg/solana/codec/v1/codec_test.go index 4ac8478db..a5c4d7d75 100644 --- a/pkg/solana/codec/codec_test.go +++ b/pkg/solana/codec/v1/codec_test.go @@ -1,4 +1,4 @@ -package codec_test +package codecv1_test import ( "bytes" @@ -19,9 +19,9 @@ import ( clcommontypes "github.com/smartcontractkit/chainlink-common/pkg/types" . "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" //nolint common practice to import test mods with . - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/testutils" - 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/codec/v1/testutils" ) const anyExtraValue = 3 @@ -161,7 +161,7 @@ func (it *codecInterfaceTester) GetCodec(t *testing.T) clcommontypes.Codec { codecConfig.Configs["DummyNamespace."+offChainName] = codecEntryCfg } - c, err := codec.NewCodec(codecConfig) + c, err := codecv1.NewCodec(codecConfig) require.NoError(t, err) return &compatibleItemTypeCodecWrapper{codec: c} diff --git a/pkg/solana/codec/helpers.go b/pkg/solana/codec/v1/helpers.go similarity index 92% rename from pkg/solana/codec/helpers.go rename to pkg/solana/codec/v1/helpers.go index b5854b854..b970d2b5f 100644 --- a/pkg/solana/codec/helpers.go +++ b/pkg/solana/codec/v1/helpers.go @@ -1,4 +1,4 @@ -package codec +package codecv1 import ( _ "embed" diff --git a/pkg/solana/codec/onramp_address.go b/pkg/solana/codec/v1/onramp_address.go similarity index 98% rename from pkg/solana/codec/onramp_address.go rename to pkg/solana/codec/v1/onramp_address.go index ff7cefa96..eb38abb39 100644 --- a/pkg/solana/codec/onramp_address.go +++ b/pkg/solana/codec/v1/onramp_address.go @@ -1,4 +1,4 @@ -package codec +package codecv1 import ( "fmt" diff --git a/pkg/solana/codec/solana.go b/pkg/solana/codec/v1/solana.go similarity index 99% rename from pkg/solana/codec/solana.go rename to pkg/solana/codec/v1/solana.go index 9af581a97..dd10b5e53 100644 --- a/pkg/solana/codec/solana.go +++ b/pkg/solana/codec/v1/solana.go @@ -17,7 +17,7 @@ supported at this time. Modifiers can be provided to assist in modifying property names, adding properties, etc. */ -package codec +package codecv1 import ( "encoding/json" @@ -31,7 +31,7 @@ import ( commonencodings "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) const ( diff --git a/pkg/solana/codec/solana_test.go b/pkg/solana/codec/v1/solana_test.go similarity index 92% rename from pkg/solana/codec/solana_test.go rename to pkg/solana/codec/v1/solana_test.go index a6089dc0f..4ccc3afb7 100644 --- a/pkg/solana/codec/solana_test.go +++ b/pkg/solana/codec/v1/solana_test.go @@ -1,4 +1,4 @@ -package codec_test +package codecv1_test import ( "encoding/json" @@ -14,9 +14,9 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/testutils" - 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/codec/v1/testutils" ) func TestNewIDLAccountCodec(t *testing.T) { @@ -95,7 +95,7 @@ func TestNewIDLCodec_WithModifiers(t *testing.T) { renameMod, err := modConfig.ToModifier(solcommoncodec.DecoderHooks...) require.NoError(t, err) - idlCodecWithMods, err := codec.NewNamedModifierCodec(idlCodec, testutils.TestStructWithNestedStruct, renameMod) + idlCodecWithMods, err := codecv1.NewNamedModifierCodec(idlCodec, testutils.TestStructWithNestedStruct, renameMod) require.NoError(t, err) type modifiedTestStruct struct { @@ -155,13 +155,13 @@ func TestNewIDLCodec_WithModifiers(t *testing.T) { func TestNewIDLCodec_CircularDependency(t *testing.T) { t.Parallel() - var idl codec.IDL + var idl codecv1.IDL if err := json.Unmarshal([]byte(testutils.CircularDepIDL), &idl); err != nil { t.Logf("failed to unmarshal test IDL: %s", err.Error()) t.FailNow() } - _, err := codec.NewIDLAccountCodec(idl, binary.LittleEndian()) + _, err := codecv1.NewIDLAccountCodec(idl, binary.LittleEndian()) assert.ErrorIs(t, err, types.ErrInvalidConfig) } @@ -175,7 +175,7 @@ const ( eventIDLType idlType = "event" ) -func newTestIDLAndCodec(t *testing.T, idlTP idlType) (string, codec.IDL, types.RemoteCodec) { +func newTestIDLAndCodec(t *testing.T, idlTP idlType) (string, codecv1.IDL, types.RemoteCodec) { t.Helper() var idlDef string @@ -189,7 +189,7 @@ func newTestIDLAndCodec(t *testing.T, idlTP idlType) (string, codec.IDL, types.R idlDef = defs.IDL } - var idl codec.IDL + var idl codecv1.IDL if err := json.Unmarshal([]byte(idlDef), &idl); err != nil { t.Logf("failed to unmarshal test IDL: %s", err.Error()) t.FailNow() @@ -203,9 +203,9 @@ func newTestIDLAndCodec(t *testing.T, idlTP idlType) (string, codec.IDL, types.R //nolint:exhaustive switch idlTP { case accountIDLType: - entry, err = codec.NewIDLAccountCodec(idl, binary.LittleEndian()) + entry, err = codecv1.NewIDLAccountCodec(idl, binary.LittleEndian()) case definedTypesIDLType: - entry, err = codec.NewIDLDefinedTypesCodec(idl, binary.LittleEndian()) + entry, err = codecv1.NewIDLDefinedTypesCodec(idl, binary.LittleEndian()) } if err != nil { diff --git a/pkg/solana/codec/testutils/chainWriterTestIDL.json b/pkg/solana/codec/v1/testutils/chainWriterTestIDL.json similarity index 100% rename from pkg/solana/codec/testutils/chainWriterTestIDL.json rename to pkg/solana/codec/v1/testutils/chainWriterTestIDL.json diff --git a/pkg/solana/codec/testutils/circularDepIDL.json b/pkg/solana/codec/v1/testutils/circularDepIDL.json similarity index 100% rename from pkg/solana/codec/testutils/circularDepIDL.json rename to pkg/solana/codec/v1/testutils/circularDepIDL.json diff --git a/pkg/solana/codec/testutils/eventItemTypeIDL.json b/pkg/solana/codec/v1/testutils/eventItemTypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/eventItemTypeIDL.json rename to pkg/solana/codec/v1/testutils/eventItemTypeIDL.json diff --git a/pkg/solana/codec/testutils/itemArray1TypeIDL.json b/pkg/solana/codec/v1/testutils/itemArray1TypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/itemArray1TypeIDL.json rename to pkg/solana/codec/v1/testutils/itemArray1TypeIDL.json diff --git a/pkg/solana/codec/testutils/itemArray2TypeIDL.json b/pkg/solana/codec/v1/testutils/itemArray2TypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/itemArray2TypeIDL.json rename to pkg/solana/codec/v1/testutils/itemArray2TypeIDL.json diff --git a/pkg/solana/codec/testutils/itemIDL.json b/pkg/solana/codec/v1/testutils/itemIDL.json similarity index 100% rename from pkg/solana/codec/testutils/itemIDL.json rename to pkg/solana/codec/v1/testutils/itemIDL.json diff --git a/pkg/solana/codec/testutils/itemSliceTypeIDL.json b/pkg/solana/codec/v1/testutils/itemSliceTypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/itemSliceTypeIDL.json rename to pkg/solana/codec/v1/testutils/itemSliceTypeIDL.json diff --git a/pkg/solana/codec/testutils/nilTypeIDL.json b/pkg/solana/codec/v1/testutils/nilTypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/nilTypeIDL.json rename to pkg/solana/codec/v1/testutils/nilTypeIDL.json diff --git a/pkg/solana/codec/testutils/sizeItemTypeIDL.json b/pkg/solana/codec/v1/testutils/sizeItemTypeIDL.json similarity index 100% rename from pkg/solana/codec/testutils/sizeItemTypeIDL.json rename to pkg/solana/codec/v1/testutils/sizeItemTypeIDL.json diff --git a/pkg/solana/codec/testutils/testIDL.json b/pkg/solana/codec/v1/testutils/testIDL.json similarity index 100% rename from pkg/solana/codec/testutils/testIDL.json rename to pkg/solana/codec/v1/testutils/testIDL.json diff --git a/pkg/solana/codec/testutils/types.go b/pkg/solana/codec/v1/testutils/types.go similarity index 99% rename from pkg/solana/codec/testutils/types.go rename to pkg/solana/codec/v1/testutils/types.go index d96b6ada6..9e48b963c 100644 --- a/pkg/solana/codec/testutils/types.go +++ b/pkg/solana/codec/v1/testutils/types.go @@ -11,7 +11,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types/interfacetests" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) var ( diff --git a/pkg/solana/codecv2/codec_entry.go b/pkg/solana/codec/v2/codec_entry.go similarity index 98% rename from pkg/solana/codecv2/codec_entry.go rename to pkg/solana/codec/v2/codec_entry.go index 7ace3a4f5..f8e065b2a 100644 --- a/pkg/solana/codecv2/codec_entry.go +++ b/pkg/solana/codec/v2/codec_entry.go @@ -6,7 +6,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/codec" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) // No AccountIDLTypes, NewAccountEntry, NewPDAEntry required as chain_reader (codec based) has moved to chain_accessor (binding based) diff --git a/pkg/solana/codecv2/codec_entry_test.go b/pkg/solana/codec/v2/codec_entry_test.go similarity index 96% rename from pkg/solana/codecv2/codec_entry_test.go rename to pkg/solana/codec/v2/codec_entry_test.go index 47a2387b3..f7e394a83 100644 --- a/pkg/solana/codecv2/codec_entry_test.go +++ b/pkg/solana/codec/v2/codec_entry_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codecv2" + codecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v2" ) //go:embed testutils/data_storage.json diff --git a/pkg/solana/codecv2/helpers.go b/pkg/solana/codec/v2/helpers.go similarity index 100% rename from pkg/solana/codecv2/helpers.go rename to pkg/solana/codec/v2/helpers.go diff --git a/pkg/solana/codecv2/solana.go b/pkg/solana/codec/v2/solana.go similarity index 99% rename from pkg/solana/codecv2/solana.go rename to pkg/solana/codec/v2/solana.go index 747ece416..a63f2eef8 100644 --- a/pkg/solana/codecv2/solana.go +++ b/pkg/solana/codec/v2/solana.go @@ -13,7 +13,7 @@ import ( commonencodings "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" ) const ( diff --git a/pkg/solana/codecv2/solana_test.go b/pkg/solana/codec/v2/solana_test.go similarity index 97% rename from pkg/solana/codecv2/solana_test.go rename to pkg/solana/codec/v2/solana_test.go index 12d0c74d2..08a6ac07a 100644 --- a/pkg/solana/codecv2/solana_test.go +++ b/pkg/solana/codec/v2/solana_test.go @@ -9,8 +9,8 @@ import ( anchoridl "github.com/gagliardetto/anchor-go/idl" "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codecv2" - solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/commoncodec" + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" + codecv2 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v2" ) func TestCreateCodecEntry(t *testing.T) { diff --git a/pkg/solana/codecv2/testutils/chainWriterTestIDL.json b/pkg/solana/codec/v2/testutils/chainWriterTestIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/chainWriterTestIDL.json rename to pkg/solana/codec/v2/testutils/chainWriterTestIDL.json diff --git a/pkg/solana/codecv2/testutils/data_storage.json b/pkg/solana/codec/v2/testutils/data_storage.json similarity index 100% rename from pkg/solana/codecv2/testutils/data_storage.json rename to pkg/solana/codec/v2/testutils/data_storage.json diff --git a/pkg/solana/codecv2/testutils/eventItemTypeIDL.json b/pkg/solana/codec/v2/testutils/eventItemTypeIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/eventItemTypeIDL.json rename to pkg/solana/codec/v2/testutils/eventItemTypeIDL.json diff --git a/pkg/solana/codecv2/testutils/itemArray1TypeIDL.json b/pkg/solana/codec/v2/testutils/itemArray1TypeIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/itemArray1TypeIDL.json rename to pkg/solana/codec/v2/testutils/itemArray1TypeIDL.json diff --git a/pkg/solana/codecv2/testutils/itemArray2TypeIDL.json b/pkg/solana/codec/v2/testutils/itemArray2TypeIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/itemArray2TypeIDL.json rename to pkg/solana/codec/v2/testutils/itemArray2TypeIDL.json diff --git a/pkg/solana/codecv2/testutils/itemIDL.json b/pkg/solana/codec/v2/testutils/itemIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/itemIDL.json rename to pkg/solana/codec/v2/testutils/itemIDL.json diff --git a/pkg/solana/codecv2/testutils/itemSliceTypeIDL.json b/pkg/solana/codec/v2/testutils/itemSliceTypeIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/itemSliceTypeIDL.json rename to pkg/solana/codec/v2/testutils/itemSliceTypeIDL.json diff --git a/pkg/solana/codecv2/testutils/testIDL.json b/pkg/solana/codec/v2/testutils/testIDL.json similarity index 100% rename from pkg/solana/codecv2/testutils/testIDL.json rename to pkg/solana/codec/v2/testutils/testIDL.json diff --git a/pkg/solana/config/chain_reader.go b/pkg/solana/config/chain_reader.go index bce9f352a..5f58e5d79 100644 --- a/pkg/solana/config/chain_reader.go +++ b/pkg/solana/config/chain_reader.go @@ -8,7 +8,7 @@ import ( commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" ) const ( @@ -67,7 +67,7 @@ type ContractReader struct { } type ChainContractReader struct { - codec.IDL `json:"anchorIDL"` + codecv1.IDL `json:"anchorIDL"` *PollingFilter `json:"pollingFilter,omitempty"` // Reads key is the off-chain name for this read. Reads map[string]ReadDefinition `json:"reads"` @@ -97,7 +97,7 @@ type ReadDefinition struct { ErrOnMissingAccountData bool `json:"errOnMissingAccountData,omitempty"` InputModifications commoncodec.ModifiersConfig `json:"inputModifications,omitempty"` OutputModifications commoncodec.ModifiersConfig `json:"outputModifications,omitempty"` - PDADefinition codec.PDATypeDef `json:"pdaDefinition,omitempty"` // Only used for PDA account reads + PDADefinition codecv1.PDATypeDef `json:"pdaDefinition,omitempty"` // Only used for PDA account reads MultiReader *MultiReader `json:"multiReader,omitempty"` EventDefinitions *EventDefinitions `json:"eventDefinitions,omitempty"` // ResponseAddressHardCoder hardcodes the address of the contract into the defined field in the response. diff --git a/pkg/solana/config/chain_reader_test.go b/pkg/solana/config/chain_reader_test.go index 5afc1478c..5ca684592 100644 --- a/pkg/solana/config/chain_reader_test.go +++ b/pkg/solana/config/chain_reader_test.go @@ -11,9 +11,8 @@ import ( codeccommon "github.com/smartcontractkit/chainlink-common/pkg/codec" "github.com/smartcontractkit/chainlink-common/pkg/types" - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec" - - "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/testutils" + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" + "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1/testutils" "github.com/smartcontractkit/chainlink-solana/pkg/solana/config" ) @@ -93,11 +92,11 @@ func TestChainReaderConfig(t *testing.T) { }) } -var nilIDL = codec.IDL{ +var nilIDL = codecv1.IDL{ Version: "0.1.0", Name: "myProgram", - Accounts: codec.IdlTypeDefSlice{ - {Name: "NilType", Type: codec.IdlTypeDefTy{Kind: codec.IdlTypeDefTyKindStruct, Fields: &codec.IdlTypeDefStruct{}}}, + Accounts: codecv1.IdlTypeDefSlice{ + {Name: "NilType", Type: codecv1.IdlTypeDefTy{Kind: codecv1.IdlTypeDefTyKindStruct, Fields: &codecv1.IdlTypeDefStruct{}}}, }, } diff --git a/pkg/solana/logpoller/filters.go b/pkg/solana/logpoller/filters.go index 36d6f8260..da4d5a949 100644 --- a/pkg/solana/logpoller/filters.go +++ b/pkg/solana/logpoller/filters.go @@ -17,8 +17,8 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "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/logpoller/types" ) @@ -211,7 +211,7 @@ func (fl *filters) RegisterFilter(ctx context.Context, filter types.Filter) erro } func newDecoder(filter types.Filter) (types.Decoder, error) { - cEntry, err := codec.NewEventArgsEntry(filter.EventName, codec.EventIDLTypes(filter.EventIdl), true, nil, binary.LittleEndian()) + cEntry, err := codecv1.NewEventArgsEntry(filter.EventName, codecv1.EventIDLTypes(filter.EventIdl), true, nil, binary.LittleEndian()) if err != nil { return nil, err } diff --git a/pkg/solana/logpoller/log_poller_test.go b/pkg/solana/logpoller/log_poller_test.go index 889e06864..d8d6f0eea 100644 --- a/pkg/solana/logpoller/log_poller_test.go +++ b/pkg/solana/logpoller/log_poller_test.go @@ -22,7 +22,7 @@ import ( commoncfg "github.com/smartcontractkit/chainlink-common/pkg/config" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "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" "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/mocks" "github.com/smartcontractkit/chainlink-solana/pkg/solana/logpoller/types" @@ -373,8 +373,8 @@ func TestProcess(t *testing.T) { lp, err := New(lggr, orm, cl, config.NewDefault(), chainID) require.NoError(t, err) - var idlTypeInt64 codec.IdlType - var idlTypeString codec.IdlType + var idlTypeInt64 codecv1.IdlType + var idlTypeString codecv1.IdlType err = json.Unmarshal([]byte("\"i64\""), &idlTypeInt64) require.NoError(t, err) @@ -382,9 +382,9 @@ func TestProcess(t *testing.T) { require.NoError(t, err) idl := types.EventIdl{ - Event: codec.IdlEvent{ + Event: codecv1.IdlEvent{ Name: "myEvent", - Fields: []codec.IdlEventField{{ + Fields: []codecv1.IdlEventField{{ Name: "A", Type: idlTypeInt64, }, { @@ -392,7 +392,7 @@ func TestProcess(t *testing.T) { Type: idlTypeString, }}, }, - Types: []codec.IdlTypeDef{}, + Types: []codecv1.IdlTypeDef{}, } filter := types.Filter{ diff --git a/pkg/solana/logpoller/orm_test.go b/pkg/solana/logpoller/orm_test.go index 9f0458686..5ebeaef71 100644 --- a/pkg/solana/logpoller/orm_test.go +++ b/pkg/solana/logpoller/orm_test.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/sqlutil/sqltest" "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/logpoller/types" ) @@ -39,12 +39,12 @@ func TestLogPollerFilters(t *testing.T) { StartingBlock: 1, SubkeyPaths: types.SubKeyPaths([][]string{{"a", "b"}, {"c"}}), EventIdl: types.EventIdl{ - Event: codec.IdlEvent{ + Event: codecv1.IdlEvent{ Name: "MyEvent", - Fields: []codec.IdlEventField{{Name: "MyField", Type: codec.NewIdlStringType(codec.IdlTypeDuration), Index: true}}, + Fields: []codecv1.IdlEventField{{Name: "MyField", Type: codecv1.NewIdlStringType(codecv1.IdlTypeDuration), Index: true}}, }, - Types: codec.IdlTypeDefSlice{ - {Name: "NilType", Type: codec.IdlTypeDefTy{Kind: codec.IdlTypeDefTyKindStruct, Fields: &codec.IdlTypeDefStruct{}}}, + Types: codecv1.IdlTypeDefSlice{ + {Name: "NilType", Type: codecv1.IdlTypeDefTy{Kind: codecv1.IdlTypeDefTyKindStruct, Fields: &codecv1.IdlTypeDefStruct{}}}, }, }, Retention: 1000, diff --git a/pkg/solana/logpoller/types/types.go b/pkg/solana/logpoller/types/types.go index 2b718d789..7e3ab6edf 100644 --- a/pkg/solana/logpoller/types/types.go +++ b/pkg/solana/logpoller/types/types.go @@ -14,8 +14,8 @@ import ( "github.com/gagliardetto/solana-go" "github.com/lib/pq" - "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" ) type PublicKey solana.PublicKey @@ -148,7 +148,7 @@ type Decoder interface { Decode(_ context.Context, raw []byte, into any, itemType string) error } -type EventIdl codec.EventIDLTypes +type EventIdl codecv1.EventIDLTypes func (e *EventIdl) Scan(src interface{}) error { return scanJSON("EventIdl", e, src) diff --git a/pkg/solana/utils/utils.go b/pkg/solana/utils/utils.go index 21a74705f..6f578a190 100644 --- a/pkg/solana/utils/utils.go +++ b/pkg/solana/utils/utils.go @@ -8,7 +8,7 @@ import ( commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" - 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/internal" )