Skip to content

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Sep 9, 2025

createFetchMiddleware needs to declare that it takes an RpcService, but it cannot get a type from @metamask/network-controller or else this would create a circular dependency. Currently this package contains a copy of AbstractRpcService from @metamask/network-controller 22.2.0, but there are a couple of problems: 1) this type is not compatible with the latest version of the package, and 2) we want to avoid further incompatibilities in the future.

This PR changes the signature for createFetchMiddleware so that it requires a simplified version of RpcService, that is, one that only contains a request method. It also upgrades the dev dependency on @metamask/network-controller to 24.1.0.

Now that `createFetchMiddleware` takes an `RpcService`, there is no need
for it to take its old signature (`fetch`, `btoa`, `rpcUrl`, and
`originHttpHeaderKey`), and there is no need for the old logic (as that
has been integrated into `RpcService`).
The only change that affects this package is in 11.3.0, where some types
were changed so that if they take a type parameter that `extends Json`,
they default to `Json` itself. Because of our lint rules that forced
some changes in this PR itself. There should be no backward-incompatible
changes, however.

`object` is deprecated, so we do need to adapt to that at some point,
but we can address that in a future PR.
@mcmire mcmire force-pushed the simplify-rpc-service-type branch from c7c864b to 96412cf Compare September 9, 2025 20:13
@mcmire mcmire changed the base branch from remove-deprecated-fetch-signature to main September 9, 2025 20:14
`createFetchMiddleware` needs to declare that it takes an `RpcService`,
but it cannot get a type from `@metamask/network-controller` or else
this would create a circular dependency. Currently this package contains
a copy of `AbstractRpcService` from `@metamask/network-controller`
22.2.0, but there are a couple of problems: 1) this type is not
compatible with the latest version of the package, and 2) we want to
avoid further incompatibilities in the future.

This PR changes the signature for `createFetchMiddleware` so that it
requires a simplified version of `RpcService` — one that only contains a
`request` method. It also upgrades the dev dependency on
`@metamask/network-controller` to 24.1.0.
@mcmire mcmire force-pushed the simplify-rpc-service-type branch from 96412cf to 545b910 Compare September 9, 2025 20:18
@mcmire mcmire closed this Sep 10, 2025
@mcmire mcmire deleted the simplify-rpc-service-type branch September 10, 2025 13:24
@mcmire mcmire restored the simplify-rpc-service-type branch September 10, 2025 13:25
@mcmire mcmire deleted the simplify-rpc-service-type branch September 10, 2025 13:25
@mcmire mcmire restored the simplify-rpc-service-type branch September 10, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant