Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Apr 21, 2020
1 parent ae0a449 commit 7ccf0c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion src/MetamaskInpageProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,17 @@ module.exports = class MetamaskInpageProvider extends SafeEventEmitter {
/**
* We override the following event methods so that we can warn consumers
* about deprecated events:
* on, once
* addListener, on, once, prependListener, prependOnceListener
*/

/**
* @inheritdoc
*/
addListener (eventName, listener) {
this._warnOfDeprecation(eventName)
return super.addListener(eventName, listener)
}

/**
* @inheritdoc
*/
Expand All @@ -288,6 +296,22 @@ module.exports = class MetamaskInpageProvider extends SafeEventEmitter {
return super.once(eventName, listener)
}

/**
* @inheritdoc
*/
prependListener (eventName, listener) {
this._warnOfDeprecation(eventName)
return super.prependListener(eventName, listener)
}

/**
* @inheritdoc
*/
prependOnceListener (eventName, listener) {
this._warnOfDeprecation(eventName)
return super.prependOnceListener(eventName, listener)
}

//====================
// Private Methods
//====================
Expand Down
4 changes: 2 additions & 2 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module.exports = {
// TODO:deprecation:remove
autoReloadDeprecation: `MetaMask: MetaMask will soon stop reloading pages on network change.\nFor more information, see: https://medium.com/metamask/no-longer-reloading-pages-on-network-change-fbf041942b44 \nSet 'ethereum.autoRefreshOnNetworkChange' to 'false' to silence this warning: https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.autorefreshonnetworkchange`,
// deprecated methods
enableDeprecation: `MetaMask: 'ethereum.enable()' is deprecated and will be removed in the future. Please use "ethereum.request({ method: 'eth_requestAccounts' })" instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102`,
enableDeprecation: `MetaMask: 'ethereum.enable()' is deprecated and will be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102`,
isConnectedDeprecation: `MetaMask: 'ethereum.isConnected()' is deprecated and will be removed in the future. Please listen for the relevant events instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
sendDeprecation: `MetaMask: 'ethereum.send(...)' is deprecated and will be removed in the future. Please use 'ethereum.request(method: string, params: Array<any> | Object)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
sendDeprecation: `MetaMask: 'ethereum.send(...)' is deprecated and will 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: {
chainIdChanged: `MetaMask: The event 'chainIdChanged' is deprecated and will be removed in the future. Please use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193`,
Expand Down

0 comments on commit 7ccf0c5

Please sign in to comment.