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
904f6e22
Unverified
Commit
904f6e22
authored
Oct 05, 2022
by
cartcrom
Committed by
GitHub
Oct 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: search attempts route to current chain (#4785)
* finished feature * added L2 icons * removed console.log
parent
66fad96e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
12 deletions
+39
-12
SuggestionRow.tsx
src/components/NavBar/SuggestionRow.tsx
+25
-10
TokenRow.tsx
src/components/Tokens/TokenTable/TokenRow.tsx
+1
-1
util.ts
src/graphql/data/util.ts
+5
-1
navbar.ts
src/nft/types/navbar/navbar.ts
+8
-0
No files found.
src/components/NavBar/SuggestionRow.tsx
View file @
904f6e22
import
clsx
from
'
clsx
'
import
clsx
from
'
clsx
'
import
{
getTokenDetailsURL
}
from
'
graphql/data/util
'
import
{
L2NetworkLogo
,
LogoContainer
}
from
'
components/Tokens/TokenTable/TokenRow
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
getTokenDetailsURL
,
useGlobalChainId
}
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
'
...
@@ -100,6 +102,15 @@ export const CollectionRow = ({
...
@@ -100,6 +102,15 @@ export const CollectionRow = ({
)
)
}
}
function
useBridgedAddress
(
token
:
FungibleToken
):
[
string
|
undefined
,
number
|
undefined
,
string
|
undefined
]
{
const
globalChainId
=
useGlobalChainId
()
const
bridgedAddress
=
globalChainId
?
token
.
extensions
?.
bridgeInfo
?.[
globalChainId
]?.
tokenAddress
:
undefined
if
(
bridgedAddress
&&
globalChainId
)
{
return
[
bridgedAddress
,
globalChainId
,
getChainInfo
(
globalChainId
)?.
circleLogoUrl
]
}
return
[
undefined
,
undefined
,
undefined
]
}
interface
TokenRowProps
{
interface
TokenRowProps
{
token
:
FungibleToken
token
:
FungibleToken
isHovered
:
boolean
isHovered
:
boolean
...
@@ -123,7 +134,8 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, traceE
...
@@ -123,7 +134,8 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, traceE
traceEvent
()
traceEvent
()
},
[
addToSearchHistory
,
toggleOpen
,
token
,
traceEvent
])
},
[
addToSearchHistory
,
toggleOpen
,
token
,
traceEvent
])
const
tokenDetailsPath
=
getTokenDetailsURL
(
token
.
address
,
undefined
,
token
.
chainId
)
const
[
bridgedAddress
,
bridgedChain
,
L2Icon
]
=
useBridgedAddress
(
token
)
const
tokenDetailsPath
=
getTokenDetailsURL
(
bridgedAddress
??
token
.
address
,
undefined
,
bridgedChain
??
token
.
chainId
)
// Close the modal on escape
// Close the modal on escape
useEffect
(()
=>
{
useEffect
(()
=>
{
const
keyDownHandler
=
(
event
:
KeyboardEvent
)
=>
{
const
keyDownHandler
=
(
event
:
KeyboardEvent
)
=>
{
...
@@ -150,14 +162,17 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, traceE
...
@@ -150,14 +162,17 @@ export const TokenRow = ({ token, isHovered, setHoveredIndex, toggleOpen, traceE
>
>
<
Row
style=
{
{
width
:
'
65%
'
}
}
>
<
Row
style=
{
{
width
:
'
65%
'
}
}
>
{
!
brokenImage
&&
token
.
logoURI
?
(
{
!
brokenImage
&&
token
.
logoURI
?
(
<
Box
<
LogoContainer
>
as=
"img"
<
Box
src=
{
token
.
logoURI
.
includes
(
'
ipfs://
'
)
?
uriToHttp
(
token
.
logoURI
)[
0
]
:
token
.
logoURI
}
as=
"img"
alt=
{
token
.
name
}
src=
{
token
.
logoURI
.
includes
(
'
ipfs://
'
)
?
uriToHttp
(
token
.
logoURI
)[
0
]
:
token
.
logoURI
}
className=
{
clsx
(
loaded
?
styles
.
suggestionImage
:
styles
.
imageHolder
)
}
alt=
{
token
.
name
}
onError=
{
()
=>
setBrokenImage
(
true
)
}
className=
{
clsx
(
loaded
?
styles
.
suggestionImage
:
styles
.
imageHolder
)
}
onLoad=
{
()
=>
setLoaded
(
true
)
}
onError=
{
()
=>
setBrokenImage
(
true
)
}
/>
onLoad=
{
()
=>
setLoaded
(
true
)
}
/>
<
L2NetworkLogo
networkUrl=
{
L2Icon
}
size=
"16px"
/>
</
LogoContainer
>
)
:
(
)
:
(
<
Box
className=
{
styles
.
imageHolder
}
/>
<
Box
className=
{
styles
.
imageHolder
}
/>
)
}
)
}
...
...
src/components/Tokens/TokenTable/TokenRow.tsx
View file @
904f6e22
...
@@ -318,7 +318,7 @@ export const L2NetworkLogo = styled.div<{ networkUrl?: string; size?: string }>`
...
@@ -318,7 +318,7 @@ export const L2NetworkLogo = styled.div<{ networkUrl?: string; size?: string }>`
width
:
$
{({
size
})
=>
size
??
'
12px
'
};
width
:
$
{({
size
})
=>
size
??
'
12px
'
};
position
:
absolute
;
position
:
absolute
;
left
:
50
%
;
left
:
50
%
;
top
:
50
%
;
bottom
:
0
;
background
:
url
(
$
{({
networkUrl
})
=>
networkUrl
});
background
:
url
(
$
{({
networkUrl
})
=>
networkUrl
});
background
-
repeat
:
no
-
repeat
;
background
-
repeat
:
no
-
repeat
;
background
-
size
:
$
{({
size
})
=>
(
size
?
`
${
size
}
${
size
}
`
:
'
12px 12px
'
)};
background
-
size
:
$
{({
size
})
=>
(
size
?
`
${
size
}
${
size
}
`
:
'
12px 12px
'
)};
...
...
src/graphql/data/util.ts
View file @
904f6e22
...
@@ -39,8 +39,12 @@ export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: Chain } = {
...
@@ -39,8 +39,12 @@ export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: Chain } = {
[
SupportedChainId
.
OPTIMISM_GOERLI
]:
'
OPTIMISM
'
,
[
SupportedChainId
.
OPTIMISM_GOERLI
]:
'
OPTIMISM
'
,
}
}
export
function
useGlobalChainId
()
{
return
useAppSelector
((
state
)
=>
state
.
application
.
chainId
)
}
export
function
useGlobalChainName
()
{
export
function
useGlobalChainName
()
{
const
chainId
=
use
AppSelector
((
state
)
=>
state
.
application
.
chainId
)
const
chainId
=
use
GlobalChainId
(
)
return
chainId
&&
CHAIN_ID_TO_BACKEND_NAME
[
chainId
]
?
CHAIN_ID_TO_BACKEND_NAME
[
chainId
]
:
'
ETHEREUM
'
return
chainId
&&
CHAIN_ID_TO_BACKEND_NAME
[
chainId
]
?
CHAIN_ID_TO_BACKEND_NAME
[
chainId
]
:
'
ETHEREUM
'
}
}
...
...
src/nft/types/navbar/navbar.ts
View file @
904f6e22
...
@@ -3,6 +3,13 @@ export interface LooksRareRewardsData {
...
@@ -3,6 +3,13 @@ export interface LooksRareRewardsData {
cumulativeLooksAmount
:
string
cumulativeLooksAmount
:
string
cumulativeLooksProof
:
string
[]
cumulativeLooksProof
:
string
[]
}
}
interface
BridgeInfoEntry
{
tokenAddress
?:
string
}
interface
FungibleTokenExtensions
{
bridgeInfo
?:
{
[
chain
:
number
]:
BridgeInfoEntry
}
}
export
interface
FungibleToken
{
export
interface
FungibleToken
{
name
:
string
name
:
string
...
@@ -16,5 +23,6 @@ export interface FungibleToken {
...
@@ -16,5 +23,6 @@ export interface FungibleToken {
price24hChange
:
number
price24hChange
:
number
volume24h
:
number
volume24h
:
number
onDefaultList
?:
boolean
onDefaultList
?:
boolean
extensions
?:
FungibleTokenExtensions
marketCap
:
number
marketCap
:
number
}
}
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