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.
- Update
StreamProvider.initializeto callmetamask_getProviderStatewithisInitializingStreamProvider: true(#422)- In implementing
metamask_getProviderState, the extension makes a request for the network version; this parameter allows us to opt-out of that extra request on UI initialization.
- In implementing
- Adds a new
shouldAnnounceCaip294flag toinitializeProvideroptions (defaulted to true), so instead of theproviderInfo.rdnsvalue determining whether or not to announce the caip-294 target, the caller ofinitializeProvidercan directly control this (#419)
- Catch error when ethereum provider is set before we attempt to set it (#416)
- BREAKING:
initializeProviderannounces the extensionId, when available, via acaip-348target on in the newtargetsproperty of the CAIP-294 wallet announcement event instead of the previousextensionIdproperty (#413)
- BREAKING:
initializeProvider()no longer accepts thejsonRpcStreamNameoption param. (#410)- This helper no longers instantiates a
jsonRpcStreamNamenamed substream from theconnectionStreamDuplex stream option param. - Callers of
initializeProvider()should now instantiate their ownmetamask-providernamed substream and pass it in as the value forconnectionStream.
- This helper no longers instantiates a
- BREAKING: An
isConnectedboolean property is now expected in the result ofmetamask_getProviderStateandmetamask_chainChangedevents (#404) - BREAKING: A
networkVersionvalue ofloadingreceived by thechainChangedevent handler is now interpreted to be null. In this case, thenetworkChangedevent emits a null value as well. (#404) - BREAKING: The disconnect event is now tied to the new
isConnectedproperty instead of thenetworkVersionproperty. (#404) - A change in the
isUnlockedboolean property of themetamask_getProviderStateandmetamask_accountsChangedevents (from what is in state) no longer causes theaccountsChangedevent to be emitted (#405) MetaMaskInpageProvider.isUnlocked()will always return true until the inpage to contentscript stream ends and the provider enters a permanently disconnected state (#405)
- BREAKING:
StreamProviderno longer accepts ajsonRpcStreamNameparameter (#400)- Previously, this parameter was used internally to create an ObjectMultiplex stream and substream for JSON-RPC communication
- Now, the consumer is responsible for creating and managing the stream multiplexing if needed
- The provider will use the provided stream connection directly without any multiplexing
- BREAKING:
MetaMaskInpageProviderno longer accepts ajsonRpcStreamNameparameter (#400)- This change is inherited from StreamProvider, as MetaMaskInpageProvider extends StreamProvider
- Stream multiplexing should be handled before provider instantiation
initializeInpageProvidernow handles stream multiplexing internally (#400)- Creates an ObjectMultiplex instance and substream using the provided
jsonRpcStreamName - This maintains backwards compatibility for consumers using
initializeInpageProvider
- Creates an ObjectMultiplex instance and substream using the provided
createExternalExtensionProvidernow handles stream multiplexing internally (#400)- Creates an ObjectMultiplex instance and substream for JSON-RPC communication
- This maintains backwards compatibility for consumers using
createExternalExtensionProvider
- Bump
@metamask/json-rpc-enginefrom^10.0.1to^10.0.2(#397) - Bump
@metamask/json-rpc-middleware-streamfrom^8.0.5to^8.0.6(#397) - Bump
@metamask/rpc-errorsfrom^7.0.1to^7.0.2(#397) - Bump
@metamask/utilsfrom^10.0.0to^11.0.1(#397)
- Add new export for
initializeInpageProviderwith legacy build system support (#391)- Previously this module could be imported from
/dist/initializeInpageProvider, but this only worked with build systems that support theexportsfield (e.g. browserify). - This new
initializeInpageProviderexport has a JavaScript redirect for older build systems, so it should work correctly in all cases.
- Previously this module could be imported from
- Allow optional
jsonRpcStreamNameforinitializeInpageProvider(#390)- This parameter was accidentally made required in v18.1.0
- Add intializeInpageProvider as package export (#380)
- Remove spurious typescript reference (#381)
- BREAKING: Bump
@metamask/json-rpc-enginefrom^9.0.1to^10.0.0(#378) - BREAKING: Bump
@metamask/rpc-errorsfrom^6.4.0to^7.0.0(#373) - Bump @metamask/object-multiplex from
^2.0.0to^2.1.0(#375) - Bump @metamask/utils from
^9.2.1to^9.3.0(#370)
- Add support for edge-chromium to
createExternalExtensionProvider(#318, #368) - Fix ESM-related build issues (#362, #363)
- Bump @metamask/utils from 9.1.0 to 9.2.1 (#357)
- Bump micromatch from 4.0.5 to 4.0.8 in the npm_and_yarn group (#359)
- Remove deprecation console warnings when accessing
window.ethereum.chainId,window.ethereum.networkVersion, andwindow.ethereum.selectedAddress(#360)
- Add
@metamask/providers/stream-providerexport (#351)- This replaces the
@metamask/providers/dist/StreamProviderexport. It still exists for backwards compatibility, but will be removed in a future major release.
- This replaces the
- Bump
@metamask/utilsfrom9.0.0to9.1.0(#348)
- Bump
@metamask/json-rpc-engineto^9.0.1(#345) - Bump
@metamask/json-rpc-middleware-streamto^8.0.1(#345) - Bump
@metamask/rpc-errorsto^6.3.1(#345) - Bump
@metamask/superstructto^3.1.0(#338) - Bump
@metamask/utilsto^9.0.0(#345)
- Bump devDependency
@ts-bridge/clito^0.2.0(#343)- Fixes incorrect handling of
jsonfile imports, where an extension was appended to the file name after compilation (e.g.*.json.cjsor*.json.mjs).
- Fixes incorrect handling of
- Bump
@metamask/json-rpc-middleware-streamfrom^7.0.1to^8.0.0(#327) - Bump
@metamask/json-rpc-enginefrom^8.0.2to^9.0.0(#328) - Bump
extension-port-streamfrom^3.0.0to^4.1.0(#331) - Bump
@metamask/utilsfrom^8.4.0to^8.5.0(#329) - Bump
@metamask/rpc-errorsfrom^6.2.1to^6.3.0(#326)
- Produce and export ESM-compatible TypeScript type declaration files in addition to CommonJS-compatible declaration files (#336)
- This fixes the issue of this package being unusable by any TypeScript project that uses
Node16orNodeNextas itsmoduleResolutionoption. - 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".
- This fixes the issue of this package being unusable by any TypeScript project that uses
- Remove chunk files (#336).
- 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.
- Use named
extension-port-streamimport to ensure compatibility with bundlers such as Vite (#331)
- Change provider RPC error log severity from
errortowarn(#323)
- BREAKING: Change webextension-polyfill from dependency to peerDependency (#319)
- Users are now expected to have the polyfill in their environment
- Restore deprecated properties, networkChanged event, and offline send() net_version support (#312)
- Bump MetaMask dependencies (#310)
- Bump @metamask/safe-event-emitter from 3.0.0 to 3.1.1 (#309)
- Bump @metamask/utils from 8.3.0 to 8.4.0 (#311)
- Bump tar from 6.1.13 to 6.2.1 (#314)
- BREAKING: Remove deprecated properties, networkChanged event, and offline send() net_version support (#306)
window.ethereum.chainIdhas been removed. Use the 'eth_chainId' RPC method instead.window.ethereum.networkVersionhas been removed. Use the 'net_version' RPC method instead.window.ethereum.selectedAddresshas been removed. Use the 'eth_accounts' RPC method instead.networkChangedevent has been removed. The closest equivalent is thechainChangedevent.window.ethereum.send()no longer resolvesnet_versionoffline (from cache).
- Bump @metamask/json-rpc-engine from 7.3.2 to 7.3.3 (#305)
- BREAKING: Add ESM build (#296)
- It's no longer possible to import files from the
distfolder directly, with the exception of./dist/StreamProvider
- It's no longer possible to import files from the
- Don't send
nullparams to underlying provider (#292)
- Don't send
undefinedparams to underlying provider (#290)
- BREAKING: Update to streams3 API (#288)
- Update
extension-port-streamfrom^2.1.1to^3.0.0- Force subdependency
readable-streamto^3.6.2in resolutions
- Force subdependency
- Update
json-rpc-middleware-streamfrom^4.2.3to^5.0.1 - Update
@metamask/object-multiplexfrom^1.3.0to^2.0.0 - Add direct dependency on
readable-stream@^3.6.2 - Replace internal usage of stream with
readable-stream
- Update
- Add support for EIP-6963 (#263)
initializeProvider()params object now accepts an optionalproviderInfoproperty with a value of EIP6963ProviderInfo object- Add
eip6963AnnounceProvider()which supports a wallet by announcing a provider through theeip6963:announceProviderevent and re-announcing the provider whenever aneip6963:requestProviderevent is received - Add
eip6963RequestProvider()which supports a dapp by dispatching aneip6963:requestProviderevent and invoking a callback for eacheip6963:announceProviderevent received - Add
EIP6963AnnounceProviderEventtype - Add
EIP6963ProviderDetailtype - Add
EIP6963ProviderInfotype - Add
EIP6963RequestProviderEventtype
- BREAKING: Update
chainId,networkVersion, andselectedAddressto be read-only (#280) - Log deprecation warning when accessing
chainId,networkVersion, andselectedAddress(#280) - Remove
pump(#281)
- BREAKING: Replace
eth-rpc-errors@^4.0.2with@metamask/rpc-errors@6.0.0(#277) - BREAKING: Replace
json-rpc-engine@^6.1.0with@metamask/json-rpc-engine@7.1.1(#277) - Upgrade
@metamask/utilsfrom^6.2.0to^8.1.0(#277)
- Update
extension-port-streamto^2.1.1(#273)
- Update
fast-deep-equal(#258)
- Add warning for callers of
wallet_watchAssetwith ERC721 and ERC1155 token types, that support is currently considered experimental (#264)
- BREAKING: Minimum Node.js version 16 (#254)
- Support Flask and Beta in the external extension provider (#252)
- Bump @metamask/safe-event-emitter from 2.0.0 to 3.0.0 (#255)
- Fix console warning about deprecated
webextension-polyfill-ts(#249) - Prevent
accountsChanged+eth_accountscallback loop (#248)- If you listen to the provider
accountsChangedevent, modify the returned accounts, then calleth_accounts, it was possible to enter an infinite loop. This was caused by the provider mistakenly thinking the accounts had changed because of the mutation performed in the event listener, triggering redundantaccountsChangedevents. This was fixed; there should be no more redundantaccountsChangedevents and no infinite loop.
- If you listen to the provider
- Update
json-rpc-middleware-stream(#234)
- Update
json-rpc-middleware-stream(#230)
- Update
json-rpc-middleware-stream(#228)
- Retry sending messages to extension when
METAMASK_EXTENSION_STREAM_CONNECTis received (#223) - BREAKING: Update minimum Node.js version to v14 (#225)
- Add deprecation warning for encryption methods (#218)
- BREAKING: Move stream functionality from
BaseProviderto newStreamProvider(#209)BaseProvideris now a transport-agnostic abstract class.StreamProvideraccepts a stream and relies on MetaMask's internal JSON-RPC API for its behavior. See theStreamProviderclass for more details.MetaMaskInpageProvidershould be completely unaffected except that its prototype chain now includes a class namedAbstractStreamProvider.
8.1.1 - 2021-05-12
- Rename package to
@metamask/providers(#168)
- Restore
networkChangedevent inMetaMaskInpageProvider(#171)
8.1.0 - 2021-05-05
BaseProvider, implementing EIP-1193 without any legacy features (#144)createExternalExtensionProvider, from the extension-provider package (#152)
8.0.4 - 2021-02-04
- Fix warning on second
currentProvideraccess (#138)
8.0.3 - 2021-01-20
- Restore 'data' provider event (#135)
8.0.2 - 2021-01-12
- Reduce
window.web3shim console noise (#133)
8.0.1 - 2020-12-08
- Fix
8.0.0types (#127)
8.0.0 - 2020-12-07
- Add
loggerparameter toinitializeProvider(#116) - Add
window.web3shim,shimWeb3export (#113, #115)- This is to maintain
window.web3.currentProvideronce MetaMask stops injectingwindow.web3(very soon), and to log attempts to access any properties on the shim other thancurrentProvider. initializeWeb3now has ashouldShimWeb3argument, which causes the shim to be set aswindow.web3iftrue.
- This is to maintain
- BREAKING: Rename
initProviderexport toinitializeProvider(#114) - BREAKING: Replace
ethereum.publicConfigStorewith new set of JSON-RPC notifications (#109)
- BREAKING: Remove
_metamask.isEnabledand_metamask.isApproved(#112) - BREAKING: Remove the
chainIdChangedevent (#111) - BREAKING: Remove
ethereum.publicConfigStore(#109) - BREAKING: Remove
web3.js-related functionality (#106)- This functionality caused the page to reload if there was a
web3.jsinstance atwindow.web3, and keptweb3.eth.defaultAccountin sync withethereum.selectedAddress. - This functionality is replicated in @metamask/legacy-web3.
- This functionality caused the page to reload if there was a
- Correctly implement
connectanddisconnectevents (#120)- See EIP-1193 for the specification of these events.
disconnectemits with an RPC error. Like all such errors emitted by this module, they have acodeproperty with anumbervalue. There are currently two codes:1013indicates that MetaMask is attempting to reestablish the connection1011indicates that a page reload is required
- Send page metadata even if page is already loaded (#119)
- Convert
MetaMaskInpageProviderloggerto instance variable (#118)- Previously, it was erroneously a singleton across all class instances.
- Stop emitting state change events on initialization (#117)
- Includes
accountsChanged,chainChanged, andnetworkChanged. - This prevents sites that handle any of these events by reloading the page from entering into a reload loop.
- Includes
7.0.0 - 2020-09-08
- BREAKING: Changed casing of
Metamaskin all exports toMetaMask- A brand is a brand ¯\_(ツ)_/¯
6.3.0 - 2020-09-04
- Types
ethereum.networkVersionand.chainIdnow default tonullinstead ofundefined- Improved JSDoc comments and tags
6.2.0 - 2020-08-04
- Package consumers can now provide a
loggerobject to the provider constructor, to override the default logger- The default logger is the
consoleglobal - The following methods are required:
debug,error,info,log,trace
- The default logger is the
6.1.1 - 2020-07-28
- Updated dependencies, which produces a smaller bundle size
6.1.0 - 2020-07-21
- Only emit
dataevent for notifications present in^4.0.0(#73)- Some consumers make assumptions about the shape of the object emitted with the event that do not hold for all notifications in
^6.0.0.
- Some consumers make assumptions about the shape of the object emitted with the event that do not hold for all notifications in
- Select icon using
rel~="icon"when retrieving site metadata (#76)- This is instead of defaulting to
rel="shortcut icon".
- This is instead of defaulting to
- Emit
accountsChangedevent after all related state has been updated (#72)- For example,
ethereum.selectedAddresswill now have been updated by the time the event is emitted.
- For example,
- Enable retrieval of site icons not hosted on the same origin
(#78)
- For example, icons hosted on
assets.foo.comthat are used onfoo.comwill now be retrieved successfully.
- For example, icons hosted on
6.0.1 - 2020-07-15
- Warning message for the
dataevent- This deprecated event was added back in
6.0.0, but the warning message was not defined.
- This deprecated event was added back in
- Restore
publicConfigStoreproperty as alias for_publicConfigStore- The
_publicConfigStorewas namedpublicConfigStorebefore4.0.0. The original property turned out to be used by consumers. The store is scheduled to be removed completely, and accessingpublicConfigStoreemits a warning.
- The
6.0.0 - 2020-07-04
- The
dataevent- This event was removed in
4.0.0, as it was thought to only be used internally. This assumption was incorrect, and the event is now restored.
- This event was removed in
- BREAKING: Restore the
notificationevent value to its pre-4.0.0state- Prior to
4.0.0this event was emitted by code in the MetaMask extension. Its value was inadvertently changed when it was moved to this package.
- Prior to
5.2.1 - 2020-06-29
- Un-deprecate
isConnectedmethod.
5.2.0 - 2020-06-24
- Remove property protections
- Unless we lock down the entire provide object, which we can't do, a determined consumer can break our provider. Thus, protected properties are pointless.
- Fix
requestsparamstype checks - Update deprecation warning messages per most recent deprecation plans
5.1.0 - 2020-06-01
- Update
requestparamstype tounknown[] | object- This is not breaking in practice, since no RPC methods with other
paramsvalues exist.
- This is not breaking in practice, since no RPC methods with other
5.0.2 - 2020-05-22
- Fix
ethereum.sendreturn value for certain argument combination- Reverted to pre-
4.0.0state
- Reverted to pre-
- Stop protecting overwrites of the following properties, that existed prior to
4.0.0:ethereum.isMetaMaskethereum._metamask
- Protect the following new, private properties required for
ethereum.requestto work:ethereum._rpcRequestethereum._rpcEngine
5.0.1 - 2020-05-11
- Rename package to @metamask/inpage-provider
- Prevent overwrite of certain properties on the Provider
ethereum.requestethereum.isMetaMaskethereum._metamask
5.0.0 - 2020-04-22
- The most recent EIP 1193 API (#30)
- The method
request - The events
disconnectandmessage
- The method
- A global initialization event,
ethereum#initialized, for asynchronous injection (#31) - Helper methods for initializing the provider (#31)
- BREAKING: Use named instead of default exports (#31)
- BREAKING:
MetaMaskInpageconstructor now takes aconnectionStreamand an options object (#31) - BREAKING:
_metamask.sendBatch->_metamask.requestBatch(#30) - BREAKING: Revert
sendto match provider in v7.7.8 ofmetamask-extension(#29) - The
connectevent now emits with aProviderConnectInfoobject per EIP 1193 (#30) - Deprecated the
sendmethod (#30) - Deprecated the events
close,networkChanged, andnotification, and added deprecation warnings for them (#30) - Un-deprecated
sendAsync(#29)