-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat: Bump @metamask/providers
to ^20.0.0
#29936
Open
jiexi
wants to merge
9
commits into
main
Choose a base branch
from
jl/send-isConnected-in-getProviderState-chainChanged
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−31
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
822e8cb
add isConnected logic
jiexi 5195235
Fix setActiveNetwork call order in permissionController:stateChange
jiexi dce5a67
restore networkVersion loading value
jiexi 5eea5ea
Merge branch 'main' into jl/send-isConnected-in-getProviderState-chai…
jiexi d6be967
Bump providers to 20.0.0
jiexi b790d6d
Merge branch 'main' into jl/send-isConnected-in-getProviderState-chai…
jiexi 8739e1d
hardcode isUnlocked in getProviderState to true
jiexi a6a40f0
remove metamask_unlockStateChanged event
jiexi 0435868
lint
jiexi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3059,11 +3059,11 @@ export default class MetamaskController extends EventEmitter { | |
if (chains.length > 0 && !chains.includes(currentChainIdForOrigin)) { | ||
const networkClientId = | ||
this.networkController.findNetworkClientIdByChainId(chains[0]); | ||
this.networkController.setActiveNetwork(networkClientId); | ||
this.selectedNetworkController.setNetworkClientIdForDomain( | ||
origin, | ||
networkClientId, | ||
); | ||
this.networkController.setActiveNetwork(networkClientId); | ||
} | ||
} | ||
}, | ||
|
@@ -3282,12 +3282,13 @@ export default class MetamaskController extends EventEmitter { | |
const publicConfigStore = new ObservableStore(); | ||
|
||
const selectPublicState = async ({ isUnlocked }) => { | ||
const { chainId, networkVersion } = await this.getProviderNetworkState(); | ||
const { chainId, networkVersion, isConnected } = | ||
await this.getProviderNetworkState(); | ||
|
||
return { | ||
isUnlocked, | ||
chainId, | ||
networkVersion: networkVersion ?? 'loading', | ||
networkVersion: isConnected ? networkVersion : 'loading', | ||
}; | ||
}; | ||
|
||
|
@@ -3316,7 +3317,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, | ||
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. a bit unfortunate in retrospect that we batched these into the same release since we are probably looking to release this as a hotfix... |
||
accounts: this.getPermittedAccounts(origin), | ||
...providerNetworkState, | ||
}; | ||
|
@@ -3358,9 +3363,13 @@ export default class MetamaskController extends EventEmitter { | |
this.deprecatedNetworkVersions[networkClientId] = networkVersion; | ||
} | ||
|
||
const metadata = | ||
this.networkController.state.networksMetadata[networkClientId]; | ||
|
||
return { | ||
chainId, | ||
networkVersion: networkVersion ?? 'loading', | ||
isConnected: metadata?.status === NetworkStatus.Available, | ||
}; | ||
} | ||
|
||
|
@@ -6790,20 +6799,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), | ||
}, | ||
}; | ||
}); | ||
|
||
this.unMarkPasswordForgotten(); | ||
|
||
// In the current implementation, this handler is triggered by a | ||
|
@@ -6814,16 +6811,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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] can we add a comment explaining why the
setActiveNetwork
call needs to come before thesetNetworkClientIdForDomain
call