Skip to content

Commit

Permalink
Add disclaimer stating oldest available slot (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored and mvines committed Jun 12, 2020
1 parent f4a7e54 commit 5b69ecf
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
6 changes: 3 additions & 3 deletions explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@solana/web3.js": "^0.55.0",
"@solana/web3.js": "^0.56.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
Expand Down
10 changes: 10 additions & 0 deletions explorer/src/components/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,22 @@ function StatusCard({ signature }: Props) {
const status = useTransactionStatus(signature);
const refresh = useFetchTransactionStatus();
const details = useTransactionDetails(signature);
const { firstAvailableBlock } = useCluster();

if (!status || status.fetchStatus === FetchStatus.Fetching) {
return <LoadingCard />;
} else if (status?.fetchStatus === FetchStatus.FetchFailed) {
return <ErrorCard retry={() => refresh(signature)} text="Fetch Failed" />;
} else if (!status.info) {
if (firstAvailableBlock !== undefined) {
return (
<ErrorCard
retry={() => refresh(signature)}
text="Not Found"
subtext={`Note: Transactions processed before block ${firstAvailableBlock} are not available at this time`}
/>
);
}
return <ErrorCard retry={() => refresh(signature)} text="Not Found" />;
}

Expand Down
13 changes: 10 additions & 3 deletions explorer/src/components/common/ErrorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import React from "react";
export default function ErrorCard({
retry,
retryText,
text
text,
subtext
}: {
retry?: () => void;
retryText?: string;
text: string;
subtext?: string;
}) {
const buttonText = retryText || "Try Again";
return (
Expand All @@ -23,11 +25,16 @@ export default function ErrorCard({
{buttonText}
</span>
<div className="d-block d-md-none mt-4">
<hr></hr>
<span className="btn btn-white" onClick={retry}>
<span className="btn btn-white w-100" onClick={retry}>
{buttonText}
</span>
</div>
{subtext && (
<div className="text-muted">
<hr></hr>
{subtext}
</div>
)}
</>
)}
</div>
Expand Down
11 changes: 9 additions & 2 deletions explorer/src/providers/cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ export const DEFAULT_CUSTOM_URL = "http://localhost:8899";
interface State {
cluster: Cluster;
customUrl: string;
firstAvailableBlock?: number;
status: ClusterStatus;
}

interface Action {
status: ClusterStatus;
cluster: Cluster;
customUrl: string;
firstAvailableBlock?: number;
}

type Dispatch = (action: Action) => void;
Expand Down Expand Up @@ -192,8 +194,13 @@ async function updateCluster(

try {
const connection = new Connection(clusterUrl(cluster, customUrl));
await connection.getRecentBlockhash();
dispatch({ status: ClusterStatus.Connected, cluster, customUrl });
const firstAvailableBlock = await connection.getFirstAvailableBlock();
dispatch({
status: ClusterStatus.Connected,
cluster,
customUrl,
firstAvailableBlock
});
} catch (error) {
console.error("Failed to update cluster", error);
dispatch({ status: ClusterStatus.Failure, cluster, customUrl });
Expand Down

0 comments on commit 5b69ecf

Please sign in to comment.