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
5dec0cf7
Unverified
Commit
5dec0cf7
authored
Jan 19, 2022
by
Jordan Frankfurt
Committed by
GitHub
Jan 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show wrong chain message instead of throwing on incorrect chain connection (#3153)
parent
1efda07e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
18 deletions
+13
-18
ErrorGenerator.tsx
src/lib/components/Error/ErrorGenerator.tsx
+1
-10
Toolbar.tsx
src/lib/components/Swap/Toolbar.tsx
+12
-1
errors.ts
src/lib/errors.ts
+0
-7
No files found.
src/lib/components/Error/ErrorGenerator.tsx
View file @
5dec0cf7
import
{
ALL_SUPPORTED_CHAIN_IDS
}
from
'
constants/chains
'
import
{
ChainIdError
,
IntegrationError
}
from
'
lib/errors
'
import
useActiveWeb3React
from
'
lib/hooks/useActiveWeb3React
'
import
{
IntegrationError
}
from
'
lib/errors
'
import
{
SwapWidgetProps
}
from
'
lib/index
'
import
{
useEffect
}
from
'
react
'
...
...
@@ -14,13 +12,6 @@ export default function ErrorGenerator(swapWidgetProps: SwapWidgetProps) {
}
},
[
provider
,
jsonRpcEndpoint
])
const
{
chainId
}
=
useActiveWeb3React
()
useEffect
(()
=>
{
if
(
chainId
&&
!
ALL_SUPPORTED_CHAIN_IDS
.
includes
(
chainId
))
{
throw
new
ChainIdError
(
'
Switch to a network supported by the Uniswap Protocol.
'
)
}
},
[
chainId
])
// size constraints
const
{
width
}
=
swapWidgetProps
useEffect
(()
=>
{
...
...
src/lib/components/Swap/Toolbar.tsx
View file @
5dec0cf7
import
{
Trans
}
from
'
@lingui/macro
'
import
{
ALL_SUPPORTED_CHAIN_IDS
}
from
'
constants/chains
'
import
{
useAtomValue
}
from
'
jotai/utils
'
import
useActiveWeb3React
from
'
lib/hooks/useActiveWeb3React
'
import
{
AlertTriangle
,
Info
,
largeIconCss
,
Spinner
}
from
'
lib/icons
'
import
{
Field
,
Input
,
inputAtom
,
outputAtom
,
stateAtom
,
swapAtom
}
from
'
lib/state/swap
'
import
styled
,
{
ThemedText
,
ThemeProvider
}
from
'
lib/theme
'
...
...
@@ -65,6 +67,7 @@ export default function Toolbar({ disabled }: { disabled?: boolean }) {
const
input
=
useAtomValue
(
inputAtom
)
const
output
=
useAtomValue
(
outputAtom
)
const
balance
=
mockBalance
const
{
chainId
}
=
useActiveWeb3React
()
const
caption
=
useMemo
(()
=>
{
const
filledInput
=
asFilledInput
(
input
)
...
...
@@ -77,6 +80,14 @@ export default function Toolbar({ disabled }: { disabled?: boolean }) {
</>
)
}
if
(
chainId
&&
!
ALL_SUPPORTED_CHAIN_IDS
.
includes
(
chainId
))
{
return
(
<>
<
AlertTriangle
color=
"secondary"
/>
<
Trans
>
Unsupported network
–
switch to another to trade.
</
Trans
>
</>
)
}
if
(
activeInput
===
Field
.
INPUT
?
filledInput
&&
output
.
token
:
filledOutput
&&
input
.
token
)
{
if
(
!
swap
)
{
return
(
...
...
@@ -109,7 +120,7 @@ export default function Toolbar({ disabled }: { disabled?: boolean }) {
<
Trans
>
Enter an amount
</
Trans
>
</>
)
},
[
activeInput
,
balance
,
disabled
,
input
,
output
,
swap
])
},
[
activeInput
,
balance
,
chainId
,
disabled
,
input
,
output
,
swap
])
return
(
<>
...
...
src/lib/errors.ts
View file @
5dec0cf7
...
...
@@ -4,10 +4,3 @@ export class IntegrationError extends Error {
this
.
name
=
'
Integration Error
'
}
}
export
class
ChainIdError
extends
Error
{
constructor
(
message
:
string
)
{
super
(
message
)
this
.
name
=
'
Unsupported network
'
}
}
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