Skip to content

Commit

Permalink
Use lenient codec from type codec to allow extra bits (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolag committed Apr 23, 2024
1 parent 59d47c7 commit b9eefe1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
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

0 comments on commit b9eefe1

Please sign in to comment.