Show transaction history for deleted accounts

This commit is contained in:
Justin Starry
2020-05-20 23:51:25 +08:00
committed by Michael Vines
parent 7d00398662
commit 5946817978
3 changed files with 7 additions and 10 deletions

View File

@ -178,7 +178,7 @@ function HistoryCard({ pubkey }: { pubkey: PublicKey }) {
const info = useAccountInfo(address); const info = useAccountInfo(address);
const refresh = useFetchAccountHistory(); const refresh = useFetchAccountHistory();
if (!info || !info.details) { if (!info || info.lamports === undefined) {
return null; return null;
} else if (info.status === Status.FetchingHistory) { } else if (info.status === Status.FetchingHistory) {
return <LoadingCard />; return <LoadingCard />;

View File

@ -109,10 +109,6 @@ const renderAccountRow = (account: Account) => {
let statusText; let statusText;
let statusClass; let statusClass;
switch (account.status) { switch (account.status) {
case Status.NotFound:
statusClass = "danger";
statusText = "Not Found";
break;
case Status.CheckFailed: case Status.CheckFailed:
case Status.HistoryFailed: case Status.HistoryFailed:
statusClass = "dark"; statusClass = "dark";
@ -127,9 +123,12 @@ const renderAccountRow = (account: Account) => {
if (account.details?.executable) { if (account.details?.executable) {
statusClass = "dark"; statusClass = "dark";
statusText = "Executable"; statusText = "Executable";
} else { } else if (account.lamports) {
statusClass = "success"; statusClass = "success";
statusText = "Found"; statusText = "Found";
} else {
statusClass = "danger";
statusText = "Not Found";
} }
break; break;
default: default:

View File

@ -16,7 +16,6 @@ export enum Status {
CheckFailed, CheckFailed,
FetchingHistory, FetchingHistory,
HistoryFailed, HistoryFailed,
NotFound,
Success Success
} }
@ -192,7 +191,6 @@ async function fetchAccountInfo(
const result = await new Connection(url, "recent").getAccountInfo(pubkey); const result = await new Connection(url, "recent").getAccountInfo(pubkey);
if (result === null) { if (result === null) {
lamports = 0; lamports = 0;
fetchStatus = Status.NotFound;
} else { } else {
lamports = result.lamports; lamports = result.lamports;
let data = undefined; let data = undefined;
@ -214,9 +212,9 @@ async function fetchAccountInfo(
owner: result.owner, owner: result.owner,
data data
}; };
}
fetchStatus = Status.FetchingHistory; fetchStatus = Status.FetchingHistory;
fetchAccountHistory(dispatch, pubkey, url); fetchAccountHistory(dispatch, pubkey, url);
}
} catch (error) { } catch (error) {
console.error("Failed to fetch account info", error); console.error("Failed to fetch account info", error);
fetchStatus = Status.CheckFailed; fetchStatus = Status.CheckFailed;