Skip to content

Commit 94f9d8e

Browse files
authored
Merge pull request #9371 from ethereum/addLayerSwap
Add layerswap.io to "How to get onto a layer 2" section
2 parents 0dcee55 + b6b65b8 commit 94f9d8e

File tree

2 files changed

+113
-11
lines changed

2 files changed

+113
-11
lines changed

src/components/Layer2/Layer2Onboard.tsx

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
33
import React, { useState } from "react"
44
import styled from "@emotion/styled"
55
import { useIntl } from "react-intl"
6+
import { Stack, Text } from "@chakra-ui/react"
67

78
// Components
89
import ButtonLink from "../ButtonLink"
@@ -11,6 +12,10 @@ import Translation from "../Translation"
1112
import { StyledSelect as Select } from "../SharedStyledComponents"
1213

1314
// Data
15+
import {
16+
cexOnboardData,
17+
CexOnboard,
18+
} from "../../data/layer-2/cex-layer-2-onboard"
1419
import cexSupport from "../../data/layer-2/cex-layer-2-support.json"
1520

1621
//Utils
@@ -190,6 +195,10 @@ interface ExchangeOption extends Option {
190195
cex: Exchange
191196
}
192197

198+
interface CexOnboardOption extends Option {
199+
cexOnboard: CexOnboard
200+
}
201+
193202
export interface IProps {
194203
layer2DataCombined: Array<Layer2>
195204
ethIcon: IGatsbyImageData
@@ -203,8 +212,13 @@ const Layer2Onboard: React.FC<IProps> = ({
203212
}) => {
204213
const intl = useIntl()
205214

206-
const [selectedExchange, setSelectedExchange] = useState<Exchange>()
207-
const [selectedL2, setSelectedL2] = useState<Layer2>()
215+
const [selectedCexOnboard, setSelectedCexOnboard] = useState<
216+
CexOnboard | undefined
217+
>(undefined)
218+
const [selectedExchange, setSelectedExchange] = useState<
219+
Exchange | undefined
220+
>(undefined)
221+
const [selectedL2, setSelectedL2] = useState<Layer2 | undefined>(undefined)
208222

209223
const layer2Options: Array<Layer2Option> = layer2DataCombined.map((l2) => {
210224
return {
@@ -224,6 +238,50 @@ const Layer2Onboard: React.FC<IProps> = ({
224238
}
225239
)
226240

241+
const cexOnboardOptions: Array<CexOnboardOption> = cexOnboardData.map(
242+
(cexOnboard: CexOnboard) => {
243+
return {
244+
label: cexOnboard.name,
245+
value: cexOnboard.name,
246+
cexOnboard: cexOnboard,
247+
}
248+
}
249+
)
250+
251+
const formatGroupLabel = (data) => {
252+
return data.label ? (
253+
<Stack borderTop="2px solid" m={0}>
254+
<Text mb={0} mt={2} textTransform="none" color="theme.colors.text">
255+
{data.label}
256+
</Text>
257+
</Stack>
258+
) : (
259+
<></>
260+
)
261+
}
262+
263+
const selectExchangeOnboard = (option: ExchangeOption | CexOnboardOption) => {
264+
if (Object.hasOwn(option, "cex")) {
265+
trackCustomEvent({
266+
eventCategory: `Selected cex to onboard`,
267+
eventAction: `Clicked`,
268+
eventName: `${option.cex.name} selected`,
269+
eventValue: `${option.cex.name}`,
270+
})
271+
setSelectedExchange(option.cex)
272+
setSelectedCexOnboard(undefined)
273+
} else {
274+
trackCustomEvent({
275+
eventCategory: `Selected cexOnboard to onboard`,
276+
eventAction: `Clicked`,
277+
eventName: `${option.cexOnboard.name} selected`,
278+
eventValue: `${option.cexOnboard.name}`,
279+
})
280+
setSelectedCexOnboard(option.cexOnboard)
281+
setSelectedExchange(undefined)
282+
}
283+
}
284+
227285
return (
228286
<Content>
229287
<Description>
@@ -308,20 +366,24 @@ const Layer2Onboard: React.FC<IProps> = ({
308366
<StyledSelect
309367
className="react-select-container"
310368
classNamePrefix="react-select"
311-
options={cexSupportOptions}
312-
onChange={(selectedOption: ExchangeOption) => {
313-
trackCustomEvent({
314-
eventCategory: `Selected cex to onboard`,
315-
eventAction: `Clicked`,
316-
eventName: `${selectedOption.cex.name} selected`,
317-
eventValue: `${selectedOption.cex.name}`,
318-
})
319-
setSelectedExchange(selectedOption.cex)
369+
options={[
370+
{
371+
options: [...cexSupportOptions],
372+
},
373+
{
374+
label:
375+
"Don't see you exchange? Use dapps to bridge directly from exchanges to layer 2.",
376+
options: [...cexOnboardOptions],
377+
},
378+
]}
379+
onChange={(selectedOption: ExchangeOption | CexOnboardOption) => {
380+
selectExchangeOnboard(selectedOption)
320381
}}
321382
placeholder={translateMessageId(
322383
"layer-2-onboard-exchange-input-placeholder",
323384
intl
324385
)}
386+
formatGroupLabel={formatGroupLabel}
325387
/>
326388
</RightSelect>
327389
<EthLogo>
@@ -360,6 +422,21 @@ const Layer2Onboard: React.FC<IProps> = ({
360422
</SelectedContainer>
361423
</RightSelected>
362424
)}
425+
{selectedCexOnboard && (
426+
<RightSelected>
427+
<SelectedContainer>
428+
<H3>Supported exchanges</H3>
429+
<p>{selectedCexOnboard.cex_support.join(", ")}</p>
430+
<H3>Supported layer 2s</H3>
431+
<p>{selectedCexOnboard.network_support.join(", ")}</p>
432+
<ButtonLink to={selectedCexOnboard.url}>
433+
{`${translateMessageId("layer-2-go-to", intl)} ${
434+
selectedCexOnboard.name
435+
}`}
436+
</ButtonLink>
437+
</SelectedContainer>
438+
</RightSelected>
439+
)}
363440
</Grid>
364441
</Content>
365442
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface CexOnboard {
2+
name: string
3+
url: string
4+
cex_support: string[]
5+
network_support: string[]
6+
}
7+
8+
export const cexOnboardData: CexOnboard[] = [
9+
{
10+
name: "Layerswap",
11+
url: "https://layerswap.io/",
12+
cex_support: [
13+
"Binance",
14+
"Bitfinex",
15+
"Bittrex Global",
16+
"Coinbase",
17+
"Crypto.com",
18+
"Huobi",
19+
"Kraken",
20+
"Kucoin",
21+
"OKX",
22+
],
23+
network_support: ["Arbitrum", "Loopring", "Optimism", "zkSpace", "zkSync"],
24+
},
25+
]

0 commit comments

Comments
 (0)