Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import React, { FC, useCallback, useMemo } from 'react';
import React, { FC, useCallback } from 'react';

import classNames from 'classnames';
import { t } from 'i18next';

import { ChainIds } from '@sovryn/ethers-provider';
import { Badge, Menu, MenuItem, Tooltip } from '@sovryn/ui';
import { Menu, MenuItem, Tooltip } from '@sovryn/ui';

import { POWPEG, RSK_FAUCET } from '../../../../../constants/general';
import { POWPEG } from '../../../../../constants/general';
import { BOB } from '../../../../../constants/infrastructure/bob';
import {
BABELFISH_APP_LINK,
SEPOLIA_FAUCET_LINK,
} from '../../../../../constants/links';
import { useWalletConnect } from '../../../../../hooks';
import { useAssetBalance } from '../../../../../hooks/useAssetBalance';
import { useCurrentChain } from '../../../../../hooks/useChainStore';
import { useIsMobile } from '../../../../../hooks/useIsMobile';
import { sharedState } from '../../../../../store/rxjs/shared-state';
import { Environments } from '../../../../../types/global';
import { COMMON_SYMBOLS } from '../../../../../utils/asset';
import { isBobChain, isRskChain } from '../../../../../utils/chain';
import {
isMainnet,
isTestnetFastBtcEnabled,
} from '../../../../../utils/helpers';
import { isMainnet } from '../../../../../utils/helpers';
import { NavDropdown } from '../NavItem/NavDropdown';

export type BridgeMenuItemProps = {
Expand All @@ -33,17 +28,8 @@ export type BridgeMenuItemProps = {
export const BridgeMenuItem: FC<BridgeMenuItemProps> = ({ dataAttribute }) => {
const { isMobile } = useIsMobile();
const chainId = useCurrentChain();
const { balance } = useAssetBalance(
isRskChain(chainId) ? COMMON_SYMBOLS.BTC : COMMON_SYMBOLS.ETH,
chainId,
);
const { account } = useWalletConnect();
const hasRbtcBalance = useMemo(() => Number(balance) !== 0, [balance]);

const enableFastBtc = useMemo(
() => isMainnet() || (!isMainnet() && isTestnetFastBtcEnabled()),
[],
);
const { account } = useWalletConnect();

const handleEthClicked = useCallback(() => {
if (isBobChain(chainId)) {
Expand All @@ -56,20 +42,6 @@ export const BridgeMenuItem: FC<BridgeMenuItemProps> = ({ dataAttribute }) => {
}
}, [chainId]);

const handleBtcClicked = useCallback(() => {
if (isBobChain(chainId)) {
window.open(
BOB.bridge[isMainnet() ? Environments.Mainnet : Environments.Testnet],
'_blank',
);
} else if (isRskChain(chainId)) {
if (enableFastBtc) sharedState.actions.openFastBtcDialog(!hasRbtcBalance);
else window.open(RSK_FAUCET, '_blank');
} else if (chainId === ChainIds.SEPOLIA) {
window.open(SEPOLIA_FAUCET_LINK, '_blank');
}
}, [hasRbtcBalance, enableFastBtc, chainId]);

const handleRunesClick = useCallback(() => {
sharedState.actions.openRuneBridgeDialog();
}, []);
Expand Down Expand Up @@ -139,24 +111,6 @@ export const BridgeMenuItem: FC<BridgeMenuItemProps> = ({ dataAttribute }) => {
})}
onClick={handleEthClicked}
/>
<MenuItem
key={t('header.nav.bridges.subMenu.btcBridge')}
text={
<span className="flex items-center gap-1.5">
{t('header.nav.bridges.subMenu.btcBridge')}
<Badge content={t('common.deprecated')} className="px-1.5" />
</span>
}
label={
!isMobile &&
t('header.nav.bridges.subMenu.btcBridgeDescription')
}
dataAttribute={`dapp-menu-btcBridge`}
className={classNames('no-underline', {
hidden: !isRskChain(chainId),
})}
onClick={handleBtcClicked}
/>
<MenuItem
key={t('header.nav.bridges.subMenu.erc20Bridge')}
text={t('header.nav.bridges.subMenu.erc20Bridge')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import React, { FC, useCallback, useMemo } from 'react';
import React, { FC } from 'react';

import { t } from 'i18next';

import { Button, ButtonSize, ButtonStyle, Paragraph } from '@sovryn/ui';
import { Button, ButtonStyle, Paragraph } from '@sovryn/ui';

import { ConnectWalletButton } from '../../../../2_molecules';
import { useWalletConnect } from '../../../../../hooks';
import { useAssetBalance } from '../../../../../hooks/useAssetBalance';
import { translations } from '../../../../../locales/i18n';
import { sharedState } from '../../../../../store/rxjs/shared-state';
import { GETTING_STARTED_URL } from './GetStarted.constants';
import { GetStartedSteps } from './components/GetStartedSteps/GetStartedSteps';
import { COMMON_SYMBOLS } from '../../../../../utils/asset';

const pageTranslations = translations.landingPage.getStarted;

export const GetStarted: FC = () => {
const { connectWallet, disconnectWallet, account, pending } =
useWalletConnect();
const { balance } = useAssetBalance(COMMON_SYMBOLS.BTC);

const hasRbtcBalance = useMemo(() => Number(balance) !== 0, [balance]);

const handleFastBtcClick = useCallback(
() => sharedState.actions.openFastBtcDialog(!hasRbtcBalance),
[hasRbtcBalance],
);

return (
<div className="max-w-full xl:max-w-md">
Expand All @@ -35,23 +24,14 @@ export const GetStarted: FC = () => {
/>
<GetStartedSteps />
<div className="flex m-6">
{account ? (
<Button
text={t(pageTranslations.actions.fundYourWallet)}
onClick={handleFastBtcClick}
size={ButtonSize.large}
dataAttribute="get-started-section-fund"
/>
) : (
<ConnectWalletButton
onConnect={connectWallet}
onDisconnect={disconnectWallet}
address={account}
pending={pending}
dataAttribute="get-started-section-connect"
className="h-10 py-3 px-6"
/>
)}
<ConnectWalletButton
onConnect={connectWallet}
onDisconnect={disconnectWallet}
address={account}
pending={pending}
dataAttribute="get-started-section-connect"
className="h-10 py-3 px-6"
/>
<Button
text={t(pageTranslations.actions.learnMore)}
className="ml-6"
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
},
"third": {
"title": "How do I get funds into Sovryn?",
"description": "On BOB, you can use the bridge interface to bring in assets from Ethereum and to bridge in BTC from the bitcoin network.<br/><br/>On Rootstock, you can bridge in BTC from the bitcoin network with FastBTC. You can also bridge in stablecoins with Babelfish and other assets from Ethereum and BSC using the Sovryn bridge."
"description": "On BOB, you can use the bridge interface to bring in assets from Ethereum and to bridge in BTC from the bitcoin network.<br/><br/>On Rootstock, you can bridge in stablecoins with Babelfish and other assets from Ethereum and BSC using the Sovryn bridge."
},
"fourth": {
"title": "What is the native gas token?",
Expand Down Expand Up @@ -2108,4 +2108,4 @@
"invalidNumberFormat": "Invalid number format."
}
}
}
}