-
Notifications
You must be signed in to change notification settings - Fork 11
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
refactor: use generic trait bound for RpcClient #483
Conversation
🦋 Changeset detectedLatest commit: 5225095 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks LGTM overall, just one change request:
Please use the same approach (unit vs integration test) for testing the client in edr_rpc_client
and edr_rpc_eth
, unless I'm missing a reason not to. I don't have strong views which is preferable here, but I like to default to unit tests due to easier code sharing.
In the
|
Ok so there is a hard reason why client tests in I can see why you implemented client tests as "integration tests" in |
The main benefit I see is separation of the tests into dedicated test files, instead of either being interspersed with source files or resulting in incredibly long source files with a I'm happy to move the tests into the client.rs source file if it hampers your dev experience, though. Changed in 5225095 |
Awesome thanks! We can move the tests to a submodule |
This PR splits off the
RpcClient
into two separate crates:edr_rpc_client
: contains a genericised version ofRpcClient
that accepts any type which implements thetrait RpcMethod
. AsRpcClient
's caching mechanism requires knowledge about the block number and chain ID I added thechain_id_request
andblock_number_request
methods totrait RpcMethod
, alongside an associated type that specifies theCacheableMethod
type.The
RpcClient
type can be reused by chain types with varying JSON-RPC methods, as listed here.edr_rpc_eth
: introduces anEthRpcClient
for all chains that support the Ethereum L1 JSON-RPC specification. It allows variance in theBlock
andTransaction
types, but this could be extended toReceipt
or other types as necessary. It's main goal is to avoid duplication ofpub enum RequestMethod
between Optimism, Arbitrum, Ethereum L1.Alternatively to the
block_number_request
andchain_id_request
methods in 1, they could be reworked toblock_number_without_caching
andchain_id_without_caching
.