Skip to content

Commit

Permalink
Restore data provider event (MetaMask#135)
Browse files Browse the repository at this point in the history
This event is deprecated, and is not part of EIP-1193. However we did not plan to remove this; it was removed accidentally as part of MetaMask#109. It should now behave exactly as it did in v6.3.0.

The text of the deprecation warning for this event has also been updated to provide a recommended alternative.
  • Loading branch information
Gudahtt authored Jan 20, 2021
1 parent 2280088 commit 35cd607
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/MetaMaskInpageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ export default class MetaMaskInpageProvider extends SafeEventEmitter {
} else if (method === 'metamask_chainChanged') {
this._handleChainChanged(params);
} else if (EMITTED_NOTIFICATIONS.includes(method)) {
// deprecated
// emitted here because that was the original order
this.emit('data', payload);

this.emit('message', {
type: method,
data: params,
Expand Down
8 changes: 4 additions & 4 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const messages = {
sendDeprecation: `MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
// deprecated events
events: {
close: `MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
data: `MetaMask: The event 'data' is deprecated and may be removed in the future.`,
networkChanged: `MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Please use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
notification: `MetaMask: The event 'notification' is deprecated and may be removed in the future. Please use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
close: `MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect`,
data: `MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`,
networkChanged: `MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged`,
notification: `MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`,
},
// misc
experimentalMethods: `MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning.`,
Expand Down

0 comments on commit 35cd607

Please sign in to comment.