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
868edc60
Unverified
Commit
868edc60
authored
Sep 26, 2022
by
cartcrom
Committed by
GitHub
Sep 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: error when hitting enter on search (#4721)
* fixed issue * fixed comment
parent
d8c84a91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
18 deletions
+29
-18
SuggestionRow.tsx
src/components/NavBar/SuggestionRow.tsx
+5
-4
TokenRow.tsx
src/components/Tokens/TokenTable/TokenRow.tsx
+2
-3
Token.ts
src/graphql/data/Token.ts
+3
-3
TopTokens.ts
src/graphql/data/TopTokens.ts
+6
-6
util.ts
src/graphql/data/util.ts
+13
-2
No files found.
src/components/NavBar/SuggestionRow.tsx
View file @
868edc60
import
clsx
from
'
clsx
'
import
clsx
from
'
clsx
'
import
{
useGlobalChainName
}
from
'
graphql/data/util
'
import
{
getTokenDetailsURL
}
from
'
graphql/data/util
'
import
uriToHttp
from
'
lib/utils/uriToHttp
'
import
uriToHttp
from
'
lib/utils/uriToHttp
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Column
,
Row
}
from
'
nft/components/Flex
'
import
{
Column
,
Row
}
from
'
nft/components/Flex
'
...
@@ -112,12 +112,13 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, index
...
@@ -112,12 +112,13 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, index
toggleOpen
()
toggleOpen
()
},
[
addToSearchHistory
,
toggleOpen
,
token
])
},
[
addToSearchHistory
,
toggleOpen
,
token
])
const
tokenDetailsPath
=
getTokenDetailsURL
(
token
.
address
,
undefined
,
token
.
chainId
)
// Close the modal on escape
// Close the modal on escape
useEffect
(()
=>
{
useEffect
(()
=>
{
const
keyDownHandler
=
(
event
:
KeyboardEvent
)
=>
{
const
keyDownHandler
=
(
event
:
KeyboardEvent
)
=>
{
if
(
event
.
key
===
'
Enter
'
&&
isHovered
)
{
if
(
event
.
key
===
'
Enter
'
&&
isHovered
)
{
event
.
preventDefault
()
event
.
preventDefault
()
navigate
(
`/tokens/
${
token
.
address
}
`
)
navigate
(
tokenDetailsPath
)
handleClick
()
handleClick
()
}
}
}
}
...
@@ -125,11 +126,11 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, index
...
@@ -125,11 +126,11 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, index
return
()
=>
{
return
()
=>
{
document
.
removeEventListener
(
'
keydown
'
,
keyDownHandler
)
document
.
removeEventListener
(
'
keydown
'
,
keyDownHandler
)
}
}
},
[
toggleOpen
,
isHovered
,
token
,
navigate
,
handleClick
])
},
[
toggleOpen
,
isHovered
,
token
,
navigate
,
handleClick
,
tokenDetailsPath
])
return
(
return
(
<
Link
<
Link
to=
{
`/tokens/${useGlobalChainName().toLowerCase()}/${token.address}`
}
to=
{
tokenDetailsPath
}
onClick=
{
handleClick
}
onClick=
{
handleClick
}
onMouseEnter=
{
()
=>
!
isHovered
&&
setHoveredIndex
(
index
)
}
onMouseEnter=
{
()
=>
!
isHovered
&&
setHoveredIndex
(
index
)
}
onMouseLeave=
{
()
=>
isHovered
&&
setHoveredIndex
(
undefined
)
}
onMouseLeave=
{
()
=>
isHovered
&&
setHoveredIndex
(
undefined
)
}
...
...
src/components/Tokens/TokenTable/TokenRow.tsx
View file @
868edc60
...
@@ -7,7 +7,7 @@ import CurrencyLogo from 'components/CurrencyLogo'
...
@@ -7,7 +7,7 @@ import CurrencyLogo from 'components/CurrencyLogo'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
FavoriteTokensVariant
,
useFavoriteTokensFlag
}
from
'
featureFlags/flags/favoriteTokens
'
import
{
FavoriteTokensVariant
,
useFavoriteTokensFlag
}
from
'
featureFlags/flags/favoriteTokens
'
import
{
TokenSortMethod
,
TopToken
}
from
'
graphql/data/TopTokens
'
import
{
TokenSortMethod
,
TopToken
}
from
'
graphql/data/TopTokens
'
import
{
CHAIN_NAME_TO_CHAIN_ID
,
TimePeriod
}
from
'
graphql/data/util
'
import
{
CHAIN_NAME_TO_CHAIN_ID
,
getTokenDetailsURL
,
TimePeriod
}
from
'
graphql/data/util
'
import
{
useAtomValue
}
from
'
jotai/utils
'
import
{
useAtomValue
}
from
'
jotai/utils
'
import
{
ForwardedRef
,
forwardRef
}
from
'
react
'
import
{
ForwardedRef
,
forwardRef
}
from
'
react
'
import
{
CSSProperties
,
ReactNode
}
from
'
react
'
import
{
CSSProperties
,
ReactNode
}
from
'
react
'
...
@@ -488,7 +488,6 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -488,7 +488,6 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
const
arrow
=
delta
?
getDeltaArrow
(
delta
)
:
null
const
arrow
=
delta
?
getDeltaArrow
(
delta
)
:
null
const
formattedDelta
=
delta
?
formatDelta
(
delta
)
:
null
const
formattedDelta
=
delta
?
formatDelta
(
delta
)
:
null
const
sortAscending
=
useAtomValue
(
sortAscendingAtom
)
const
sortAscending
=
useAtomValue
(
sortAscendingAtom
)
const
{
chainName
}
=
useParams
<
{
chainName
?:
string
}
>
()
const
exploreTokenSelectedEventProperties
=
{
const
exploreTokenSelectedEventProperties
=
{
chain_id
:
filterNetwork
,
chain_id
:
filterNetwork
,
...
@@ -504,7 +503,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -504,7 +503,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
return
(
return
(
<
div
ref=
{
ref
}
>
<
div
ref=
{
ref
}
>
<
StyledLink
<
StyledLink
to=
{
`/tokens/${chainName}/${tokenAddress}`
}
to=
{
getTokenDetailsURL
(
token
.
address
,
token
.
chain
)
}
onClick=
{
()
=>
sendAnalyticsEvent
(
EventName
.
EXPLORE_TOKEN_ROW_CLICKED
,
exploreTokenSelectedEventProperties
)
}
onClick=
{
()
=>
sendAnalyticsEvent
(
EventName
.
EXPLORE_TOKEN_ROW_CLICKED
,
exploreTokenSelectedEventProperties
)
}
>
>
<
TokenRow
<
TokenRow
...
...
src/graphql/data/Token.ts
View file @
868edc60
...
@@ -38,10 +38,10 @@ The difference between Token and TokenProject:
...
@@ -38,10 +38,10 @@ The difference between Token and TokenProject:
const
tokenQuery
=
graphql
`
const
tokenQuery
=
graphql
`
query TokenQuery($contract: ContractInput!, $duration: HistoryDuration!) {
query TokenQuery($contract: ContractInput!, $duration: HistoryDuration!) {
tokens(contracts: [$contract]) {
tokens(contracts: [$contract]) {
id
id
@required(action: LOG)
name
name
chain
chain
@required(action: LOG)
address
address
@required(action: LOG)
symbol
symbol
market(currency: USD) {
market(currency: USD) {
totalValueLocked {
totalValueLocked {
...
...
src/graphql/data/TopTokens.ts
View file @
868edc60
...
@@ -27,10 +27,10 @@ export function usePrefetchTopTokens(duration: HistoryDuration, chain: Chain) {
...
@@ -27,10 +27,10 @@ export function usePrefetchTopTokens(duration: HistoryDuration, chain: Chain) {
const
topTokens100Query
=
graphql
`
const
topTokens100Query
=
graphql
`
query TopTokens100Query($duration: HistoryDuration!, $chain: Chain!) {
query TopTokens100Query($duration: HistoryDuration!, $chain: Chain!) {
topTokens(pageSize: 100, page: 1, chain: $chain) {
topTokens(pageSize: 100, page: 1, chain: $chain) {
id
id
@required(action: LOG)
name
name
chain
chain
@required(action: LOG)
address
address
@required(action: LOG)
symbol
symbol
market(currency: USD) {
market(currency: USD) {
totalValueLocked {
totalValueLocked {
...
@@ -251,10 +251,10 @@ export function useTopTokens(chain: Chain): UseTopTokensReturnValue {
...
@@ -251,10 +251,10 @@ export function useTopTokens(chain: Chain): UseTopTokensReturnValue {
export
const
tokensQuery
=
graphql
`
export
const
tokensQuery
=
graphql
`
query TopTokens_TokensQuery($contracts: [ContractInput!]!, $duration: HistoryDuration!) {
query TopTokens_TokensQuery($contracts: [ContractInput!]!, $duration: HistoryDuration!) {
tokens(contracts: $contracts) {
tokens(contracts: $contracts) {
id
id
@required(action: LOG)
name
name
chain
chain
@required(action: LOG)
address
address
@required(action: LOG)
symbol
symbol
market(currency: USD) {
market(currency: USD) {
totalValueLocked {
totalValueLocked {
...
...
src/graphql/data/util.ts
View file @
868edc60
...
@@ -29,7 +29,7 @@ export function toHistoryDuration(timePeriod: TimePeriod): HistoryDuration {
...
@@ -29,7 +29,7 @@ export function toHistoryDuration(timePeriod: TimePeriod): HistoryDuration {
}
}
}
}
export
const
CHAIN_ID
S
_TO_BACKEND_NAME
:
{
[
key
:
number
]:
Chain
}
=
{
export
const
CHAIN_ID_TO_BACKEND_NAME
:
{
[
key
:
number
]:
Chain
}
=
{
[
SupportedChainId
.
MAINNET
]:
'
ETHEREUM
'
,
[
SupportedChainId
.
MAINNET
]:
'
ETHEREUM
'
,
[
SupportedChainId
.
GOERLI
]:
'
ETHEREUM_GOERLI
'
,
[
SupportedChainId
.
GOERLI
]:
'
ETHEREUM_GOERLI
'
,
[
SupportedChainId
.
POLYGON
]:
'
POLYGON
'
,
[
SupportedChainId
.
POLYGON
]:
'
POLYGON
'
,
...
@@ -44,7 +44,7 @@ export const CHAIN_IDS_TO_BACKEND_NAME: { [key: number]: Chain } = {
...
@@ -44,7 +44,7 @@ export const CHAIN_IDS_TO_BACKEND_NAME: { [key: number]: Chain } = {
export
function
useGlobalChainName
()
{
export
function
useGlobalChainName
()
{
const
chainId
=
useAppSelector
((
state
)
=>
state
.
application
.
chainId
)
const
chainId
=
useAppSelector
((
state
)
=>
state
.
application
.
chainId
)
return
chainId
&&
CHAIN_ID
S_TO_BACKEND_NAME
[
chainId
]
?
CHAIN_IDS
_TO_BACKEND_NAME
[
chainId
]
:
'
ETHEREUM
'
return
chainId
&&
CHAIN_ID
_TO_BACKEND_NAME
[
chainId
]
?
CHAIN_ID
_TO_BACKEND_NAME
[
chainId
]
:
'
ETHEREUM
'
}
}
export
const
URL_CHAIN_PARAM_TO_BACKEND
:
{
[
key
:
string
]:
Chain
}
=
{
export
const
URL_CHAIN_PARAM_TO_BACKEND
:
{
[
key
:
string
]:
Chain
}
=
{
...
@@ -76,3 +76,14 @@ export function isValidBackendChainName(chainName: string | undefined): chainNam
...
@@ -76,3 +76,14 @@ export function isValidBackendChainName(chainName: string | undefined): chainNam
}
}
return
false
return
false
}
}
export
function
getTokenDetailsURL
(
address
:
string
,
chainName
?:
Chain
,
chainId
?:
number
)
{
if
(
chainName
)
{
return
`/tokens/
${
chainName
.
toLowerCase
()}
/
${
address
}
`
}
else
if
(
chainId
)
{
const
chainName
=
CHAIN_ID_TO_BACKEND_NAME
[
chainId
]
return
chainName
?
`/tokens/
${
chainName
.
toLowerCase
()}
/
${
address
}
`
:
''
}
else
{
return
''
}
}
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