Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
13c42a38
Unverified
Commit
13c42a38
authored
Dec 23, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(network switch): do not show failed to switch networks for successful network switches
parent
458e04f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
FailedNetworkSwitchPopup.tsx
src/components/Popups/FailedNetworkSwitchPopup.tsx
+2
-2
switchToNetwork.ts
src/utils/switchToNetwork.ts
+6
-5
No files found.
src/components/Popups/FailedNetworkSwitchPopup.tsx
View file @
13c42a38
...
@@ -24,8 +24,8 @@ export default function FailedNetworkSwitchPopup({ chainId }: { chainId: Support
...
@@ -24,8 +24,8 @@ export default function FailedNetworkSwitchPopup({ chainId }: { chainId: Support
<
AutoColumn
gap=
"8px"
>
<
AutoColumn
gap=
"8px"
>
<
ThemedText
.
Body
fontWeight=
{
500
}
>
<
ThemedText
.
Body
fontWeight=
{
500
}
>
<
Trans
>
<
Trans
>
Your wallet does not support switching networks from the Uniswap Interface. In order to use Uniswap on
{
'
'
}
Failed to switch networks from the Uniswap Interface. In order to use Uniswap on
{
chainInfo
.
label
}
, you must
{
chainInfo
.
label
}
, you must
change the network in your wallet.
change the network in your wallet.
</
Trans
>
</
Trans
>
</
ThemedText
.
Body
>
</
ThemedText
.
Body
>
</
AutoColumn
>
</
AutoColumn
>
...
...
src/utils/switchToNetwork.ts
View file @
13c42a38
...
@@ -37,15 +37,16 @@ export async function switchToNetwork({ library, chainId }: SwitchNetworkArgumen
...
@@ -37,15 +37,16 @@ export async function switchToNetwork({ library, chainId }: SwitchNetworkArgumen
},
},
],
],
})
})
const
{
chainId
:
chainIdAfterSwitch
}
=
await
library
.
getNetwork
()
// metamask (only known implementer) automatically switches after a network is added
if
(
chainIdAfterSwitch
!==
chainId
)
{
// the second call is done here because that behavior is not a part of the spec and cannot be relied upon in the future
// metamask (only known implementer) automatically switches after a network is added
// metamask's behavior when switching to the current network is just to return null (a no-op)
// the second call is done here because that behavior is not a part of the spec and cannot be relied upon in the future
try
{
// metamask's behavior when switching to the current network is just to return null (a no-op)
await
library
.
provider
.
request
({
await
library
.
provider
.
request
({
method
:
'
wallet_switchEthereumChain
'
,
method
:
'
wallet_switchEthereumChain
'
,
params
:
[{
chainId
:
formattedChainId
}],
params
:
[{
chainId
:
formattedChainId
}],
})
})
}
catch
(
error
)
{
console
.
debug
(
'
Added network but could not switch chains
'
,
error
)
}
}
}
else
{
}
else
{
throw
error
throw
error
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment