Skip to content

Commit 5c95532

Browse files
1.34.1-0.1.0: [fix] network switch bug (#673)
* 1.34.1-0.1.0: [fix] Only show switch network modal once per wallet check * Fix formatting
1 parent 448fdc3 commit 5c95532

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.34.1",
3+
"version": "1.34.1-0.1.0",
44
"description": "Onboard users to web3 by allowing them to select a wallet, get that wallet ready to transact and have access to synced wallet state.",
55
"keywords": [
66
"ethereum",

src/modules/check/network.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ function network(
1414
): (currentState: StateAndHelpers) => Promise<WalletCheckModal | undefined> {
1515
const { heading, description, icon, html, button } = options
1616

17+
let networkCheckRequested = false
18+
let prevWalletCheckInProgressValue: boolean
19+
20+
app.subscribe(({ walletCheckInProgress }: AppState) => {
21+
if (
22+
prevWalletCheckInProgressValue === false &&
23+
walletCheckInProgress === true
24+
) {
25+
networkCheckRequested = false
26+
}
27+
prevWalletCheckInProgressValue = walletCheckInProgress
28+
})
29+
1730
return async (stateAndHelpers: StateAndHelpers) => {
1831
const {
1932
network,
@@ -42,8 +55,13 @@ function network(
4255
}
4356
}
4457
// Adds a check for WalletConnect since it hangs for unsupported rpc methods
45-
if (getProviderName(wallet?.provider) !== 'WalletConnect') {
58+
if (
59+
!networkCheckRequested &&
60+
stateStore.network.get() != appNetworkId &&
61+
getProviderName(wallet?.provider) !== 'WalletConnect'
62+
) {
4663
try {
64+
networkCheckRequested = true
4765
await wallet?.provider?.request({
4866
method: 'wallet_switchEthereumChain',
4967
params: [{ chainId: '0x' + appNetworkId?.toString(16) }]

0 commit comments

Comments
 (0)