-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
242 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
apps/frontend/src/app/5_pages/BobGateway/BobGateway.utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
import { GatewaySDK } from '@gobob/bob-sdk'; | ||
import { GatewayQuoteParams, GatewaySDK } from '@gobob/bob-sdk'; | ||
import { QueryClient } from '@tanstack/react-query'; | ||
|
||
export const bobGateway = new GatewaySDK('bob'); | ||
|
||
export const strategies: GatewayQuoteParams[] = [ | ||
{ | ||
fromToken: 'BTC', | ||
fromChain: 'Bitcoin', | ||
fromUserAddress: 'bc1qafk4yhqvj4wep57m62dgrmutldusqde8adh20d', | ||
toChain: 'BOB', | ||
toUserAddress: '0x2D2E86236a5bC1c8a5e5499C517E17Fb88Dbc18c', | ||
toToken: 'tBTC', // or e.g. "SolvBTC" | ||
amount: 10000000, // 0.1 BTC | ||
gasRefill: 10000, // 0.0001 BTC. The amount of BTC to swap for ETH for tx fees. | ||
}, | ||
]; | ||
|
||
export const queryClient = new QueryClient(); |
82 changes: 82 additions & 0 deletions
82
apps/frontend/src/app/5_pages/BobGateway/components/BitcoinWallet/BitcoinWallet.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { useAccount, useConnect, useDisconnect } from '@gobob/sats-wagmi'; | ||
|
||
import React, { FC, useCallback, useEffect, useState } from 'react'; | ||
|
||
import { t } from 'i18next'; | ||
import { nanoid } from 'nanoid'; | ||
|
||
import { | ||
Button, | ||
Dialog, | ||
DialogBody, | ||
DialogHeader, | ||
NotificationType, | ||
WalletIdentity, | ||
} from '@sovryn/ui'; | ||
|
||
import { useNotificationContext } from '../../../../../contexts/NotificationContext'; | ||
import { translations } from '../../../../../locales/i18n'; | ||
|
||
export const BitcoinWallet: FC = () => { | ||
const { addNotification } = useNotificationContext(); | ||
const { connectors, connect } = useConnect(); | ||
const { address: btcAddress } = useAccount(); | ||
const { disconnect } = useDisconnect(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onCopyAddress = useCallback(() => { | ||
addNotification({ | ||
type: NotificationType.success, | ||
title: t(translations.copyAddress), | ||
content: '', | ||
dismissible: true, | ||
id: nanoid(), | ||
}); | ||
}, [addNotification]); | ||
|
||
useEffect(() => { | ||
if (btcAddress && isOpen) { | ||
setIsOpen(false); | ||
} | ||
}, [btcAddress, isOpen]); | ||
|
||
if (!btcAddress) { | ||
return ( | ||
<> | ||
<Button | ||
text={t(translations.connectWalletButton.connectBTC)} | ||
onClick={() => setIsOpen(true)} | ||
/> | ||
<Dialog isOpen={isOpen} onClose={() => setIsOpen(false)}> | ||
<DialogHeader | ||
onClose={() => setIsOpen(false)} | ||
title={t(translations.connectWalletButton.connectBTC)} | ||
/> | ||
<DialogBody className="p-6"> | ||
<div className="flex gap-2 my-4 flex-wrap"> | ||
{connectors.map(connector => ( | ||
<Button | ||
key={connector.name} | ||
text={connector.name} | ||
onClick={() => connect({ connector })} | ||
/> | ||
))} | ||
</div> | ||
</DialogBody> | ||
</Dialog> | ||
</> | ||
); | ||
} | ||
return ( | ||
<WalletIdentity | ||
onDisconnect={disconnect} | ||
onCopyAddress={onCopyAddress} | ||
address={btcAddress} | ||
dropdownClassName="z-[10000000]" | ||
submenuLabels={{ | ||
copyAddress: t(translations.connectWalletButton.copyAddress), | ||
disconnect: t(translations.connectWalletButton.disconnect), | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/frontend/src/app/5_pages/BobGateway/components/BobGatewayForm/BobGatewayForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { FC, useMemo, useState } from 'react'; | ||
|
||
import { t } from 'i18next'; | ||
|
||
import { Tabs } from '@sovryn/ui'; | ||
|
||
import { translations } from '../../../../../locales/i18n'; | ||
import { BobGatewayDeposit } from '../BobGatewayDeposit/BobGatewayDeposit'; | ||
|
||
export const BobGatewayForm: FC = () => { | ||
const [index, setIndex] = useState(0); | ||
|
||
const items = useMemo( | ||
() => [ | ||
{ | ||
label: t(translations.bobGatewayPage.deposit), | ||
content: <BobGatewayDeposit />, | ||
dataAttribute: 'bob-gateway-deposit', | ||
}, | ||
{ | ||
label: t(translations.bobGatewayPage.deposit), | ||
content: <BobGatewayDeposit />, | ||
dataAttribute: 'bob-gateway-deposit', | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
return ( | ||
<div className="flex py-8 justify-center gap-6"> | ||
<div className="p-0 sm:border sm:border-gray-50 sm:rounded lg:min-w-[28rem] sm:p-6 sm:bg-gray-90"> | ||
<Tabs | ||
items={items} | ||
onChange={setIndex} | ||
index={index} | ||
className="w-full border-none" | ||
contentClassName="border-none" | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.