Skip to content

Commit

Permalink
fix tx views
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Feb 8, 2024
1 parent e1c2c54 commit 9068d41
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
16 changes: 9 additions & 7 deletions lib/web3/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export const publicClient = (() => {
return;
}

return createPublicClient({
chain: currentChain,
transport: http(),
batch: {
multicall: true,
},
});
try {
return createPublicClient({
chain: currentChain,
transport: http(),
batch: {
multicall: true,
},
});
} catch (error) {}
})();
9 changes: 6 additions & 3 deletions ui/pages/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import config from 'configs/app';
import { useAppContext } from 'lib/contexts/app';
import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import getQueryParamString from 'lib/router/getQueryParamString';
import { publicClient } from 'lib/web3/client';
import TextAd from 'ui/shared/ad/TextAd';
import EntityTags from 'ui/shared/EntityTags';
import PageTitle from 'ui/shared/Page/PageTitle';
Expand All @@ -33,7 +34,7 @@ const TransactionPageContent = () => {
const txQuery = useTxQuery();
const { data, isPlaceholderData, isError, error, errorUpdateCount } = txQuery;

const showDegradedView = (isError || isPlaceholderData) && errorUpdateCount > 0;
const showDegradedView = publicClient && (isError || isPlaceholderData) && errorUpdateCount > 0;

const tabs: Array<RoutedTab> = (() => {
const detailsComponent = showDegradedView ?
Expand Down Expand Up @@ -97,8 +98,10 @@ const TransactionPageContent = () => {
return <RoutedTabs tabs={ tabs }/>;
})();

if (error?.status === 422) {
throwOnResourceLoadError({ resource: 'tx', error, isError: true });
if (isError && !showDegradedView) {
if (error?.status === 422 || error?.status === 404) {
throwOnResourceLoadError({ resource: 'tx', error, isError: true });
}
}

return (
Expand Down
5 changes: 5 additions & 0 deletions ui/tx/TxDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import TestnetWarning from 'ui/shared/alerts/TestnetWarning';
import DataFetchAlert from 'ui/shared/DataFetchAlert';

import TxInfo from './details/TxInfo';
import type { TxQuery } from './useTxQuery';
Expand All @@ -10,6 +11,10 @@ interface Props {
}

const TxDetails = ({ txQuery }: Props) => {
if (txQuery.isError) {
return <DataFetchAlert/>;
}

return (
<>
<TestnetWarning mb={ 6 } isLoading={ txQuery.isPlaceholderData }/>
Expand Down
4 changes: 4 additions & 0 deletions ui/tx/TxDetailsDegraded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const TxDetailsDegraded = ({ hash, txQuery }: Props) => {
const query = useQuery<RpcResponseType, unknown, Transaction | null>({
queryKey: [ 'RPC', 'tx', { hash } ],
queryFn: async() => {
if (!publicClient) {
throw new Error('No public RPC client');
}

const tx = await publicClient.getTransaction({ hash: hash as `0x${ string }` });

if (!tx) {
Expand Down
5 changes: 5 additions & 0 deletions ui/tx/TxUserOps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

import { USER_OPS_ITEM } from 'stubs/userOps';
import { generateListStub } from 'stubs/utils';
import DataFetchAlert from 'ui/shared/DataFetchAlert';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
import TxPendingAlert from 'ui/tx/TxPendingAlert';
import TxSocketAlert from 'ui/tx/TxSocketAlert';
Expand All @@ -28,6 +29,10 @@ const TxUserOps = ({ txQuery }: Props) => {
return txQuery.socketStatus ? <TxSocketAlert status={ txQuery.socketStatus }/> : <TxPendingAlert/>;
}

if (txQuery.isError) {
return <DataFetchAlert/>;
}

return <UserOpsContent query={ userOpsQuery } showTx={ false }/>;
};

Expand Down

0 comments on commit 9068d41

Please sign in to comment.