diff --git a/src/MetamaskInpageProvider.js b/src/MetamaskInpageProvider.js index 2415d204..49cc4cc4 100644 --- a/src/MetamaskInpageProvider.js +++ b/src/MetamaskInpageProvider.js @@ -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 */ @@ -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 //==================== diff --git a/src/messages.js b/src/messages.js index 095449f6..ac63246a 100644 --- a/src/messages.js +++ b/src/messages.js @@ -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 | 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`,