Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,104 @@
import {
Disclosure,
DisclosureButton,
DisclosurePanel
} from '@headlessui/react'
import {
XCircleIcon,
ChevronRightIcon,
ArrowsRightLeftIcon,
DocumentIcon,
EyeIcon
} from '@heroicons/react/24/outline'
import { ChainError, ChainPair } from '../../hooks/useTransactionHistory'
import { Tooltip } from '../common/Tooltip'
import { getNetworkName } from '../../util/networks'
import { NetworkImage } from '../common/NetworkImage'
import { useCopyToClipboard } from '@uidotdev/usehooks'
import { successToast } from '../common/atoms/Toast'

function Networks({ networks }: { networks: ChainPair }) {
return (
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-1">
<NetworkImage chainId={networks.parentChainId} className="h-5 w-5" />
<span>{getNetworkName(networks.parentChainId)}</span>
</div>
<ArrowsRightLeftIcon width={20} />
<div className="flex items-center space-x-1">
<NetworkImage chainId={networks.childChainId} className="h-5 w-5" />
<span>{getNetworkName(networks.childChainId)}</span>
</div>
</div>
)
}

function ErrorTooltip({ error }: { error: string }) {
return (
<Tooltip
tippyProps={{ className: 'break-all', trigger: 'click' }}
content={error}
>
<div className="arb-hover flex cursor-pointer space-x-1">
<EyeIcon width={20} />
<span>View details</span>
</div>
</Tooltip>
)
}

function CopyErrorToClipboard({ error }: { error: string }) {
const [, copyToClipboard] = useCopyToClipboard()

const handleCopy = () => {
copyToClipboard(error)
successToast('Error message copied to clipboard.')
}

return (
<button className="arb-hover flex space-x-1" onClick={handleCopy}>
<DocumentIcon width={20} />
<span>Copy error</span>
</button>
)
}

export function ChainErrorsInfo({
chainErrors
}: {
chainErrors: ChainError[]
}) {
if (chainErrors.length === 0) {
return null
}

return (
<Disclosure
as="div"
className="text-red-dark my-3 flex w-full flex-col justify-start gap-1 rounded border border-red-400 bg-red-900 px-3 py-2 text-sm text-white"
>
<DisclosureButton className="flex items-center text-left">
<div className="flex items-start gap-1">
<XCircleIcon width={20} />
<p>
Errors occurred while fetching data for some of the chains and they
may not show in the history. Click to expand the view and see more
info.
</p>
</div>
<ChevronRightIcon className="ml-auto h-3 w-3 shrink-0 ui-open:rotate-90 ui-open:transform" />
</DisclosureButton>
<DisclosurePanel className="flex flex-col gap-2 pl-4">
<ul>
{chainErrors.map(chainError => (
<li className="grid grid-cols-[1fr_1fr_auto] items-center border-t border-white/50 py-2">
<Networks networks={chainError.chainPair} />
<ErrorTooltip error={chainError.error} />
<CopyErrorToClipboard error={chainError.error} />
</li>
))}
</ul>
</DisclosurePanel>
</Disclosure>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Disclosure } from '@headlessui/react'
import {
Disclosure,
DisclosureButton,
DisclosurePanel
} from '@headlessui/react'
import {
InformationCircleIcon,
ChevronRightIcon
Expand All @@ -13,7 +17,7 @@ export function PendingDepositWarning() {
as="div"
className="mt-4 flex w-full flex-col justify-start gap-1 rounded border border-orange-dark bg-orange p-3 text-sm text-orange-dark"
>
<Disclosure.Button className="flex items-center text-left">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated

<DisclosureButton className="flex items-center text-left">
<div className="flex items-start gap-1">
<InformationCircleIcon className="mt-[2px] h-3 w-3 shrink-0 stroke-orange-dark" />
<p>
Expand All @@ -22,8 +26,8 @@ export function PendingDepositWarning() {
</p>
</div>
<ChevronRightIcon className="ml-auto h-3 w-3 shrink-0 ui-open:rotate-90 ui-open:transform" />
</Disclosure.Button>
<Disclosure.Panel className="flex flex-col gap-2 pl-4">
</DisclosureButton>
<DisclosurePanel className="flex flex-col gap-2 pl-4">
<p>
If you must leave, check back <strong>within a week</strong>. In most
cases, your deposits should go through successfully.
Expand All @@ -42,7 +46,7 @@ export function PendingDepositWarning() {
</ExternalLink>
, the mechanism behind deposits.
</p>
</Disclosure.Panel>
</DisclosurePanel>
</Disclosure>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { useTransactionHistoryAddressStore } from './TransactionHistorySearchBar'
import { shallow } from 'zustand/shallow'
import { TransactionHistoryDisclaimer } from './TransactionHistoryDisclaimer'
import { ChainErrorsInfo } from './ChainErrorsInfo'

function useTransactionHistoryUpdater() {
const sanitizedAddress = useTransactionHistoryAddressStore(
Expand Down Expand Up @@ -56,7 +57,7 @@ const tabClasses =

export function TransactionHistorySearchResults() {
const props = useTransactionHistoryUpdater()
const { transactions } = props
const { transactions, chainErrors } = props
const { forceFetchReceived, setForceFetchReceived } = useForceFetchReceived(
state => ({
forceFetchReceived: state.forceFetchReceived,
Expand Down Expand Up @@ -125,6 +126,12 @@ export function TransactionHistorySearchResults() {
<TransactionStatusInfo />
</div>

{chainErrors.length > 0 && (
<div className="pr-4 md:pr-0">
<ChainErrorsInfo chainErrors={chainErrors} />
</div>
)}

<div className="mb-4">
<TransactionHistoryDisclaimer />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ import {
} from 'react'
import { twMerge } from 'tailwind-merge'
import { Column, Table } from 'react-virtualized'
import {
ExclamationCircleIcon,
PlusCircleIcon
} from '@heroicons/react/24/outline'
import { PlusCircleIcon } from '@heroicons/react/24/outline'
import dayjs from 'dayjs'
import { getProviderForChainId } from '@/token-bridge-sdk/utils'

import { isTokenDeposit } from '../../state/app/utils'
import {
ChainPair,
UseTransactionHistoryResult
} from '../../hooks/useTransactionHistory'
import { UseTransactionHistoryResult } from '../../hooks/useTransactionHistory'
import { Tooltip } from '../common/Tooltip'
import { getNetworkName } from '../../util/networks'
import { isTxPending } from './helpers'
import { PendingDepositWarning } from './PendingDepositWarning'
import { TransactionsTableRow } from './TransactionsTableRow'
Expand Down Expand Up @@ -96,39 +89,6 @@ export const HistoryLoader = () => {
return <span className="animate-pulse">Loading transactions...</span>
}

const FailedChainPairsTooltip = ({
failedChainPairs
}: {
failedChainPairs: ChainPair[]
}) => {
if (failedChainPairs.length === 0) {
return null
}

return (
<Tooltip
content={
<div className="flex flex-col space-y-1 text-xs">
<span>
We were unable to fetch data for the following chain pairs:
</span>
<ul className="flex list-disc flex-col pl-4">
{failedChainPairs.map(pair => (
<li key={`${pair.parentChainId}-${pair.childChainId}`}>
<b>{getNetworkName(pair.parentChainId)}</b>
{' <> '}
<b>{getNetworkName(pair.childChainId)}</b>
</li>
))}
</ul>
</div>
}
>
<ExclamationCircleIcon height={20} className="text-error" />
</Tooltip>
)
}

type TransactionHistoryTableProps = UseTransactionHistoryResult & {
selectedTabIndex: number
oldestTxTimeAgoString: string
Expand All @@ -142,7 +102,6 @@ export const TransactionHistoryTable = (
loading,
completed,
error,
failedChainPairs,
resume,
selectedTabIndex,
oldestTxTimeAgoString
Expand Down Expand Up @@ -216,13 +175,11 @@ export const TransactionHistoryTable = (
>
{loading ? (
<div className="flex h-[28px] items-center space-x-2">
<FailedChainPairsTooltip failedChainPairs={failedChainPairs} />
<HistoryLoader />
</div>
) : (
<div className="flex items-center justify-between gap-2">
<div className="flex items-center justify-start space-x-1">
<FailedChainPairsTooltip failedChainPairs={failedChainPairs} />
<span className="text-xs">
Showing {transactions.length}{' '}
{isPendingTab ? 'pending' : 'settled'} transactions made in{' '}
Expand Down
11 changes: 11 additions & 0 deletions packages/arb-token-bridge-ui/src/components/common/atoms/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ export const warningToast = (
toast.warning(message, { autoClose })
}

export const successToast = (
message: React.ReactNode,
{
autoClose
}: {
autoClose?: number | false | undefined
} = { autoClose: 5000 }
) => {
toast.success(message, { autoClose })
}

export const Toast = () => {
return (
<ToastContainer
Expand Down
Loading
Loading