All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Bump
@metamask/json-rpc-enginefrom^10.2.4to^10.3.0(#8661)
- Expose missing public
NetworkControllermethods through its messenger (#8350)- The following actions are now available:
NetworkController:enableRpcFailoverNetworkController:disableRpcFailoverNetworkController:getProviderAndBlockTrackerNetworkController:getNetworkClientRegistryNetworkController:initializeProviderNetworkController:lookupNetworkNetworkController:lookupNetworkByClientIdNetworkController:get1559CompatibilityWithNetworkClientIdNetworkController:resetConnectionNetworkController:rollbackToPreviousProviderNetworkController:loadBackup
- Corresponding action types are available as well.
- The following actions are now available:
- Add
getEthQuerymethod toNetworkController(#8350)
- Bump
@metamask/controller-utilsfrom^11.19.0to^11.20.0(#8344) - Bump
@metamask/eth-json-rpc-middlewarefrom^23.1.1to^23.1.3(#8550, #8611) - Bump
@metamask/messengerfrom^1.0.0to^1.2.0(#8364, #8373, #8632) - Bump
@metamask/base-controllerfrom^9.0.1to^9.1.0(#8457)
NetworkControllerGetNetworkConfigurationByNetworkClientIdtype is deprecated in favor ofNetworkControllerGetNetworkConfigurationByNetworkClientIdAction(#8350)- Deprecate
AbstractRpcServiceandRpcServiceRequestable(#8475)- There are no equivalents to these interfaces. If you need to take an "RPC-service-like" argument, it's best to declare which properties you're interested in rather than accepting the entire RPC service interface.
- Restore retries for failed requests even if the user is offline, preventing a bad user experience if the reported offline status is inaccurate or stuck (#8623)
- Bump
@metamask/base-controllerfrom^9.0.0to^9.0.1(#8317) - Bump
@metamask/connectivity-controllerfrom^0.1.0to^0.2.0(#8317) - Bump
@metamask/eth-json-rpc-middlewarefrom^23.1.0to^23.1.1(#8317) - Bump
@metamask/eth-json-rpc-providerfrom^6.0.0to^6.0.1(#8317) - Bump
@metamask/messengerfrom^0.3.0to^1.0.0(#8317) - Bump
@metamask/json-rpc-enginefrom^10.2.2to^10.2.4(#8078, #8317)
- Add
rpcMethodNametoNetworkController:rpcEndpointDegradedandNetworkController:rpcEndpointChainDegradedevent payloads (#7954)- This field contains the JSON-RPC method name (e.g.
eth_blockNumber) that was being processed when the event fired, enabling identification of which methods produce the most slow requests or retry exhaustions.
- This field contains the JSON-RPC method name (e.g.
- Add
typeandretryReasontoNetworkController:rpcEndpointDegradedandNetworkController:rpcEndpointChainDegradedevent payloads (#7988)type(DegradedEventType) is'slow_success'when the request succeeded but was slow, or'retries_exhausted'when retries ran out.retryReason(RetryReason, only present whentypeis'retries_exhausted') classifies the error that was retried (e.g.'non_successful_http_status','timed_out','connection_failed').
- BREAKING: The
RpcServiceRequestabletype'sonDegradedlistener now receivesrpcMethodName: stringin its data parameter (#7954)- Implementors of this interface will need to accept the new field in their
onDegradedcallback signature.
- Implementors of this interface will need to accept the new field in their
- Bump
@metamask/eth-json-rpc-middlewarefrom^23.0.0to^23.1.0(#7810) - Bump
@metamask/json-rpc-enginefrom^10.2.1to^10.2.2(#7856) - Bump
@metamask/controller-utilsfrom^11.18.0to^11.19.0(#7995)
- Add dependency
@metamask/connectivity-controller^0.1.0(#7642)
- Bump
@metamask/eth-block-trackerfrom^15.0.0to^15.0.1(#7642) - Bump
@metamask/json-rpc-enginefrom^10.2.0to^10.2.1(#7642) - Bump
@metamask/eth-json-rpc-middlewarefrom^22.0.1to^23.0.0(#7634) - BREAKING: NetworkController now requires
ConnectivityController:getStateaction handler to be registered on the messenger (#7627)- The
NetworkControllernow depends on theConnectivityControllerto prevent retries and suppress events when the user is offline. - When offline,
NetworkController:rpcEndpointUnavailableandNetworkController:rpcEndpointDegradedevents are suppressed since retries don't occur and circuit breakers don't trigger. - You must register a
ConnectivityController:getStateaction handler on your root messenger that returns an object with aconnectivityStatusproperty ('online'or'offline'). - You must delegate the
ConnectivityController:getStateaction from your root messenger to theNetworkControllerMessengerusingrootMessenger.delegate({ messenger: networkControllerMessenger, actions: ['ConnectivityController:getState'] }).
- The
- Corrects the previous 27.2.0 release to document breaking changes that were missed:
- BREAKING: Remove dependency on
@metamask/error-reporting-service(#7542)ErrorReportingService:captureExceptionis no longer an allowed action on the NetworkController messenger. You do not need to delegate itsErrorReportingService:captureExceptionaction to the NetworkController messenger.
- BREAKING: Remove dependency on
27.2.0 [DEPRECATED]
- Upgrade
@metamask/utilsfrom^11.8.1to^11.9.0(#7511) - Remove dependency on
@metamask/error-reporting-service(#7542)- The service no longer needs
ErrorReportingService:captureException.
- The service no longer needs
- Bump
@metamask/controller-utilsfrom^11.17.0to^11.18.0(#7583)
- Add MegaETH Testnet "v2" as a default custom network (#7272)
- The URL for this is
https://timothy.megaeth.com/rpcrather thanhttps://carrot.megaeth.com/rpc, and the chain ID has changed from0x18c6to0x18c7. - "v1" of this network has not been removed.
- The URL for this is
- Bump
@metamask/eth-json-rpc-middlewarefrom^22.0.0to^22.0.1(#7330) - Bump
@metamask/controller-utilsfrom^11.16.0to^11.17.0(#7534)
- Ensure
get1559CompatibilityWithNetworkClientIdupdates network metadata with EIP-1559 compatibility data missing (#7532)
- Add
NetworkController:rpcEndpointChainAvailablemessenger event (#7166)- This is a counterpart to the (new)
NetworkController:rpcEndpointChainUnavailableandNetworkController:rpcEndpointChainDegradedevents, but is published when a successful request to an endpoint within a chain of endpoints is made either initially or following a previously established degraded or unavailable status.
- This is a counterpart to the (new)
- Update
networksMetadatastate property so that networks can now have a possible status ofdegraded(#7186)
- BREAKING: Split up and update payload data for
NetworkController:rpcEndpointDegradedandNetworkController:rpcEndpointUnavailable(#7166)NetworkController:rpcEndpointDegradedandNetworkController:rpcEndpointUnavailablestill exist and retain the same behavior as before.- New events are
NetworkController:rpcEndpointChainDegradedandNetworkController:rpcEndpointChainUnavailable, and are designed to represent an entire chain of endpoints. They are also guaranteed to not be published multiple times in a row. In particular,NetworkController:rpcEndpointChainUnavailableis published only after trying all of the endpoints for a chain and when the underlying circuit for the last endpoint breaks, not as each primary's or failover's circuit breaks. - The event payloads have been changed:
- For individual endpoint events (
NetworkController:rpcEndpointUnavailable,NetworkController:rpcEndpointDegraded):failoverEndpointUrlhas been removed, andprimaryEndpointUrlhas been added. In addition,networkClientIdhas been added to the payload. - For chain-level events (
NetworkController:rpcEndpointChainUnavailable,NetworkController:rpcEndpointChainDegraded,NetworkController:rpcEndpointChainAvailable): These includechainId,networkClientId, and event-specific fields (e.g.,error,endpointUrl) but do not includeprimaryEndpointUrl. Consumers can derive endpoint information from thenetworkClientIdusingNetworkController:getNetworkClientByIdorNetworkController:getNetworkConfigurationByNetworkClientId.
- For individual endpoint events (
- BREAKING: Rename and update payload data for
NetworkController:rpcEndpointRequestRetried(#7166)- This event is now called
NetworkController:rpcEndpointRetried. - The event payload has been changed as well:
failoverEndpointUrlhas been removed, andprimaryEndpointUrlhas been added. In addition,networkClientIdandattempthave been added to the payload.
- This event is now called
- BREAKING: Update
AbstractRpcService/RpcServiceRequestableto remove{ isolated: true }from theonBreakevent data type (#7166)- This represented the error produced when
isolateis called on a Cockatiel circuit breaker policy. This never happens for our service (we useisolateinternally, but this error is suppressed and cannot triggeronBreak)
- This represented the error produced when
- Move peer dependencies for controller and service packages to direct dependencies (#7209)
- The dependencies moved are:
@metamask/error-reporting-service(^3.0.0)
- In clients, it is now possible for multiple versions of these packages to exist in the dependency tree.
- For example, this scenario would be valid: a client relies on
@metamask/controller-a1.0.0 and@metamask/controller-b1.0.0, and@metamask/controller-bdepends on@metamask/controller-a1.1.0.
- For example, this scenario would be valid: a client relies on
- Note, however, that the versions specified in the client's
package.jsonalways "win", and you are expected to keep them up to date so as not to break controller and service intercommunication.
- The dependencies moved are:
- Automatically update network status metadata when chain-level RPC events are published (#7186)
NetworkControllernow automatically subscribes toNetworkController:rpcEndpointChainUnavailable,NetworkController:rpcEndpointChainDegraded, andNetworkController:rpcEndpointChainAvailableevents and updates the corresponding network's status metadata in state when these events are published.- This enables real-time network status updates without requiring explicit
lookupNetworkcalls, providing more accurate and timely network availability information.
- Add infura supported networks (#6972)
- Bump
@metamask/json-rpc-enginefrom^10.1.1to^10.2.0(#7202) - Bump
@metamask/eth-json-rpc-providerfrom^5.0.1to^6.0.0(#7202) - Bump
@metamask/eth-json-rpc-middlewarefrom^21.0.0to^22.0.0(#7202) - Bump
@metamask/eth-block-trackerfrom^14.0.0to^15.0.0(#7202) - BREAKING: Use
InternalProviderinstead ofSafeEventEmitterProvider(#6796)- Providers accessible either via network clients or global proxies no longer emit events (or inherit from EventEmitter, for that matter).
- BREAKING: Make
Providertype more specific (#7061)- The
Providertype is now anInternalProviderwith a context type of{ origin: string; skipCache: boolean } & Record<string, unknown>.
- The
- BREAKING: Stop retrying
undefinedresults for methods that include a block tag parameter (#7001)- The network client middleware, via
@metamask/eth-json-rpc-middleware, will now throw an error if it encounters anundefinedresult when dispatching a request with a later block number than the originally requested block number. - In practice, this should happen rarely if ever.
- The network client middleware, via
- BREAKING: Migrate
NetworkClienttoJsonRpcEngineV2(#7065)- This ought to be unobservable, but we mark it as breaking out of an abundance of caution.
- BREAKING: Update signature of
requestinAbstractRpcServiceandRpcServiceRequestableso that the JSON-RPC request must be frozen (#7138) - Bump
@metamask/controller-utilsfrom^11.15.0to^11.16.0(#7003, #7202)
- Ensure
networksMetadatanever references old network client IDs (#7047)- When removing a network configuration, ensure that metadata for all RPC endpoints in the network configuration are also removed from
networksMetadata - When initializing the controller, remove metadata for RPC endpoints in
networksMetadatathat are not present in a network configuration
- When removing a network configuration, ensure that metadata for all RPC endpoints in the network configuration are also removed from
- BREAKING: Use new
Messengerfrom@metamask/messenger(#6386)- Previously,
NetworkControlleraccepted aRestrictedMessengerinstance from@metamask/base-controller.
- Previously,
- BREAKING: Bump
@metamask/error-reporting-servicefrom^2.0.0to^3.0.0(#6962) - Bump
@metamask/base-controllerfrom^8.4.2to^9.0.0(#6962)
- Bump
@metamask/base-controllerfrom^8.4.1to^8.4.2(#6917)
- Bump
@metamask/eth-json-rpc-middlewarefrom^19.0.1to^21.0.0(#6866, #6883) - Bump
@metamask/eth-block-trackerfrom^13.0.0to^14.0.0(#6883)
- Bump
@metamask/eth-block-trackerfrom^12.0.1to^12.2.1(#6811) - Bump
@metamask/eth-json-rpc-infurafrom^10.2.0to^10.3.0(#6811) - Bump
@metamask/eth-json-rpc-middlewarefrom^18.0.0to^19.0.1(#6811)
- Bump
@metamask/utilsfrom^11.8.0to^11.8.1(#6708) - Update
@metamask/eth-json-rpc-middlewarefrom^17.0.1to^18.0.0(#6714) - Bump
@metamask/error-reporting-servicefrom^2.1.0to^2.2.0(#6782) - Bump
@metamask/base-controllerfrom^8.4.0to^8.4.1(#6807) - Bump
@metamask/controller-utilsfrom^11.14.0to^11.14.1(#6807) - Bump
@metamask/eth-json-rpc-providerfrom^5.0.0to^5.0.1(#6807) - Bump
@metamask/json-rpc-enginefrom^10.1.0to^10.1.1(#6807)
- Add two new controller state metadata properties:
includeInStateLogsandusedInUi(#6525) - Add
lookupNetworkoption toinitializeProvider, to allow for skipping the request used to populate metadata for the globally selected network (#6575, #6607)- If
lookupNetworkis set tofalse, the function is fully synchronous, and does not return a promise.
- If
- Bump
@metamask/controller-utilsfrom^11.12.0to^11.14.0(#6620, #6629) - Bump
@metamask/base-controllerfrom^8.1.0to^8.4.0(#6355, #6465, #6632) - Rephrase "circuit broken" errors so they are more user-friendly (#6423)
- These are errors produced when a request is made to an RPC endpoint after it returns too many consecutive 5xx responses and the underlying circuit is open.
- Bump
@metamask/utilsfrom^11.4.2to^11.8.0(#6588) - Bump
@metamask/json-rpc-enginefrom^10.0.3to^10.1.0(#6678) - Bump
@metamask/eth-json-rpc-providerfrom^4.1.8to^5.0.0(#6678)
- Deprecate
lookupNetworkByClientId(#6308)lookupNetworkalready supports passing in a network client ID; please use this going forward instead.
- The object in the
NetworkController:rpcEndpointDegradedevent payload now includes anerrorproperty, which can be used to access the error produced by the last request when the maximum number of retries is exceeded (#6188)- This
errorproperty will beundefinedif the degraded event merely represents a slow request
- This
- Bump
@metamask/base-controllerfrom^8.0.1to^8.1.0(#6284) - Bump
@metamask/controller-utilsfrom^11.11.0to^11.12.0(#6303)- This effectively changes the
onDegradedproperty onAbstractRpcServiceso that the event listener payload may be an object with either aendpointUrlproperty,error+endpointUrlproperties, orvalue+endpointUrlproperties - NOTE: Although
errorandvalueare new, optional properties, this change makes an inadvertent breaking change to the signature of the event listener due to how TypeScript compares function types. We have conciously decided not to re-release this change under a major version, so be advised.
- This effectively changes the
- Requests to an RPC endpoint that returns a 502 response ("bad gateway") will now be retried (#5923)
- All JSON-RPC errors that represent 4xx and 5xx responses from RPC endpoints now include the HTTP status code under
data.httpStatus(#5923) - 3xx responses from RPC endpoints are no longer treated as errors (#5923)
- Bump
@metamask/controller-utilsfrom^11.10.0to^11.11.0(#6069) - Bump
@metamask/utilsfrom^11.2.0to^11.4.2(#6054)
- If an RPC endpoint returns invalid/unparseable JSON, it is now represented as a JSON-RPC error with code -32700 (parse error) instead of -32603 (internal error) (#5923)
- If an RPC endpoint returns a 401 response, it is now represented as a JSON-RPC error with code -32006 (unauthorized) instead of -32603 (internal error) (#5923)
- If an RPC endpoint returns a 405 response, it is now represented as a JSON-RPC error with code -32080 (client error) instead of -32601 (method not found) (#5923)
- If an RPC endpoint returns a 402, 404, or 5xx response, it is now represented as a JSON-RPC error with code -32002 (resource unavailable error) instead of -32603 (internal error) (#5923)
- If an RPC endpoint returns a 4xx response besides 401, 402, 404, 405, or 429, it is now represented as a JSON-RPC error with code -32080 (client error) instead of -32603 (internal error) (#5923)
- Improve detection of partial JSON responses from RPC endpoints (#5923)
- Fix "Request cannot be constructed from a URL that includes credentials" error when using RPC endpoints with embedded credentials (#6116)
- BREAKING: Remove
@metamask/error-reporting-service@^1.0.0as a direct dependency, add^2.0.0as a peer dependency (#5970, #5999)
- Add Base network to default infura networks (#5902)
- Network changes were added in
@metamask/controller-utils
- Network changes were added in
- Bump
@metamask/controller-utilsto^11.10.0(#5935)
- BREAKING: NetworkController messenger now requires the
ErrorReportingService:captureExceptionaction to be allowed (#5970)- This change was originally missed when this release was created. It was added to the changelog afterward.
- Block tracker errors will no longer be wrapped under "PollingBlockTracker - encountered an error while attempting to update latest block" (#5860)
- Bump dependencies (#5867, #5860)
- Bump
@metamask/eth-block-trackerto^12.0.1 - Bump
@metamask/eth-json-rpc-infurato^10.2.0 - Bump
@metamask/eth-json-rpc-middlewareto^17.0.1
- Bump
- Rather than throwing an error, NetworkController now corrects an invalid initial
selectedNetworkClientIdto point to the default RPC endpoint of the first network sorted by chain ID (#5851) - Fix the block tracker so that it will now reject if an error is thrown while making the request instead of hanging (#5860)
- Remove obsolete
eth_getBlockByNumbererror handling for load balancer errors (#5808) - Bump
@metamask/controller-utilsto^11.9.0(#5812)
- Improved handling of HTTP status codes to prevent unnecessary circuit breaker triggers (#5798, #5809)
- HTTP 4XX responses (e.g. rate limit errors) will no longer trigger the circuit breaker policy.
- Add Monad Testnet as default network (#5724)
- Bump
@metamask/controller-utilsto^11.8.0(#5765)
- Add optional
getBlockTrackerOptionsargument to NetworkController constructor (#5702) - Add optional
rpcFailoverEnabledoption to NetworkController constructor (falseby default) (#5668) - Add
enableRpcFailoveranddisableRpcFailovermethods to NetworkController (#5668)
- Bump
@metamask/base-controllerfrom ^8.0.0 to ^8.0.1 (#5722) - Disable the RPC failover behavior by default (#5668)
- You are free to set the
failoverUrlsproperty on an RPC endpoint, but it won't have any effect - To enable this behavior, either pass
rpcFailoverEnabled: trueto the constructor or callenableRpcFailoverafter initialization
- You are free to set the
- Add optional
additionalDefaultNetworksoption toNetworkControllerconstructor (#5527)- This can be used to customize which custom networks the default
networkConfigurationsByChainIdincludes.
- This can be used to customize which custom networks the default
- Add
getSelectedChainIdmethod toNetworkController(#5516)- This is also callable via the messenger.
- Add
DEPRECATED_NETWORKSconstant (#5560)
- Remove Goerli and Linea Goerli from set of default networks (#5560)
- Note that if you do not pass any initial state to NetworkController, this means that
0x5and0xe704will no longer be keys innetworkConfigurationsByChainId. - We are not counting this as a breaking change because we don't make any guarantees about what keys are present in
networkConfigurationsByChainIdat runtime — only that they must be valid chain IDs. - If you want more of a guarantee, you are recommended to persist the NetworkController state and then pass it back through as initial state.
- Note that if you do not pass any initial state to NetworkController, this means that
- Update
RpcEndpointso thatfailoverUrlsis optional (#5561)- This property was introduced in 23.0.0 as a breaking change, but this change makes it non-breaking.
- Update
NetworkClientConfigurationso thatfailoverUrlsis optional (#5561)- This property was introduced in 23.0.0 as a breaking change, but this change makes it non-breaking.
- Bump
@metamask/controller-utilsto^11.7.0(#5583)
- Upgrade
@metamask/eth-json-rpc-infurato^10.1.1and@metamask/eth-json-rpc-infurato^16.0.1(#5573)- This fixes a bug where non-standard unsuccessful JSON-RPC errors were being ignored/discarded
- The
NetworkController:rpcEndpointDegradedmessenger event now has a newchainIdproperty in its data, which is the ID of the chain that the endpoint represents (#5517)
- Implement circuit breaker pattern when retrying requests to Infura and custom RPC endpoints (#5290)
- If the network is perceived to be unavailable after 5 attempts, further retries will be paused for 30 seconds.
- "Unavailable" means the following:
- A failure to reach the network (exact error depending on platform / HTTP client)
- The request responds with a non-JSON-parseable or non-JSON-RPC-compatible body
- The request returns a non-200 response
- Use exponential backoff / jitter when retrying requests to Infura and custom RPC endpoints (#5290)
- As requests are retried, the delay between retries will increase exponentially (using random variance to prevent bursts).
- Add support for automatic failover when Infura is unavailable (#5360)
- An Infura RPC endpoint can now be configured with a list of failover URLs via
failoverUrls. - If, after many attempts, an Infura network is perceived to be down, the list of failover URLs will be tried in turn.
- An Infura RPC endpoint can now be configured with a list of failover URLs via
- Add messenger action
NetworkController:rpcEndpointUnavailablefor responding to when a RPC endpoint becomes unavailable (see above) (#5492, #5501)- Also add associated type
NetworkControllerRpcEndpointUnavailableEvent.
- Also add associated type
- Add messenger action
NetworkController:rpcEndpointDegradedfor responding to when a RPC endpoint becomes degraded (#5492)- Also add associated type
NetworkControllerRpcEndpointDegradedEvent.
- Also add associated type
- Add messenger action
NetworkController:rpcEndpointRequestRetriedfor responding to when a RPC endpoint is retried following a retriable error (#5492)- Also add associated type
NetworkControllerRpcEndpointRequestRetriedEvent. - This is mainly useful for tests when mocking timers.
- Also add associated type
- Export
RpcServiceRequestabletype, which was previously namedAbstractRpcService(#5492) - Export
isConnectionErrorutility function (#5501)
- BREAKING:
NetworkControllerconstructor now takes a new required option,getRpcServiceOptions(#5290, #5492)- This can be used to customize how RPC services (which eventually hit RPC endpoints) are constructed.
- For instance, you could set one
circuitBreakDurationfor one class of endpoints, and anothercircuitBreakDurationfor another class. - At minimum you will need to pass
fetchandbtoa. - The
NetworkControllerOptionsalso reflects this change.
- BREAKING: Add required property
failoverUrlstoRpcEndpoint(#5360)- The
NetworkControllerStateand thestateoption toNetworkControlleralso reflect this change.
- The
- BREAKING: Add required property
failoverRpcUrlstoNetworkClientConfiguration(#5360)- The
configurationproperty in theAutoManagedNetworkClientandNetworkClienttypes also reflect this change.
- The
- BREAKING: The
AbstractRpcServicetype now has a non-optionalendpointUrlproperty (#5492)- The old version of
AbstractRpcServiceis now calledRpcServiceRequestable
- The old version of
- Synchronize retry logic and error handling behavior between Infura and custom RPC endpoints (#5290)
- A request to a custom endpoint that returns a 418 response will no longer return a JSON-RPC response with the error "Request is being rate limited".
- A request to a custom endpoint that returns a 429 response now returns a JSON-RPC response with the error "Request is being rate limited".
- A request to a custom endpoint that throws an "ECONNRESET" error will now be retried up to 5 times.
- A request to a Infura endpoint that fails more than 5 times in a row will now respond with a JSON-RPC error that encompasses the failure instead of hiding it as "InfuraProvider - cannot complete request. All retries exhausted".
- A request to a Infura endpoint that returns a non-retriable, non-2xx response will now respond with a JSON-RPC error that has the underling message "Non-200 status code: '<code>'" rather than including the raw response from the endpoint.
- A request to a custom endpoint that fails with a retriable error more than 5 times in a row will now respond with a JSON-RPC error that encompasses the failure instead of returning an empty response.
- A "retriable error" is now regarded as the following:
- A failure to reach the network (exact error depending on platform / HTTP client)
- The request responds with a non-JSON-parseable or non-JSON-RPC-compatible body
- The request returns a 503 or 504 response
- Bump dependencies to support usage of RPC services internally for network requests (#5290)
- Bump
@metamask/eth-json-rpc-infurato^10.1.0 - Bump
@metamask/eth-json-rpc-middlewareto^15.1.0
- Bump
- Bump
@metamask/controller-utilsto^11.5.0(#5439) - Bump
@metamask/utilsto^11.2.0(#5301)
- Fix
findNetworkClientIdByChainIdto return the network client ID for the chain's configured default RPC endpoint instead of its first listed RPC endpoint (#5344)
- Bump
@metamask/base-controllerfrom^7.1.1to^8.0.0(#5305)
- Export
AbstractRpcServicetype (#5263)
- Bump
@metamask/base-controllerfrom^7.0.0to^7.1.1(#5079, #5135) - Bump
@metamask/controller-utilsfrom^11.4.4to^11.5.0(#5135, #5272) - Bump
@metamask/eth-json-rpc-providerfrom^4.1.6to^4.1.8(#5082, #5272) - Bump
@metamask/json-rpc-enginefrom^10.0.1to^10.0.3(#5082, #5272) - Bump
@metamask/rpc-errorsfrom^7.0.1to^7.0.2(#5080) - Bump
@metamask/utilsfrom^10.0.0to^11.1.0(#5080, #5223)
- Fix
lookupNetworkso that it will no longer throw an error ifnetworkDidChangesubscriptions have been removed before it returns (#5116)- This error could occur if the NetworkController's messenger is cleared of subscriptions, as in a "destroy" step.
- Fix race condition so that after adding a new RPC endpoint to a network, it is possible to access the new endpoint inside of a
stateChangeevent listener viagetNetworkConfigurationByNetworkClientId(#5122) - Fix
selectAvailableNetworkClientIdsso that it is properly memoized (#5193)
- Bump
@metamask/eth-json-rpc-middlewarefrom^15.0.0to^15.0.1(#5037) - Bump
swappable-obj-proxyfrom^2.2.0to^2.3.0(#5036) - Bump
@metamask/eth-block-trackerfrom^11.0.2to^11.0.3(#5025)
- The
NetworkController:networkRemovedmessenger event will now be emitted when a network is removed (#4698) - Add messenger actions
NetworkController:addNetwork,NetworkController:removeNetwork, andNetworkController:updateNetworkwhich call the respective controller methods (#4698) - Add
lastUpdatedAtproperty to network configurations which will be set to the current time on addition or update (#4652)- This was added to support the upcoming network syncing feature.
- This property is optional and will be
undefinedfor existing network configurations that have not yet been updated.
- Add dependency
fast-deep-equal(#4652) - Bump
@metamask/controller-utilsfrom^11.4.3to^11.4.4(#5012)
- Remove dependency on Node builtin module
utilto ensure that@metamask/network-controllercan be used in a strict browser context (#3672) - Correct ESM-compatible build so that imports of the following packages that re-export other modules via
export *are no longer corrupted: (#5011)@metamask/eth-block-tracker@metamask/eth-json-rpc-infura@metamask/eth-json-rpc-middleware@metamask/eth-query@metamask/swappable-obj-proxyfast-deep-equal
getDefaultNetworkConfigurationsByChainIdreturns the updated display names for mainnet and linea.Ethereum Mainnetinstead ofMainnet, andLineainstead ofLinea Mainnet. (#4865)- Bump
@metamask/controller-utilsfrom^11.4.2to^11.4.3(#4915)
- Bump
@metamask/base-controllerfrom^7.0.1to^7.0.2(#4862) - Bump
@metamask/controller-utilsfrom^11.4.0to^11.4.2(#4862, #4870) - Bump
@metamask/eth-json-rpc-providerfrom^4.1.5to^4.1.6(#4862) - Bump
@metamask/json-rpc-enginefrom^10.0.0to^10.0.1(#4862) - Bump
@metamask/rpc-errorsfrom^7.0.0to^7.0.1(#4831)
- Corrects the previous 21.1.0 release to document breaking changes that were missed:
- BREAKING: Bump
@metamask/eth-block-trackerfrom^10.0.0to^11.0.2(#4769) - BREAKING: Bump
@metamask/eth-json-rpc-middlewarefrom^13.0.0to^15.0.0(#4769) - BREAKING: Bump
@metamask/json-rpc-enginefrom^9.0.3to^10.0.0(#4769) - BREAKING: Bump
@metamask/rpc-errorsfrom^6.3.1to^7.0.0(#4769) - BREAKING: Bump
@metamask/eth-json-rpc-infurafrom^9.1.0to^10.0.0(#4769) - Bump
@metamask/eth-json-rpc-providerfrom^4.1.4to^4.1.5(#4798)- This update was recorded in the v21.1.0 changelog, but is listed here again because that release has been deprecated.
- BREAKING: Bump
- Bump
@metamask/controller-utilsfrom^11.3.0to^11.4.0(#4834)
21.1.0 [DEPRECATED]
- Bump
@metamask/eth-json-rpc-providerfrom^4.1.4to^4.1.5(#4798)
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files (#4648)
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
exportsfield inpackage.jsonlinked to these files. This is an anti-pattern and was rightfully flagged by the "Are the Types Wrong?" tool as "masquerading as CJS". All of the ATTW checks now pass.
- Previously, this package shipped with only one variant of type declaration
files, and these files were only CommonJS-compatible, and the
- Remove chunk files (#4648)
- Previously, the build tool we used to generate JavaScript files extracted common code to "chunk" files. While this was intended to make this package more tree-shakeable, it also made debugging more difficult for our development teams. These chunk files are no longer present.
- BREAKING: Add
networkConfigurationsByChainIdtoNetworkState(type:Record<Hex, NetworkConfiguration>) (#4268)- This property replaces
networkConfigurations, and, as its name implies, organizes network configurations by chain ID rather than network client ID. - If no initial state or this property is not included in initial state, the default value of this property will now include configurations for known Infura networks (Mainnet, Goerli, Sepolia, Linea Goerli, Linea Sepolia, and Linea Mainnet) by default.
- This property replaces
- Add
getNetworkConfigurationByChainIdmethod,NetworkController:getNetworkConfigurationByChainIdmessenger action, andNetworkControllerGetNetworkConfigurationByNetworkClientIdtype (#4268) - Add
addNetwork, which replaces one half ofupsertNetworkConfigurationand can be used to add new network clients for a chain (#4268)- It's worth noting that this method now publishes a
NetworkController:networkAddedevent instead of calling atrackMetaMetricsEventcallback. It is expected that you will subscribe to this event and create a MetaMetrics event yourself.
- It's worth noting that this method now publishes a
- Add
updateNetwork, which replaces one half ofupsertNetworkConfigurationand can be used to recreate the network clients for an existing chain based on an updated configuration (#4268)- Note that it is not possible to remove the RPC endpoint from a network configuration that is currently represented by the globally selected network client. To prevent an error, you'll need to detect when such a removal is occurring and pass the
replacementSelectedRpcEndpointIndextoupdateNetwork. It will then switch to the designated RPC endpoint's network client on your behalf.
- Note that it is not possible to remove the RPC endpoint from a network configuration that is currently represented by the globally selected network client. To prevent an error, you'll need to detect when such a removal is occurring and pass the
- Add
removeNetwork, which replacesremoveNetworkConfigurationand can be used to remove existing network clients for a chain (#4268) - Add
getDefaultNetworkControllerStatefunction, which replacesdefaultStateand matches patterns in other controllers (#4268) - Add
RpcEndpointType,AddNetworkFields, andUpdateNetworkFieldstypes (#4268) - Add
getNetworkConfigurations,getAvailableNetworkClientIdsandselectAvailableNetworkClientIdsselectors (#4268)- These new selectors can be applied to messenger event subscriptions
- BREAKING: Replace
NetworkConfigurationtype with a new definition (#4268)- A network configuration no longer represents a single RPC endpoint but rather a collection of RPC endpoints that can all be used to interface with a single chain.
- The only property that has brought over to this type unchanged is
chainId. tickerhas been renamed tonativeCurrency.nicknamehas been renamed toname.rpcEndpointshas been added. This is an an array of objects, where each object has propertiesname(optional),networkClientId(optional),type, andurl.defaultRpcEndpointIndexhas been added. This must point to an entry inrpcEndpoints.- The block explorer URL is no longer located in
rpcPrefsand is no longer restricted to one:blockExplorerUrlshas been added along with a corresponding propertydefaultBlockExplorerUrlIndex, which must point to an entry inblockExplorerUrls. idhas been removed. Previously, this represented the ID of the network client associated with the network configuration. Since network clients are now created from RPC endpoints, the equivalent to this is thenetworkClientIdproperty on anRpcEndpoint.
- BREAKING: The network controller messenger must now allow the action
NetworkController:getNetworkConfigurationByChainId(#4268) - BREAKING: The network controller messenger must now allow the event
NetworkController:networkAdded(#4268) - BREAKING: The
NetworkControllerconstructor will now throw if the initial state provided is invalid (#4268)networkConfigurationsByChainIdcannot be empty.- The
chainIdof a network configuration innetworkConfigurationsByChainIdmust match the chain ID it is filed under. - The
defaultRpcEndpointIndexof a network configuration innetworkConfigurationsByChainIdmust point to an entry in itsrpcEndpoints. - The
defaultBlockExplorerUrlIndexof a network configuration innetworkConfigurationsByChainIdmust point to an entry in itsblockExplorerUrls. selectedNetworkClientIdmust match thenetworkClientIdof an RPC endpoint innetworkConfigurationsByChainId.
- BREAKING: Update
getNetworkConfigurationByNetworkClientIdso that when given an Infura network name (that is, a value fromInfuraNetworkType), it will return a masked version of the RPC endpoint URL for the associated Infura network (#4268)- If you want the unmasked version, you'll need the
urlproperty from the network client configuration, which you can get by callinggetNetworkClientByIdand then accessing theconfigurationproperty off of the network client.
- If you want the unmasked version, you'll need the
- BREAKING: Update
loadBackupto take and updatenetworkConfigurationsByChainIdinstead ofnetworkConfigurations(#4268) - Bump
@metamask/base-controllerfrom^6.0.2to^7.0.0(#4625, #4643) - Bump
@metamask/controller-utilsfrom^11.0.2to^11.2.0(#4639, #4651) - Bump
@metamask/eth-block-trackerfrom^9.0.3to^10.0.0(#4424) - Bump
@metamask/eth-json-rpc-middlewarefrom^12.1.1to^13.0.0(#4424)
- BREAKING: Remove
networkConfigurationsfromNetworkState, which has been replaced withnetworkConfigurationsByChainId(#4268) - BREAKING: Remove
upsertNetworkConfigurationandremoveNetworkConfiguration, which have been replaced withaddNetwork,updateNetwork, andremoveNetwork(#4268) - BREAKING: Remove
defaultStatevariable, which has been replaced with agetDefaultNetworkControllerStatefunction (#4268) - BREAKING: Remove
trackMetaMetricsEventoption from the NetworkController constructor (#4268)- Previously, this was used in
upsertNetworkConfigurationto create a MetaMetrics event when a new network was added. This can now be achieved by subscribing to theNetworkController:networkAddedevent and creating the event inside of the event handler.
- Previously, this was used in
upsertNetworkConfigurationnow accepts an optional id property on the NetworkConfiguration param. It allows a network configuration to have its rpcUrl updated in place when an id is specified, but only if that new rpcUrl does not already exist on a different network configuration. (#4614)- Bump
@metamask/eth-json-rpc-providerto^4.1.3(#4607) - Update TypeScript to 5.2.2 (#4576, #4584)
removeNetworkConfigurationnow throws an error if you attempt to remove the selected network (#4566)
- Newly export the following types:
AutoManagedNetworkClient,InfuraNetworkClientConfiguration,CustomNetworkClientConfiguration(#3645)
- Upgrade TypeScript version to
~5.0.4and setmoduleResolutionoption toNode16(#3645) - Bump
@metamask/base-controllerfrom^6.0.0to^6.0.2(#4517, #4544) - Bump
@metamask/controller-utilsfrom^11.0.0to^11.0.2(#4517, #4544) - Bump
@metamask/eth-json-rpc-providerfrom^4.1.0to^4.1.2(#4519, #4548) - Bump
@metamask/json-rpc-enginefrom^9.0.0to^9.0.2(#4517, #4544) - Bump
@metamask/rpc-errorsfrom^6.2.1to^6.3.1(#4516) - Bump
@metamask/utilsfrom^8.3.0to^9.1.0(#4516, #4529)
- Add a new
logargument to the constructor (#4440)- The new
logargument must be aLoggerobject from theloglevelpackage and will be used to log a message when we fail to connect to a network or the network responds with an unknown error
- The new
- BREAKING: Update
networksMetadatastate property so that the keys in the object will only ever be network client IDs and not RPC URLs (#4254)- Some keys could have been RPC URLs if the initial network controller state had a
providerConfigwith an emptyid, but sinceproviderConfigis being removed, that won't happen anymore.
- Some keys could have been RPC URLs if the initial network controller state had a
- Bump
@metamask/eth-block-trackerto^9.0.3(#4418) - Bump
@metamask/eth-json-rpc-providerto^4.1.0(#4508)
- BREAKING: Remove
providerConfigproperty from state along withProviderConfigtype andNetworkController:getProviderConfigmessenger action (#4254)- The best way to obtain the equivalent configuration object, e.g. to access the chain ID of the currently selected network, is to get
selectedNetworkClientIdfrom state, pass this to theNetworkController:getNetworkClientIdmessenger action, and then use theconfigurationproperty on the network client.
- The best way to obtain the equivalent configuration object, e.g. to access the chain ID of the currently selected network, is to get
- BREAKING: Bump minimum Node version to 18.18 (#3611)
- Bump
@metamask/base-controllerto^6.0.0(#4352) - Bump
@metamask/controller-utilsto^11.0.0(#4352) - Bump
@metamask/eth-json-rpc-providerto^4.0.0(#4352) - Bump
@metamask/json-rpc-engineto^9.0.0(#4352)
- Update from
eth-block-trackerto@metamask/eth-block-tracker^9.0.2, mitigating redundant polling loops (#4309)
- Export
BuiltInNetworkClientIdandCustomNetworkClientId(#4247)
- Bump
@metamask/eth-json-rpc-providerto^3.0.2(#4234) - Bump
@metamask/json-rpc-engineto^8.0.2(#4234) - Bump
@metamask/base-controllerto^5.0.2(#4232) - Bump
@metamask/controller-utilsto^9.1.0(#4153)
- Add
getSelectedNetworkClientmethod that returns the provider and blockTracker for the currently selected network but with a more easily used type thangetProviderAndBlockTracker(#4063) - Add
NetworkController:getSelectedNetworkClientaction (#4063)
getProviderAndBlockTrackeris now marked as deprecated and will be removed in a future release. (#4063)
- Fix
typesfield inpackage.json(#4047)
- BREAKING: Add ESM build (#3998)
- It's no longer possible to import files from
./distdirectly.
- It's no longer possible to import files from
- Add network client for Linea Sepolia (chain ID
0xe705) (#3995)- Bump
@metamask/eth-json-rpc-infurato^9.1.0to bring this change.
- Bump
- BREAKING: Bump
@metamask/base-controllerto^5.0.0(#4039)- This version has a number of breaking changes. See the changelog for more.
- Bump
@metamask/controller-utilsto^9.0.0(#4039)
- BREAKING: Narrow
NetworkControllerMessengertype parametersAllowedActionandAllowedEventfromstringtonever(#4031)- Allowlisting or using any external actions or events will now produce a type error.
- Bump
@metamask/controller-utilsto^8.0.4(#4007) - Bump
@metamask/eth-json-rpc-middlewareto^12.1.0(#3829) - Bump
@metamask/json-rpc-engineto^7.3.3(#4007) - Bump
@metamask/rpc-errorsto^6.2.1(#3970, #3954)
- The
setActiveNetworkmethod and action now supports built-in network types (#3764)- Previously this would only accept a network configuration ID. Now it will accept the type of a built-in network as well, using it like an ID. This lets you switch to a built-in or custom network with a single method/action.
- Deprecate the
setProviderTypemethod and action (#3764)- Use
setActiveNetworkinstead
- Use
- Bump
@metamask/swappable-obj-proxyto^2.2.0(#3784) - Bump
@metamask/utilsto^8.3.0(#3769) - Bump
@metamask/base-controllerto^4.1.1(#3760, #3821) - Bump
@metamask/controller-utilsto^8.0.2(#3821) - Bump
@metamask/eth-json-rpc-providerto^2.3.2(#3821) - Bump
@metamask/json-rpc-engineto^7.3.2(#3821)
- Add
getNetworkConfigurationByNetworkClientIdmethod which can be used to retrieve details for both custom and built-in networks (using the network configuration object shape) (#2055) - Add
NetworkController:getNetworkConfigurationByNetworkClientIdmessenger action for the previous method (#2055)
- Bump
@metamask/base-controllerto^4.0.1(#3695) - Bump
@metamask/controller-utilsto^8.0.1(#3695, #3678, #3667, #3580) - Bump
@metamask/eth-json-rpc-providerto^2.3.1(#3695) - Bump
@metamask/json-rpc-engineto^7.3.1(#3695) - Create new network clients before updating
networkConfigurationsstate (#3679)- This primarily affects subscribers to the
NetworkController:stateChangeevent. It's now safe to use a network client for any network that appears in thenetworkConfigurationsstate, whereas previously it was possible that synchronous attempts to access a network client in response to this event would fail.
- This primarily affects subscribers to the
- Add
NetworkStatepayload toNetworkController:networkWillChangeandNetworkController:networkDidChange(#3598)- Both of these events now include
NetworkStateas the first and only item in the payload
- Both of these events now include
- BREAKING: Bump
@metamask/base-controllerto ^4.0.0 (#2063)- This is breaking because the type of the
messengerhas backward-incompatible changes. See the changelog for this package for more.
- This is breaking because the type of the
- Bump
@metamask/controller-utilsto ^6.0.0 (#2063)
- BREAKING: Bump dependency
@metamask/eth-queryfrom ^3.0.1 to ^4.0.0 (#2028)- This is breaking because it changes the type of the EthQuery instance this controller creates internally and exports under the
getEthQueryaction. Please consult the changelog for@metamask/eth-query4.0.0 for more.
- This is breaking because it changes the type of the EthQuery instance this controller creates internally and exports under the
- Update @metamask/eth-json-rpc-middleware in network controller (#1988)
- Bump dependency on
@metamask/json-rpc-engineto ^7.2.0 (#1895) - Bump @metamask/utils from 8.1.0 to 8.2.0 (#1957)
- Add new action handlers and associated types (#1806)
NetworkController:setActiveNetwork/NetworkControllerSetActiveNetworkActionNetworkController:setProviderType/NetworkControllerSetProviderTypeActionNetworkController:findNetworkClientByChainId/NetworkControllerFindNetworkClientIdByChainIdAction
- Add
tickertoNetworkClientConfiguration(#1794)
- Bump dependency on
@metamask/eth-json-rpc-providerto ^2.2.0 (#1738)
- BREAKING: Bump dependency on
@metamask/eth-json-rpc-infurato ^9.0.0 (#1653) - BREAKING: Bump dependency on
@metamask/eth-json-rpc-middlewareto ^12.0.0 (#1653) - BREAKING: Move from
json-rpc-engine^7.1.1 to@metamask/json-rpc-engine^8.0.0 (#1653) - BREAKING: Bump dependency on
eth-block-trackerto ^8.0.0 (#1653) - Bump dependency on
@metamask/eth-json-rpc-providerto ^2.1.0 (#1653) - Move from
eth-rpc-errors^4.0.2 to@metamask/rpc-errors^6.1.0 (#1653)
- Add
NetworkController:getEIP1559Compatibilitycontroller action (#1673)
- BREAKING: Rename
get1555CompatibilityWithNetworkClientIdtoget1559CompatibilityWithNetworkClientId(#1673) - Bump dependency on
@metamask/utilsto ^8.1.0 (#1639) - Bump dependency on
@metamask/base-controllerto ^3.2.3 - Bump dependency on
@metamask/controller-utilsto ^5.0.2
- Update linea goerli explorer url (#1666)
- Update TypeScript to v4.8.x (#1718)
- BREAKING: Remove
NetworkIdtype (#1633) - BREAKING: Remove
networkIdproperty fromNetworkStatetype (#1633) - Update scaffold RPC middleware for built-in Infura networks to no longer resolve
net_versionlocally (#1633) - Stop making
net_versionrequest to determine network status (#1633) - Bump dependency on
@metamask/controller-utilsto ^5.0.0
- Add
NetworkController:getNetworkClientByIdaction (#1638) - Add
lookupNetworkByClientIdandget1555CompatibilityWithNetworkClientIdmethods (#1557)
- Add optional
networkClientIdargument to methodslookupNetworkandgetEIP1559Compatibility(#1557)
- Bump dependency on
@metamask/base-controllerto ^3.2.1 - Bump dependency on
@metamask/controller-utilsto ^4.3.2
- Added an export for NetworkClientId in NetworkController (#1583)
- Add
NetworksMetadatatype (#1559)
- BREAKING: Remove
NetworkDetailstype in favor ofNetworkMetadata(#1559)- This new type includes
NetworkDetailsplus astatusproperty
- This new type includes
- BREAKING: Add
networksMetadatato state (#1559)- Consumers will need to add a migration. The data for this property can be constructed by looping over the values in
InfuraNetworkTypefrom@metamask/controller-utilsplus the network configuration IDs in the state propertynetworkConfigurationsand setting each value to{ status: "unknown", EIPS: {} }.
- Consumers will need to add a migration. The data for this property can be constructed by looping over the values in
- BREAKING: Add
selectedNetworkClientIdto state (#1548)- Consumers will need to add a migration. This property should be set to either
providerConfig.typeorproviderConfig.id.
- Consumers will need to add a migration. This property should be set to either
- Update
getEIP1559Compatibilityto returnundefinedwhen the latest block is unavailable (#1457) - Replace
eth-query^2.1.2 with@metamask/eth-query^3.0.1 (#1546)
- BREAKING: Remove
networkDetailsfrom state (#1559)- The data in this state property has been merged into the new
networksMetadatastate property; each value in this object contains anEIPSproperty.
- The data in this state property has been merged into the new
- BREAKING: Require
tickerto be included in theproviderConfigstate (#1495)- This requires a state migration, setting
providerConfig.tickertoETHif it's missing.
- This requires a state migration, setting
- Update
@metamask/utilsto^6.2.0(#1514) - Bump @metamask/eth-json-rpc-infura from 8.1.0 to 8.1.1 (#1517)
- Remove unnecessary
babel-runtimedependency (#1504)
- Bump
@metamask/eth-json-rpc-infuradependency from ^8.0.0 to ^8.1.0- This extends the types that this package recognizes to include Linea networks
- Add
getNetworkClientsByIdmethod (#1439)- This method returns a registry of available built-in and custom networks, allowing consumers to access multiple networks simultaneously if desired
- Network clients are retained and will no longer be destroyed or recreated whenever the network is initialized or switched (#1439)
- This means that cached responses for a network will no longer disappear when a different network is selected
- Update
upsertNetworkConfigurationto keep the network client registry up to date with changes to the set of network configurations (#1439)- If a new network configuration is added, the information in it will be used to create and register a new network client
- If an existing network configuration is updated, its information will be used to recreate the client for the corresponding network
- Expose
BlockTrackertype (#1443)
- Add
loadBackupmethod to NetworkController (#1421)
- BREAKING: Update
getEIP1559Compatibilityto returnfalseinstead oftrueif the provider has not been initialized yet (#1404) - Update
getEIP1559Compatibilityto not hit the current network if it is known that it does not support EIP-1559 (#1404) - Update
networkDetailsinitial state from{ EIPS: { 1559: false } }to{ EIPS: {} }(#1404) - Update lookupNetwork to unset
networkDetails.EIPS[1559]in state instead of setting itfalseif either of its requests for the network ID or network details fails (#1403)
- The events
networkWillChangeandnetworkDidChangeare emitted duringsetProviderType,setActiveNetwork,resetConnection, androllbackToPreviousProvider(#1336)- The
networkWillChangeevent is emitted before the network is switched (before the network status is cleared), - The
networkDidChangeevent is emitted after the new provider is setup (but before it has finished initializing).
- The
- Add
destroymethod (#1330) - Add events
infuraIsBlockedandinfuraIsUnblocked(#1264) - Add
NetworkController:getStateaction constant (#1329)
- BREAKING: Bump to Node 16 (#1262)
- BREAKING: The
providerConfigtype and state property have changed. ThechainIdproperty is nowHexrather than a decimalstring(#1367)- This requires a state migration
- This affects the return value of the
NetworkController:getProviderConfigandNetworkController:getStateactions.
- BREAKING: The
NetworkConfigurationtype and thenetworkConfigurationsstate property have changed. ThechainIdproperty on each configuration is nowHexrather than a decimalstring. (#1367)- This requires a state migration
- This change affects the
upsertNetworkConfigurationmethod, which takes a network configuration as the first parameter - This affects the return value of the
NetworkController:getStateaction
- Allow overlapping
lookupNetworkcalls (#1375)lookupNetworkno longer uses a mutex, meaning that a lookup can be initiated before the previous one has finished. This allows for faster network switching- When there is an overlap in
lookupNetworkcalls, the older one is aborted before events are emitted and before state changes
- BREAKING: Change
networkDetailsformat (#1326)- Previously
networkDetailswas{ isEIP1559Compatible: boolean }, now it is{ EIPS: { [eipNumber: number]: boolean } }
- Previously
- BREAKING: Update NetworkController to use a simpler middleware stack derived from pieces of
eth-json-rpc-middlewareinstead ofweb3-provider-engine(#1116)- A call to
eth_chainIdon a custom network will now return thechainIdin the provider config rather than the chain ID returned by the network. - A call to
eth_chainIdon a built-in Infura network will now return a hard-coded chain ID rather than the chain ID returned by the network. - A call to
net_versionon a built-in Infura network will now return a hard-coded network ID rather than the network ID returned by the network. - Previously, RPC requests with an object as the first parameter (e.g.
eth_call) were "sanitized" (i.e. unknown properties were removed from this first parameter, and any hex strings were normalized). This no longer happens. Instead these requests will pass through to the network unchanged. - A call to
eth_getBalance,eth_getBlockByNumber,eth_getCode,eth_getTransactionCount, oreth_callwill now be intercepted such that a block tag parameter of"latest"will be replaced with the latest known block number before being passed to the network.- This substitution makes it more likely that we can return a cached response to the request.
- Previously, a
eth_getTransactionCountrequest with a block tag of"pending"would be intercepted and given a result from our nonce cache (if the cache was populated for the given address). This nonce cache was updated upon each call toeth_sendRawTransactionbased on the nonce of the transaction being sent. The whole nonce cache was also cleared upon a call toevm_revert. This no longer happens, and these RPC methods will be passed to the network unchanged.- If you were using this to get a suggested next nonce, you can instead use the
nonceTrackerthat@metamask/transaction-controllerexposes
- If you were using this to get a suggested next nonce, you can instead use the
- A call to
web3_clientVersionis no longer intercepted to return a static result of"ProviderEngine/v<version>/javascript" - A call to
net_listeningis no longer intercepted to return a static result oftrue - A call to
eth_hashrateis no longer intercepted to return a static result of"0x00" - A call to
eth_miningis no longer intercepted to return a static result offalse - Previously,
eth_subscribeandeth_unsubscribewould never hit the network; instead, the behavior was polyfilled by polling the network for new blocks. Additionally, thenewPendingTransactionsparameter foreth_subscribewas unsupported. This polyfill is no longer present, andeth_subscribeandeth_unsubscribeare passed through to the network unchanged.- Consumers wishing to recreate the prior behavior and use the block tracker to power subscriptions may employ the middleware provided by the
eth-json-rpc-filterspackage.
- Consumers wishing to recreate the prior behavior and use the block tracker to power subscriptions may employ the middleware provided by the
- Previously,
eth_newFilter,eth_newBlockFilter,eth_newPendingTransactionFilter,eth_uninstallFilter,eth_getFilterChanges, andeth_getFilterLogswould never hit the network; instead, the behavior was polyfilled by polling the network for new blocks and recording updates for registered filters. This polyfill is no longer present, and these RPC methods are passed through to the network unchanged.- Consumers wishing to recreate the prior behavior and use the block tracker to power filters may employ the middleware provided by the
eth-json-rpc-filterspackage.
- Consumers wishing to recreate the prior behavior and use the block tracker to power filters may employ the middleware provided by the
- Interfacing with a network that exposes a websocket is no longer supported.
- A call to
- BREAKING: The methods
initializeProvider,setActiveNetwork, andresetConnectionwill now throw if the provider config is of typerpcbut is missing an RPC URL or a chain ID. (#1316)- Previously the chain ID was not required to setup the provider.
- Previously if the RPC URL was omitted, no error would be thrown but the provider would not be setup.
- BREAKING: The method
setProviderTypewill now throw when passed the typerpc. (#1316)- Previously no error would be thrown but the provider would not be setup.
- BREAKING: Update type of
blockTrackerproperty exposed bygetProviderAndBlockTrackerfromanytoSwappableProxy<PollingBlockTracker>(#1303) - BREAKING: Rename provider configuration property
rpcTargettorpcUrl(#1292) - BREAKING: The network status will now be "blocked" rather than "unavailable" when the user is blocked by Infura (#1264)
- BREAKING: The
infuraProjectIdconstructor parameter is now required (#1276) - BREAKING: The exported
Providertype has been updated to better reflect the provider type returned by the network controller (#1266)- Previously this was set to
any. Now it returns a type that mostly matches the provider returned (some semi-internal properties are omitted) - This affects the exported
ProviderProxytype as well, which wraps theProvidertype
- Previously this was set to
- Support hex and number
net_versionresponses (#1380) - Bump @metamask/utils from 5.0.1 to 5.0.2 (#1271)
- Bump dependency
eth-json-rpc-infura(now@metamask/eth-json-rpc-infura) from ^7.0.0 to ^8.0.0. (#1116) - Add dependency
eth-json-rpc-middleware^11.0.0 (#1116) - Add dependency
eth-json-rpc-provider^1.0.0 (#1116) - Add dependency
eth-block-tracker^7.0.0 (#1116) - Add dependency
json-rpc-engine^6.1.0 (#1116)
- BREAKING: Remove
providerConfigChangeevent (#1329)- Consumers are encouraged to subscribe to
NetworkController:stateChangewith a selector function that returnsproviderConfigif they want to perform an action whenproviderConfigchanges.
- Consumers are encouraged to subscribe to
- BREAKING: The built-in "localhost" network has been removed (#1313)
- Update network details in
lookupNetworkeven when network ID is unchanged (#1379) - Fix error when
rollbackToPreviousProvideris called when the previous network is a custom network with a missing or invalidid(#1223)- In that situation,
rollbackToPreviousProviderused to throw an error. Now it correctly rolls back instead.
- In that situation,
- Update EIP-1559 compatibility during network lookup (#1236)
- EIP-1559 compatibility check is still performed on initialization and after switching networks, like before. This change only impacts direct calls to
lookupNetwork. lookupNetworkis now making two network calls instead of one, ensuring that thenetworkDetailsstate is up-to-date.
- EIP-1559 compatibility check is still performed on initialization and after switching networks, like before. This change only impacts direct calls to
- BREAKING: Replace
networkstate withnetworkIdandnetworkStatus(#1196)- If you were using
networkto access the network ID, usenetworkIdinstead. It will be set tonullrather thanloadingif the network is not currently available. - If you were using
networkto see if the network was currently available, usenetworkStatusinstead. It will be set toNetworkStatus.Availableif the network is available. - When the network is unavailable, we now have two different states to represent that:
unknownandunavailable.unavailablemeans that the network was detected as not available, whereasunknownis used for unknown errors and cases where the network status is yet to be determined (e.g. before initialization, or while the network is loading).
- If you were using
- Use JavaScript private fields rather than
privateTypeScript keyword for internal methods/fields (#1189) - Export
BlockTrackerProxytype (#1147)- This is the type of the block tracker returned from the
getProviderAndBlockTrackermethod
- This is the type of the block tracker returned from the
- BREAKING: Async refactor
- Dependency updates
- BREAKING: Remove
isCustomNetworkstate (#1199)- The
providerConfig.typestate will be set to'rpc'if the current network is a custom network. Replace all references to theisCustomNetworkstate by checking the provider config state instead.
- The
- BREAKING: Replace
providerConfigsetter with a publicinitializeProvidermethod (#1133)- The property
providerConfigshould no longer be set to initialize the provider. That property no longer exists. - The method
initializeProvidermust be called instead to initialize the provider after constructing the network controller.
- The property
- Add rollbackToPreviousProvider method (#1132)
- BREAKING: Migrate network configurations from
PreferencesControllertoNetworkController(#1064)- Consumers will need to adapt to reading network data from
NetworkConfigurationsstate onNetworkControllerrather thanfrequentRpcListonPreferencesController. setRpcTargetbecomessetActiveNetworkonNetworkControllerand accepts anetworkConfigurationIdargument rather than anrpcUrl.addToFrequentRpcListonPreferencesControllerbecomesupsertNetworkConfigurationonNetworkController.removeFromFrequentRpcListonPreferencesControllerbecomesremoveNetworkConfigurationonNetworkController- The
NetworkControllerrequires atrackMetaMetricsEventcallback function argument in its constructor.
- Consumers will need to adapt to reading network data from
- BREAKING: Expose
getProviderAndBlockTrackerinstead ofprovider(#1091)- This change is breaking because it removes the provider property from
NetworkController. Instead, a new methodgetProviderAndBlockTrackermethod is available for accessing the current provider object.
- This change is breaking because it removes the provider property from
- BREAKING: Rename
propertiesproperty in state object tonetworkDetails(#1074)
- BREAKING: Remove
isomorphic-fetch(#1106)- Consumers must now import
isomorphic-fetchor another polyfill themselves if they are running in an environment withoutfetch
- Consumers must now import
- BREAKING: Update type of state object by renaming
propertiesproperty tonetworkDetails(#1074)- Consumers are recommended to add a state migration for this change.
- BREAKING: Rename
NetworkPropertiestype toNetworkDetails(#1074) - Change
getEIP1559Compatibilityto use async await syntax (#1084)
- Add support for Sepolia as a built-in Infura network (#1041)
- Export types for network controller events and actions (#1039)
- BREAKING: Make
lookupNetworkblock on completing the lookup (#1063)- This function was always
async, but it would return before completing any async work. Now it will not return until after the network lookup has been completed.
- This function was always
- Rename this repository to
core(#1031) - Update
@metamask/controller-utilspackage (#1041)
- BREAKING:: Drop support for Ropsten, Rinkeby, and Kovan as built-in Infura networks (#1041)
- BREAKING: Update type of state object by renaming
providerproperty toproviderConfig(#995)- Consumers are recommended to add a state migration for this change.
- BREAKING: Rename
NetworkController:providerChangemessenger event toNetworkController:providerConfigChange(#995) - Relax dependencies on
@metamask/base-controllerand@metamask/controller-utils(use^instead of~) (#998)
- Initial release
-
As a result of converting our shared controllers repo into a monorepo (#831), we've created this package from select parts of
@metamask/controllersv33.0.0, namely:- Everything in
src/network(minusNetworkTypeandNetworksChainId, which were placed in@metamask/controller-utils)
All changes listed after this point were applied to this package following the monorepo conversion.
- Everything in
-