Skip to content

feat: add specific return types for BlockWithTxs and BlockWithTxHashes#841

Open
bimakw wants to merge 1 commit intoNethermindEth:mainfrom
bimakw:feat/specific-return-types-block-355
Open

feat: add specific return types for BlockWithTxs and BlockWithTxHashes#841
bimakw wants to merge 1 commit intoNethermindEth:mainfrom
bimakw:feat/specific-return-types-block-355

Conversation

@bimakw
Copy link
Copy Markdown

@bimakw bimakw commented Jan 7, 2026

Summary

  • Replace interface{} return type with specific interface types for BlockWithTxs and BlockWithTxHashes
  • Add BlockWithTxsResult interface (returns *Block or *PreConfirmedBlock)
  • Add BlockWithTxHashesResult interface (returns *BlockTxHashes or *PreConfirmedBlockTxHashes)
  • Uses Go's sealed type union pattern with unexported marker methods

This improves type safety and IDE autocomplete while maintaining backward compatibility.

Changes

  • rpc/types_block.go: Add result interfaces with marker methods
  • rpc/block.go: Update return types
  • rpc/provider.go: Update RPCProvider interface
  • internal/tests/mocks/rpcv10mock/rpc.go: Regenerated mock

Test plan

  • go build ./... passes
  • go test ./rpc/... -run TestBlockWithTx passes
  • go vet ./... passes
  • Mock regenerated with mockgen

Closes #355

Replace interface{} return type with specific interface types:
- BlockWithTxsResult for BlockWithTxs (returns *Block or *PreConfirmedBlock)
- BlockWithTxHashesResult for BlockWithTxHashes (returns *BlockTxHashes or *PreConfirmedBlockTxHashes)

This follows Go's sealed type union pattern with unexported marker methods,
improving type safety and IDE autocomplete while maintaining backward compatibility.

Closes NethermindEth#355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Specific return type for BlockWithTxs and BlockWithTxHashes methods

1 participant