From 38cb9c177d25ed53c2116888dea438a2d219d7ce Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 26 Jul 2023 16:31:02 +0200 Subject: [PATCH 1/5] refactor getFastBridges --- .../DepositConfirmationDialog.tsx | 12 +- .../TransferPanel/OneNovaTransferDialog.tsx | 27 +- .../USDCDepositConfirmationDialog.tsx | 38 ++- .../USDCWithdrawalConfirmationDialog.tsx | 40 +-- .../WithdrawalConfirmationDialog.tsx | 19 +- .../src/util/fastBridges.ts | 302 ++++++++---------- 6 files changed, 201 insertions(+), 237 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/DepositConfirmationDialog.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/DepositConfirmationDialog.tsx index 11928edf6f..6718f3562c 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/DepositConfirmationDialog.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/DepositConfirmationDialog.tsx @@ -50,11 +50,13 @@ export function DepositConfirmationDialog( tokenAddress && bridgeInfo && bridgeInfo.tokenSymbolOnArbitrum const fastBridges = [ - ...getFastBridges({ - from: from.id, - to: to.id, - tokenSymbol, - amount: props.amount + ...getFastBridges<'bridge'>({ + deepLinkInfo: { + from: from.id, + to: to.id, + tokenSymbol, + amount: props.amount + } }) ].filter(bridge => { return ( diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/OneNovaTransferDialog.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/OneNovaTransferDialog.tsx index d4e2ba80dd..7a05b6893b 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/OneNovaTransferDialog.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/OneNovaTransferDialog.tsx @@ -1,13 +1,12 @@ import { Dialog as HeadlessUIDialog, Tab } from '@headlessui/react' import { XMarkIcon } from '@heroicons/react/24/outline' -import Hop from '@/images/bridge/hop.png' import { useAppState } from '../../state' import { Button } from '../common/Button' import { TabButton } from '../common/Tab' import { BridgesTable } from '../common/BridgesTable' import { Dialog, UseDialogProps } from '../common/Dialog' -import { FastBridgeInfo, FastBridgeNames } from '../../util/fastBridges' +import { FastBridgeNames, getFastBridges } from '../../util/fastBridges' import { ChainId, getNetworkName } from '../../util/networks' export function OneNovaTransferDialog( @@ -31,19 +30,15 @@ export function OneNovaTransferDialog( ? ChainId.ArbitrumOne : ChainId.ArbitrumNova - const sourceNetworkSlug = - sourceChainId === ChainId.ArbitrumOne ? 'arbitrum' : 'nova' - const destinationNetworkSlug = - destinationChainId === ChainId.ArbitrumOne ? 'arbitrum' : 'nova' - - const bridgeDeepLink = `https://app.hop.exchange/#/send?sourceNetwork=${sourceNetworkSlug}&destNetwork=${destinationNetworkSlug}&token=${ - selectedToken?.symbol || 'ETH' - }&amount=${props.amount}` - - // only enable Hop for now - const fastBridgeList: FastBridgeInfo[] = [ - { name: FastBridgeNames.Hop, imageSrc: Hop, href: bridgeDeepLink } - ] + const fastBridges = getFastBridges<'bridge'>({ + deepLinkInfo: { + from: sourceChainId, + to: destinationChainId, + tokenSymbol: selectedToken?.symbol || 'ETH', + amount: props.amount + }, + supportedFastBridgeNames: [FastBridgeNames.Hop] + }) return ( @@ -76,7 +71,7 @@ export function OneNovaTransferDialog(

- +