Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove web3-related functionality #106

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions src/MetaMaskInpageProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module.exports = class MetaMaskInpageProvider extends SafeEventEmitter {
},
// misc
// TODO:deprecation:remove
autoRefresh: false,
publicConfigStore: false,
},
isConnected: undefined,
Expand All @@ -104,7 +103,7 @@ module.exports = class MetaMaskInpageProvider extends SafeEventEmitter {
this.networkVersion = null
this.chainId = null

// bind functions (to prevent e.g. web3@1.x from making unbound calls)
// bind functions (to prevent consumers from making unbound calls)
this._handleAccountsChanged = this._handleAccountsChanged.bind(this)
this._handleDisconnect = this._handleDisconnect.bind(this)
this._sendSync = this._sendSync.bind(this)
Expand Down Expand Up @@ -230,24 +229,6 @@ module.exports = class MetaMaskInpageProvider extends SafeEventEmitter {

// indicate that we've connected, for EIP-1193 compliance
setTimeout(() => this.emit('connect', { chainId: this.chainId }))

// TODO:deprecation:remove
/** @deprecated */
this._web3Ref = undefined

// TODO:deprecation:remove
// if true, MetaMask reloads the page if window.web3 has been accessed
/** @deprecated */
this.autoRefreshOnNetworkChange = true

// TODO:deprecation:remove
// wait a second to attempt to send this, so that the warning can be silenced
setTimeout(() => {
if (this.autoRefreshOnNetworkChange && !this._state.sentWarnings.autoRefresh) {
log.warn(messages.warnings.autoRefreshDeprecation)
this._state.sentWarnings.autoRefresh = true
}
}, 1000)
}

get publicConfigStore () {
Expand Down Expand Up @@ -473,18 +454,6 @@ module.exports = class MetaMaskInpageProvider extends SafeEventEmitter {
this.selectedAddress = _accounts[0] || null
}

// TODO:deprecation:remove
// handle web3
if (this._web3Ref) {
this._web3Ref.defaultAccount = this.selectedAddress
} else if (
window.web3 &&
window.web3.eth &&
typeof window.web3.eth === 'object'
) {
window.web3.eth.defaultAccount = this.selectedAddress
}

// only emit the event once all state has been updated
this.emit('accountsChanged', _accounts)
}
Expand Down
3 changes: 2 additions & 1 deletion src/initializeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function initializeProvider ({
)

provider = new Proxy(provider, {
deleteProperty: () => true, // some libraries, e.g. web3@1.x, mess with our API
// some common libraries, e.g. web3@1.x, mess with our API
deleteProperty: () => true,
})

if (shouldSetOnWindow) {
Expand Down
4 changes: 1 addition & 3 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
errors: {
disconnected: () => `MetaMask: Lost connection to MetaMask background process.`,
sendSiteMetadata: () => `MetaMask: Failed to send site metadata. This is an internal error, please report this bug.`,
unsupportedSync: (method) => `MetaMask: The MetaMask Web3 object does not support synchronous methods like ${method} without a callback parameter.`,
unsupportedSync: (method) => `MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${method} without a callback parameter.`,
invalidDuplexStream: () => 'Must provide a Node.js-style duplex stream.',
invalidOptions: (maxEventListeners, shouldSendMetadata) => `Invalid options. Received: { maxEventListeners: ${maxEventListeners}, shouldSendMetadata: ${shouldSendMetadata} }`,
invalidRequestArgs: () => `Expected a single, non-array, object argument.`,
Expand All @@ -12,8 +12,6 @@ module.exports = {
invalidLoggerMethod: (method) => `'args.logger' must include required method '${method}'.`,
},
warnings: {
// TODO:deprecation:remove
autoRefreshDeprecation: `MetaMask: MetaMask will soon stop reloading pages on network change.\nFor more information, see: https://docs.metamask.io/guide/ethereum-provider.html#ethereum-autorefreshonnetworkchange \nSet 'ethereum.autoRefreshOnNetworkChange' to 'false' to silence this warning.`,
// deprecated methods
enableDeprecation: `MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102`,
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`,
Expand Down