-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feat: Bump @metamask/providers to ^20.0.0
#29936
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
Changes from all commits
ec919bd
822e8cb
5195235
dce5a67
5eea5ea
d6be967
b790d6d
8739e1d
a6a40f0
0435868
d417b42
38171cb
8108290
b4e7142
7b56a80
7be8143
820761d
d31071c
c949078
a457bc2
4868431
972574a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| export enum NOTIFICATION_NAMES { | ||
| accountsChanged = 'metamask_accountsChanged', | ||
| unlockStateChanged = 'metamask_unlockStateChanged', | ||
| chainChanged = 'metamask_chainChanged', | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2742,6 +2742,10 @@ export default class MetamaskController extends EventEmitter { | |
| if (chains.length > 0 && !chains.includes(currentChainIdForOrigin)) { | ||
| const networkClientId = | ||
| this.networkController.findNetworkClientIdByChainId(chains[0]); | ||
| // setActiveNetwork should be called before setNetworkClientIdForDomain | ||
| // to ensure that the isConnected value can be accurately inferred from | ||
| // NetworkController.state.networksMetadata in return value of | ||
| // `metamask_getProviderState` requests and `metamask_chainChanged` events. | ||
| this.networkController.setActiveNetwork(networkClientId); | ||
| this.selectedNetworkController.setNetworkClientIdForDomain( | ||
| origin, | ||
|
|
@@ -2993,7 +2997,11 @@ export default class MetamaskController extends EventEmitter { | |
| const providerNetworkState = await this.getProviderNetworkState(origin); | ||
|
|
||
| return { | ||
| isUnlocked: this.isUnlocked(), | ||
| /** | ||
| * We default `isUnlocked` to `true` because even though we no longer emit events depending on this, | ||
| * embedded dapp providers might listen directly to our streams, and therefore depend on it, so we leave it here. | ||
| */ | ||
| isUnlocked: true, | ||
ffmcgee725 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| accounts: this.getPermittedAccounts(origin), | ||
| ...providerNetworkState, | ||
| }; | ||
|
|
@@ -6495,20 +6503,8 @@ export default class MetamaskController extends EventEmitter { | |
|
|
||
| /** | ||
| * Handle global application unlock. | ||
| * Notifies all connections that the extension is unlocked, and which | ||
| * account(s) are currently accessible, if any. | ||
| */ | ||
| _onUnlock() { | ||
| this.notifyAllConnections((origin) => { | ||
| return { | ||
| method: NOTIFICATION_NAMES.unlockStateChanged, | ||
| params: { | ||
| isUnlocked: true, | ||
| accounts: this.getPermittedAccounts(origin), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. There might still be a case where a dapp doesn't find out about an account change: when the accounts change before the wallet is marked as unlocked (e.g. if a change is triggered during that update, not sure exactly what the sequence of events is). I see that we react to account changes below in this file, in Maybe we can continue emitting them here, or remove that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved in 7be8143 by removing |
||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| this.unMarkPasswordForgotten(); | ||
|
|
||
| // In the current implementation, this handler is triggered by a | ||
|
|
@@ -6519,16 +6515,8 @@ export default class MetamaskController extends EventEmitter { | |
|
|
||
| /** | ||
| * Handle global application lock. | ||
| * Notifies all connections that the extension is locked. | ||
| */ | ||
| _onLock() { | ||
| this.notifyAllConnections({ | ||
| method: NOTIFICATION_NAMES.unlockStateChanged, | ||
| params: { | ||
| isUnlocked: false, | ||
| }, | ||
| }); | ||
|
|
||
| // In the current implementation, this handler is triggered by a | ||
| // KeyringController event. Other controllers subscribe to the 'lock' | ||
| // event of the MetaMaskController itself. | ||
|
|
@@ -7057,21 +7045,19 @@ export default class MetamaskController extends EventEmitter { | |
| } | ||
|
|
||
| _notifyAccountsChange(origin, newAccounts) { | ||
| if (this.isUnlocked()) { | ||
| this.notifyConnections(origin, { | ||
| method: NOTIFICATION_NAMES.accountsChanged, | ||
| // This should be the same as the return value of `eth_accounts`, | ||
| // namely an array of the current / most recently selected Ethereum | ||
| // account. | ||
| params: | ||
| newAccounts.length < 2 | ||
| ? // If the length is 1 or 0, the accounts are sorted by definition. | ||
| newAccounts | ||
| : // If the length is 2 or greater, we have to execute | ||
| // `eth_accounts` vi this method. | ||
| this.getPermittedAccounts(origin), | ||
| }); | ||
| } | ||
| this.notifyConnections(origin, { | ||
| method: NOTIFICATION_NAMES.accountsChanged, | ||
| // This should be the same as the return value of `eth_accounts`, | ||
| // namely an array of the current / most recently selected Ethereum | ||
| // account. | ||
| params: | ||
| newAccounts.length < 2 | ||
| ? // If the length is 1 or 0, the accounts are sorted by definition. | ||
| newAccounts | ||
| : // If the length is 2 or greater, we have to execute | ||
| // `eth_accounts` vi this method. | ||
| this.getPermittedAccounts(origin), | ||
| }); | ||
|
|
||
| this.permissionLogController.updateAccountsHistory(origin, newAccounts); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.