-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
upgrade NetworkController to V20 #395
Conversation
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@metamask/[email protected] |
src/SmartTransactionsController.ts
Outdated
onNetworkStateChange((networkState) => { | ||
const { selectedNetworkClientId } = networkState; | ||
const networkClient = this.getNetworkClientById(selectedNetworkClientId); | ||
const { chainId } = networkClient.configuration; | ||
const isNewChainId = chainId !== this.config.chainId; | ||
this.configure({ chainId }); | ||
this.initializeSmartTransactionsForChainId(); | ||
if (isNewChainId) { | ||
this.#ensureUniqueSmartTransactions(); | ||
} | ||
this.checkPoll(this.state); | ||
this.ethQuery = new EthQuery(provider); | ||
this.ethQuery = new EthQuery(networkClient.provider); | ||
}); |
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: Could we do it this way instead? The only difference is fewer rows and earlier deconstruction ?
onNetworkStateChange((networkState) => { | |
const { selectedNetworkClientId } = networkState; | |
const networkClient = this.getNetworkClientById(selectedNetworkClientId); | |
const { chainId } = networkClient.configuration; | |
const isNewChainId = chainId !== this.config.chainId; | |
this.configure({ chainId }); | |
this.initializeSmartTransactionsForChainId(); | |
if (isNewChainId) { | |
this.#ensureUniqueSmartTransactions(); | |
} | |
this.checkPoll(this.state); | |
this.ethQuery = new EthQuery(provider); | |
this.ethQuery = new EthQuery(networkClient.provider); | |
}); | |
onNetworkStateChange(({ selectedNetworkClientId }) => { | |
const { | |
configuration: { chainId }, | |
provider, | |
} = this.getNetworkClientById(selectedNetworkClientId); | |
const isNewChainId = chainId !== this.config.chainId; | |
this.configure({ chainId }); | |
this.initializeSmartTransactionsForChainId(); | |
if (isNewChainId) { | |
this.#ensureUniqueSmartTransactions(); | |
} | |
this.checkPoll(this.state); | |
this.ethQuery = new EthQuery(provider); | |
}); |
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.
Looks good to me, there's just one minor change proposed
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.
LGTM!
Upgrade the @metamask/network-controller to v20. @metamask/network-controller 20.0.0 removed providerConfig from state, which means that we now need to use selectedNetworkClientId to access the chain ID for the currently selected network. And we no longer need to take provider, instead get this from the network client object.
@metamask/network-controller
from v19 to v20 #391