From b9eefe1a829741233b44967f7aeda2fe144091be Mon Sep 17 00:00:00 2001 From: Ryan Tinianov Date: Tue, 23 Apr 2024 13:41:17 -0400 Subject: [PATCH] Use lenient codec from type codec to allow extra bits (#667) --- pkg/solana/chainreader/chain_reader_test.go | 7 +++---- pkg/solana/codec/solana.go | 6 +++--- pkg/solana/codec/solana_test.go | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/solana/chainreader/chain_reader_test.go b/pkg/solana/chainreader/chain_reader_test.go index dd4b4ebc7..7df246214 100644 --- a/pkg/solana/chainreader/chain_reader_test.go +++ b/pkg/solana/chainreader/chain_reader_test.go @@ -18,7 +18,6 @@ import ( "github.com/stretchr/testify/require" codeccommon "github.com/smartcontractkit/chainlink-common/pkg/codec" - "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" "github.com/smartcontractkit/chainlink-common/pkg/logger" commontestutils "github.com/smartcontractkit/chainlink-common/pkg/loop/testutils" @@ -263,7 +262,7 @@ func TestSolanaChainReaderService_GetLatestValue(t *testing.T) { }) } -func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, encodings.CodecFromTypeCodec) { +func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, types.RemoteCodec) { t.Helper() var idl codec.IDL @@ -283,7 +282,7 @@ func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, encodings.CodecFromTyp return testutils.JSONIDLWithAllTypes, idl, entry } -func newTestConfAndCodec(t *testing.T) (encodings.CodecFromTypeCodec, config.ChainReader) { +func newTestConfAndCodec(t *testing.T) (types.RemoteCodec, config.ChainReader) { t.Helper() rawIDL, _, testCodec := newTestIDLAndCodec(t) @@ -714,7 +713,7 @@ func (r *chainReaderInterfaceTester) MaxWaitTimeForEvents() time.Duration { return maxWaitTime } -func makeTestCodec(t *testing.T, rawIDL string, encoding config.EncodingType) encodings.CodecFromTypeCodec { +func makeTestCodec(t *testing.T, rawIDL string, encoding config.EncodingType) types.RemoteCodec { t.Helper() var idl codec.IDL diff --git a/pkg/solana/codec/solana.go b/pkg/solana/codec/solana.go index aecdbf612..fc28beb65 100644 --- a/pkg/solana/codec/solana.go +++ b/pkg/solana/codec/solana.go @@ -61,8 +61,8 @@ func NewNamedModifierCodec(original types.RemoteCodec, itemType string, modifier } // NewIDLCodec is for Anchor custom types -func NewIDLCodec(idl IDL, builder encodings.Builder) (encodings.CodecFromTypeCodec, error) { - accounts := make(map[string]encodings.TypeCodec) +func NewIDLCodec(idl IDL, builder encodings.Builder) (types.RemoteCodec, error) { + accounts := make(encodings.LenientCodecFromTypeCodec) refs := &codecRefs{ builder: builder, @@ -86,7 +86,7 @@ func NewIDLCodec(idl IDL, builder encodings.Builder) (encodings.CodecFromTypeCod accounts[name] = accCodec } - return encodings.CodecFromTypeCodec(accounts), nil + return accounts, nil } type codecRefs struct { diff --git a/pkg/solana/codec/solana_test.go b/pkg/solana/codec/solana_test.go index 73bcf28d8..403abed02 100644 --- a/pkg/solana/codec/solana_test.go +++ b/pkg/solana/codec/solana_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" codeccommon "github.com/smartcontractkit/chainlink-common/pkg/codec" - "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings/binary" "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" @@ -119,7 +118,7 @@ func TestNewIDLCodec_CircularDependency(t *testing.T) { assert.ErrorIs(t, err, types.ErrInvalidConfig) } -func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, encodings.CodecFromTypeCodec) { +func newTestIDLAndCodec(t *testing.T) (string, codec.IDL, types.RemoteCodec) { t.Helper() var idl codec.IDL