Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lenient codec from type codec to allow extra bits #667

Merged
merged 1 commit into from
Apr 23, 2024
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
7 changes: 3 additions & 4 deletions pkg/solana/chainreader/chain_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/solana/codec/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/solana/codec/solana_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading