Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/enable anchorage on mainnet #480

Merged
merged 25 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"dependencies": {
"@apollo/client": "^3.5.10",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@bobanetwork/graphql-utils": "^1.0.45",
"@bobanetwork/graphql-utils": "^1.1.9",
"@bobanetwork/light-bridge-chains": "^1.0.9",
"@bobanetwork/register": "^0.0.22",
"@bobanetwork/register": "^0.0.25",
"@bobanetwork/sdk": "1.0.7",
"@cfx-kit/wallet-avatar": "^0.0.5",
"@emotion/styled": "^11.11.0",
Expand Down
2 changes: 1 addition & 1 deletion src/api/omgxWatcherAxios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios'

// TODO: remove once BNB migrated to anchorage.
export default (networkConfig) => {
const watcherUrl = networkConfig['OMGX_WATCHER_URL']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`ApplicationBanner should match snapshot when alerts are enable 1`] = `
data-testid="banner-item"
>
<div
class="sc-ikkxIA"
class="sc-ikkxIA kkCcKf"
>
<p>
Message update 1
Expand Down Expand Up @@ -49,7 +49,7 @@ exports[`ApplicationBanner should match snapshot when alerts are enable 1`] = `
data-testid="banner-item"
>
<div
class="sc-ikkxIA"
class="sc-ikkxIA kkCcKf"
>
<p
class="sc-imWYAI dZiXLh sc-fUnMCh iwiHIW"
Expand Down
5 changes: 3 additions & 2 deletions src/components/ApplicationBanner/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export const bannerAlerts = (): IAppAlert[] => [
canClose: false,
Component: () => (
<BannerText>
In preparation for the release of Boba Light Bridge, the Earn program is
being sunset. To withdraw funds,{' '}
The earn program is being phased out as we introduce the Boba Light
Bridge. To initiate a withdrawal of funds from the liquidity pool, To
withdraw funds{' '}
<a href="/earn" target="blank">
CLICK HERE
</a>
Expand Down
8 changes: 0 additions & 8 deletions src/components/ApplicationBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ import {
} from './styles'
import { bannerAlerts } from './data'
import { IAppAlert } from './types'
import { useNetworkInfo } from 'hooks/useNetworkInfo'
import { ChevronLeft, ChevronRight } from '@mui/icons-material'

// @todo disable banner for sepolia.
// remove use of isAnchorageEnabled
const ApplicationBanner = () => {
const [alerts, setAlerts] = useState<IAppAlert[]>([])
const [storageChange, setStorageChange] = useState(false)
const { isAnchorageEnabled } = useNetworkInfo()

const [index, setIndex] = useState(0)

Expand Down Expand Up @@ -60,10 +56,6 @@ const ApplicationBanner = () => {
setStorageChange(!storageChange)
}

if (!!isAnchorageEnabled) {
return <></>
}

if (alerts && !alerts.length) {
return <></>
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/ApplicationBanner/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export const BannerContainer = styled('div')`
}
}
`
export const BannerContent = styled('div')``
export const BannerContent = styled('div')`
padding: 0px 20px;
`

export const BannerAction = styled('div')`
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion src/components/global/svg/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactSVG } from 'react-svg'
import { SvgTypes } from './types'

export const Svg: React.FC<SvgTypes> = ({
src,
src = '',
fill = 'current',
stroke = 'current',
onClick,
Expand Down
6 changes: 1 addition & 5 deletions src/components/notificationBanner/bannerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ interface BannerContent {
*
**/

export const BannerConfig: Record<string, BannerContent> = {
[Network.ETHEREUM]: {
message: `Note: Classic withdrawals will be temporarily suspended for a duration of 10 days beginning April 6th in preparation for our Anchorage update! Light bridging will remain available throughout the period.`,
},
}
export const BannerConfig: Record<string, BannerContent> = {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
exports[`BridgeAction AccountEnabled is false should match snapshot 1`] = `
<DocumentFragment>
<div
class="sc-hzhJZQ crgmVn"
class="sc-feUZmu fKaVOM"
>
<button
class="sc-jlZhew fFYrTq sc-fHjqPf"
class="sc-jlZhew fFYrTq sc-fUnMCh"
data-testid="connect-btn"
label="[object Object]"
style="width: 100%;"
Expand All @@ -26,10 +26,10 @@ exports[`BridgeAction AccountEnabled is false should match snapshot 1`] = `
exports[`BridgeAction AccountEnabled is true should match snapshot 1`] = `
<DocumentFragment>
<div
class="sc-hzhJZQ crgmVn"
class="sc-feUZmu fKaVOM"
>
<button
class="sc-jlZhew fFYrTq sc-fHjqPf"
class="sc-jlZhew fFYrTq sc-fUnMCh"
data-testid="bridge-btn"
label="[object Object]"
style="width: 100%;"
Expand Down
5 changes: 0 additions & 5 deletions src/containers/Bridging/BridgeAction/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { setConnect } from 'actions/setupAction'
import { openModal } from 'actions/uiAction'
import { Heading } from 'components/global'
import { useNetworkInfo } from 'hooks/useNetworkInfo'
import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import {
Expand All @@ -18,12 +17,8 @@ const BridgeAction = () => {
const token = useSelector(selectTokenToBridge())
const amountToBridge = useSelector(selectAmountToBridge())
const bridgeAlerts = useSelector(selectBridgeAlerts())
const { isClassicWithdrawalDisabled } = useNetworkInfo()

const isBridgeActionDisabled = () => {
if (isClassicWithdrawalDisabled) {
return isClassicWithdrawalDisabled
}
const hasError = bridgeAlerts.find((alert: any) => alert.type === 'error')
return !token || !amountToBridge || hasError
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ exports[`BridgeHeader should match snapshot when connected to TESTNET 1`] = `
class="sc-eDPEul jXgUQt"
>
Bridge
<div
class="sc-fPXMVe eTa-Dsg"
data-mui-internal-clone-element="true"
data-testid="tooltip-btn"
style="margin-left: 5px;"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-1t96nry-MuiSvgIcon-root"
data-testid="HelpOutlineOutlinedIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M11 18h2v-2h-2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"
/>
</svg>
</div>
</h2>
<div
class="sc-fPXMVe hPlmSk"
Expand Down
36 changes: 17 additions & 19 deletions src/containers/Bridging/BridgeHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const ValueStyle = styled.span`
const BridgeHeader = () => {
const dispatch = useDispatch<any>()
const theme: any = useTheme()
const { isAnchorageEnabled } = useNetworkInfo()

const iconColor =
theme.name === 'light' ? theme.colors.gray[600] : theme.colors.gray[100]
Expand All @@ -38,6 +37,7 @@ const BridgeHeader = () => {
dispatch(openModal('settingsModal'))
}

// TODO: update the copy when the anchorage bridge is enabled.
const ClassicBridgeInfo = () => {
return (
<>
Expand Down Expand Up @@ -71,24 +71,22 @@ const BridgeHeader = () => {
<BridgeHeaderWrapper>
<Heading variant="h2">
Bridge
{isAnchorageEnabled ? null : (
<Tooltip
data-testid="tooltip-btn"
title={
<>
<ClassicBridgeInfo />
<LightBridgeInfo />
</>
}
>
<IconWrapper inline={true} style={{ marginLeft: '5px' }}>
<HelpOutlineOutlined
fontSize="small"
sx={{ cursor: 'pointer', color: iconColor }}
/>
</IconWrapper>
</Tooltip>
)}
<Tooltip
data-testid="tooltip-btn"
title={
<>
<ClassicBridgeInfo />
<LightBridgeInfo />
</>
}
>
<IconWrapper inline={true} style={{ marginLeft: '5px' }}>
<HelpOutlineOutlined
fontSize="small"
sx={{ cursor: 'pointer', color: iconColor }}
/>
</IconWrapper>
</Tooltip>
</Heading>
<IconWrapper>
<GearIcon
Expand Down
27 changes: 9 additions & 18 deletions src/containers/Bridging/BridgeInput/Fee/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ const Fee = (props: Props) => {
const feePriceRatio = useSelector(selectBobaPriceRatio())
const exitFee = useSelector(selectExitFee)

const { isAnchorageEnabled } = useNetworkInfo()
const { isAnchorageEnabled, isActiveNetworkBnb } = useNetworkInfo()

const { amount: amountToReceive } = useAmountToReceive()

const [gasFee, setGasFee] = useState('')

const estimateTime = () => {
if (isAnchorageEnabled && layer === LAYER.L1) {
return '~ 3mins'
} else if (bridgeType === BRIDGE_TYPE.CLASSIC) {
if (bridgeType === BRIDGE_TYPE.CLASSIC) {
if (layer === LAYER.L1) {
return '13 ~ 14mins.'
} else {
Expand Down Expand Up @@ -104,27 +102,20 @@ const Fee = (props: Props) => {
<Label>Estimated time</Label>
<Label>{estimateTime()}</Label>
</InfoRow>
<InfoRow>
<Label>Destination gas fee</Label>
<Label>{gasFee}</Label>
</InfoRow>
{!isAnchorageEnabled &&
{isAnchorageEnabled ? null : (
<InfoRow>
<Label>Gas fee</Label>
<Label>{gasFee}</Label>
</InfoRow>
)}
{isActiveNetworkBnb &&
layer === LAYER.L2 &&
bridgeType !== BRIDGE_TYPE.LIGHT ? (
<InfoRow>
<Label>xChain Relay Fee</Label>
<Label>{exitFee} BOBA</Label>
</InfoRow>
) : null}
<InfoRow>
<Label>Bridge Fee</Label>
<Label>
{(layer === LAYER.L1 && bridgeType !== BRIDGE_TYPE.LIGHT
? l2FeeRateN
: l1FeeRateN) || 0}
%
</Label>
</InfoRow>
<InfoRow>
<Label
color={`${
Expand Down
8 changes: 7 additions & 1 deletion src/containers/Bridging/BridgeInput/TokenInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { InputContainer, InputContainerLabel } from './index.styles'
import { purgeBridgeAlert, setAmountToBridge } from 'actions/bridgeAction'
import { BRIDGE_TYPE } from 'containers/Bridging/BridgeTypeSelector'
import networkService from 'services/networkService'
import { useNetworkInfo } from 'hooks/useNetworkInfo'

interface Props {}

Expand All @@ -31,6 +32,7 @@ const TokenInput = (props: Props) => {
const feeUseBoba = useSelector(selectBobaFeeChoice())
const feePriceRatio = useSelector(selectBobaPriceRatio())
const exitFee = useSelector(selectExitFee)
const { isActiveNetworkBnb } = useNetworkInfo()

const [tokenAmount, setTokenAmount] = useState('')
const [maxBalance, setMaxBalance] = useState<any>()
Expand All @@ -55,7 +57,11 @@ const TokenInput = (props: Props) => {
setZeroBalanceError(false)
}

if (layer === LAYER.L2 && bridgeType !== BRIDGE_TYPE.LIGHT) {
if (
layer === LAYER.L2 &&
bridgeType !== BRIDGE_TYPE.LIGHT &&
!!isActiveNetworkBnb
) {
let cost = classicExitCost || 0
if (bridgeType === BRIDGE_TYPE.FAST) {
cost = fastExitCost || 0
Expand Down
2 changes: 0 additions & 2 deletions src/containers/Bridging/BridgeTypeSelector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { setBridgeType } from 'actions/bridgeAction'
import { setNetwork } from 'actions/networkAction'
import { useNetworkInfo } from 'hooks/useNetworkInfo'
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import {
Expand Down Expand Up @@ -30,7 +29,6 @@ const BridgeTypeSelector = () => {
const network = useSelector(selectNetwork())
const isOnLimitedNetwork = networkLimitedAvailability(networkType, network)
const activeNetworkType = useSelector(selectActiveNetworkType())
const { isAnchorageEnabled } = useNetworkInfo()

const isMainnet =
useSelector(selectActiveNetworkType()) === NetworkType.MAINNET
Expand Down
Loading
Loading