Skip to content

Commit

Permalink
Add MustEmbed Constraint to Contract Reader (#801)
Browse files Browse the repository at this point in the history
Reintroducing the must embed constraint to `ContractReader` implementations to
ensure that all implementations of `ContractReader` embed the `UnimplementedContractReader`.

If an implementation contains the unemplemented struct, changes to the interface
will flow down to all implementations without introducing breaking changes.
  • Loading branch information
EasterTheBunny authored and cedric-cordenier committed Oct 4, 2024
1 parent ba2d2f2 commit 2ed5fc2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/types/contract_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type ContractReader interface {

// QueryKey provides fetching chain agnostic events (Sequence) with general querying capability.
QueryKey(ctx context.Context, contract BoundContract, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]Sequence, error)

mustEmbedUnimplementedContractReader()
}

// BatchGetLatestValuesRequest string is contract name.
Expand Down Expand Up @@ -163,3 +165,5 @@ func (UnimplementedContractReader) Name() string {
func (UnimplementedContractReader) Ready() error {
return UnimplementedError("ContractReader.Ready unimplemented")
}

func (UnimplementedContractReader) mustEmbedUnimplementedContractReader() {}

0 comments on commit 2ed5fc2

Please sign in to comment.