fix(checkout): Correctly handle adding a new network#2625
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit a9481b4.
☁️ Nx Cloud last updated this comment at |
keithbro-imx
commented
May 5, 2025
| export async function switchWalletNetwork( | ||
| config: CheckoutConfiguration, | ||
| provider: JsonRpcProvider | WrappedBrowserProvider, | ||
| provider: WrappedBrowserProvider, |
Contributor
Author
There was a problem hiding this comment.
We never pass in a JsonRpcProvider so we can simplify the contents of this function
keithbro-imx
commented
May 5, 2025
|
|
||
| if ( | ||
| !allowedNetworks.networks.some((network) => Number(network.chainId) === chainId) | ||
| !allowedNetworks.networks.some((network) => network.chainId === chainId) |
Contributor
Author
There was a problem hiding this comment.
chainId is already a number no need to cast it
keithbro-imx
commented
May 5, 2025
| } | ||
|
|
||
| if ('ethereumProvider' in provider && provider.ethereumProvider?.isPassport) { | ||
| if (provider.ethereumProvider?.isPassport) { |
Contributor
Author
There was a problem hiding this comment.
a WrappedBrowserProvider will always have ethereumProvider so no need to check
keithbro-imx
commented
May 5, 2025
| const currentChainId = await provider.send('eth_chainId', []); | ||
| // eslint-disable-next-line radix | ||
| const parsedChainId = Number(currentChainId.toString()); | ||
| const currentChainId = await provider.send('eth_chainId', []) as `0x${string}`; |
Contributor
Author
There was a problem hiding this comment.
eth_chainId returns a hexidecimal string so capture that in types
keithbro-imx
commented
May 5, 2025
| let walletName = ''; | ||
| if (isWalletConnectProvider(provider)) { | ||
| walletName = (provider.provider as any)?.session?.peer?.metadata?.name.toLowerCase(); | ||
| walletName = (provider.ethereumProvider as any)?.session?.peer?.metadata?.name.toLowerCase(); |
Contributor
Author
There was a problem hiding this comment.
Unrelated bug also introduced in v2
jeetparikh
approved these changes
May 5, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi👋, please ensure the PR title follows the below standards:
type(scope): message. For example:feat(passport): my new feature!after thetype(scope), for examplefeat(passport)!: my new breaking featureSummary
This was a regression in v2 of the SDK, due to the changes in the way Ethers does error handling.
Detail and impact of the change
Added
Changed
Deprecated
Removed
Fixed
Security
Anything else worth calling out?