-
-
Notifications
You must be signed in to change notification settings - Fork 225
chore: explicitly pass networkClientId for nftController #5622
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
base: main
Are you sure you want to change the base?
Conversation
this.messagingSystem.subscribe( | ||
'NetworkController:networkDidChange', | ||
this.#onNetworkControllerNetworkDidChange.bind(this), | ||
); |
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.
This subscription is removed because the purpose of onNetworkControllerNetworkDidChange
was to populate this.#chainId
which has been removed
selectedNetworkClientId, | ||
); | ||
this.#chainId = chainId; | ||
} |
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.
Removed this because subscription was also removed
return chainId; | ||
} | ||
return this.#chainId; | ||
} |
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.
This has been removed and we are making a call
to NetworkController:getNetworkClientById
when needed since we no longer fallback to this.#chainId
// TODO: revisit this with Solana support and instead of passing chainId, make sure chainId is read from nftMetadata | ||
const chainIdToAddTo = | ||
chainId || this.#getCorrectChainId({ networkClientId }); | ||
|
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.
Removed this in favor of the mandatory networkClientId
;
This will be called from nftDetectionController
to add NFTs in which case we will take the chainId from the NFT and find the networkClientId. Or directly from clients, in which case they need to provide the networkClientId.
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
TODO: Changelog |
@@ -1827,6 +1838,16 @@ export class NetworkController extends BaseController< | |||
return this.state.networkConfigurationsByChainId[chainId]; | |||
} | |||
|
|||
getNetworkClientIdByChainId(chainId: Hex): NetworkClientId | undefined { |
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.
Is findNetworkClientByChainId
not sufficient for your use case? Or do you prefer this version because it doesn't throw? I hesitate to introduce a similar-sounding method because it could get confusing, so it would be good to figure out what we wan to do here.
0d5cebc
to
476edcf
Compare
476edcf
to
42bb475
Compare
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
### Added | |||
|
|||
- Add optional `getBlockTrackerOptions` argument to NetworkController constructor ([#5702](https://github.com/MetaMask/core/pull/5702)) | |||
- Add helper function `buildMockFindNetworkClientIdByChainId` to mock `findNetworkClientIdByChainId` |
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: You can omit this changelog entry since this change is only related to tests.
- Add helper function `buildMockFindNetworkClientIdByChainId` to mock `findNetworkClientIdByChainId` |
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.
done :)
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.
the only problem is , it's causing a failure on the CI :/
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.
Yes it's okay to use no-changelog
label in this case
@metamaskbot publish-preview |
1 similar comment
@metamaskbot publish-preview |
Explanation
This PR is part of a larger effort to remove the global network selector.
On this PR:
UI integration:
References
NFTController
: Remove Private Property#chainId
and the fallback on current selected network #5581Changelog
@metamask/assets-controllers
NftController
andNftDetectionController
to eliminate the dependency on the current chain. All functions that previously accepted networkClientId as an optional parameter now require it as a mandatory parameterChecklist