Add disclaimer stating oldest available slot (#136)

This commit is contained in:
Justin Starry 2020-05-23 18:19:39 +08:00 committed by Michael Vines
parent e962d40815
commit 7e2eefad3e
5 changed files with 33 additions and 9 deletions

View File

@ -1269,9 +1269,9 @@
"integrity": "sha512-DetpxZw1fzPD5xUBrIAoplLChO2VB8DlL5Gg+I1IR9b2wPqYIca2WSUxL5g1vLeR4MsQq1NeWriXAVffV+U1Fw==" "integrity": "sha512-DetpxZw1fzPD5xUBrIAoplLChO2VB8DlL5Gg+I1IR9b2wPqYIca2WSUxL5g1vLeR4MsQq1NeWriXAVffV+U1Fw=="
}, },
"@solana/web3.js": { "@solana/web3.js": {
"version": "0.55.0", "version": "0.56.0",
"resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-0.55.0.tgz", "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-0.56.0.tgz",
"integrity": "sha512-1VfcfeI8nNJSlFA8ZZpyoaZHeftyvmBfE9dRyPtqsZszPfbtyA6NeOvydRBaSSU7XDC7hQZnKP4QFIf6uef8Mw==", "integrity": "sha512-Vys4PY7wksHXLyMbjpTLJGMSs58zRGdDPaBmlxeTXfwjv27W5xcjanuC+sNQ8CaeKjUy9Rd0ptU2qSjBHp/rNw==",
"requires": { "requires": {
"@babel/runtime": "^7.3.1", "@babel/runtime": "^7.3.1",
"bn.js": "^5.0.0", "bn.js": "^5.0.0",

View File

@ -3,7 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@solana/web3.js": "^0.55.0", "@solana/web3.js": "^0.56.0",
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2", "@testing-library/user-event": "^7.1.2",

View File

@ -101,12 +101,22 @@ function StatusCard({ signature }: Props) {
const status = useTransactionStatus(signature); const status = useTransactionStatus(signature);
const refresh = useFetchTransactionStatus(); const refresh = useFetchTransactionStatus();
const details = useTransactionDetails(signature); const details = useTransactionDetails(signature);
const { firstAvailableBlock } = useCluster();
if (!status || status.fetchStatus === FetchStatus.Fetching) { if (!status || status.fetchStatus === FetchStatus.Fetching) {
return <LoadingCard />; return <LoadingCard />;
} else if (status?.fetchStatus === FetchStatus.FetchFailed) { } else if (status?.fetchStatus === FetchStatus.FetchFailed) {
return <ErrorCard retry={() => refresh(signature)} text="Fetch Failed" />; return <ErrorCard retry={() => refresh(signature)} text="Fetch Failed" />;
} else if (!status.info) { } 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" />; return <ErrorCard retry={() => refresh(signature)} text="Not Found" />;
} }

View File

@ -3,11 +3,13 @@ import React from "react";
export default function ErrorCard({ export default function ErrorCard({
retry, retry,
retryText, retryText,
text text,
subtext
}: { }: {
retry?: () => void; retry?: () => void;
retryText?: string; retryText?: string;
text: string; text: string;
subtext?: string;
}) { }) {
const buttonText = retryText || "Try Again"; const buttonText = retryText || "Try Again";
return ( return (
@ -23,11 +25,16 @@ export default function ErrorCard({
{buttonText} {buttonText}
</span> </span>
<div className="d-block d-md-none mt-4"> <div className="d-block d-md-none mt-4">
<hr></hr> <span className="btn btn-white w-100" onClick={retry}>
<span className="btn btn-white" onClick={retry}>
{buttonText} {buttonText}
</span> </span>
</div> </div>
{subtext && (
<div className="text-muted">
<hr></hr>
{subtext}
</div>
)}
</> </>
)} )}
</div> </div>

View File

@ -58,6 +58,7 @@ export const DEFAULT_CUSTOM_URL = "http://localhost:8899";
interface State { interface State {
cluster: Cluster; cluster: Cluster;
customUrl: string; customUrl: string;
firstAvailableBlock?: number;
status: ClusterStatus; status: ClusterStatus;
} }
@ -65,6 +66,7 @@ interface Action {
status: ClusterStatus; status: ClusterStatus;
cluster: Cluster; cluster: Cluster;
customUrl: string; customUrl: string;
firstAvailableBlock?: number;
} }
type Dispatch = (action: Action) => void; type Dispatch = (action: Action) => void;
@ -192,8 +194,13 @@ async function updateCluster(
try { try {
const connection = new Connection(clusterUrl(cluster, customUrl)); const connection = new Connection(clusterUrl(cluster, customUrl));
await connection.getRecentBlockhash(); const firstAvailableBlock = await connection.getFirstAvailableBlock();
dispatch({ status: ClusterStatus.Connected, cluster, customUrl }); dispatch({
status: ClusterStatus.Connected,
cluster,
customUrl,
firstAvailableBlock
});
} catch (error) { } catch (error) {
console.error("Failed to update cluster", error); console.error("Failed to update cluster", error);
dispatch({ status: ClusterStatus.Failure, cluster, customUrl }); dispatch({ status: ClusterStatus.Failure, cluster, customUrl });