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

feat: Bump @metamask/providers to ^20.0.0 #29936

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion app/scripts/controllers/permissions/enums.ts
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',
}
37 changes: 13 additions & 24 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

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 the setNetworkClientIdForDomain call

this.selectedNetworkController.setNetworkClientIdForDomain(
origin,
networkClientId,
);
this.networkController.setActiveNetwork(networkClientId);
}
}
},
Expand Down Expand Up @@ -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',
};
};

Expand Down Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The 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,
};
Expand Down Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"@metamask/ppom-validator": "0.36.0",
"@metamask/preinstalled-example-snap": "^0.3.0",
"@metamask/profile-sync-controller": "^4.1.1",
"@metamask/providers": "^19.0.0",
"@metamask/providers": "^20.0.0",
"@metamask/queued-request-controller": "^7.0.1",
"@metamask/rate-limit-controller": "^6.0.0",
"@metamask/remote-feature-flag-controller": "^1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6059,9 +6059,9 @@ __metadata:
languageName: node
linkType: hard

"@metamask/providers@npm:^19.0.0":
version: 19.0.0
resolution: "@metamask/providers@npm:19.0.0"
"@metamask/providers@npm:^20.0.0":
version: 20.0.0
resolution: "@metamask/providers@npm:20.0.0"
dependencies:
"@metamask/json-rpc-engine": "npm:^10.0.2"
"@metamask/json-rpc-middleware-stream": "npm:^8.0.6"
Expand All @@ -6076,7 +6076,7 @@ __metadata:
readable-stream: "npm:^3.6.2"
peerDependencies:
webextension-polyfill: ^0.10.0 || ^0.11.0 || ^0.12.0
checksum: 10/e45b2e90aa45db689bed582e85181d6964daff3c4b651ffc8503edcec2206a1b76677c0ae6fc0b29cef37a1b33775545e73bd1cf62802a4fc5e2841973cdafb6
checksum: 10/b958d03a9380d86e605db239109a3debcc1ffde90371abe5beb82a5bed46c7718303a2bb92ec269eae16eff145b9ebbfcb3445a2b6bad4f297a590ee725a5bad
languageName: node
linkType: hard

Expand Down Expand Up @@ -26655,7 +26655,7 @@ __metadata:
"@metamask/preferences-controller": "npm:^15.0.1"
"@metamask/preinstalled-example-snap": "npm:^0.3.0"
"@metamask/profile-sync-controller": "npm:^4.1.1"
"@metamask/providers": "npm:^19.0.0"
"@metamask/providers": "npm:^20.0.0"
"@metamask/queued-request-controller": "npm:^7.0.1"
"@metamask/rate-limit-controller": "npm:^6.0.0"
"@metamask/remote-feature-flag-controller": "npm:^1.3.0"
Expand Down
Loading