Remove cached transactions from explorer and update copy (#11965)
This commit is contained in:
parent
7641b60a2b
commit
2de7768f41
|
@ -22,7 +22,6 @@ import { LoadingCard } from "components/common/LoadingCard";
|
|||
import { TableCardBody } from "components/common/TableCardBody";
|
||||
import { displayTimestamp } from "utils/date";
|
||||
import { InfoTooltip } from "components/common/InfoTooltip";
|
||||
import { isCached } from "providers/transactions/cached";
|
||||
import { Address } from "components/common/Address";
|
||||
import { Signature } from "components/common/Signature";
|
||||
import { intoTransactionInstruction } from "utils/tx";
|
||||
|
@ -281,7 +280,6 @@ function AccountsCard({
|
|||
signature,
|
||||
autoRefresh,
|
||||
}: SignatureProps & AutoRefreshProps) {
|
||||
const { url } = useCluster();
|
||||
const details = useTransactionDetails(signature);
|
||||
const fetchDetails = useFetchTransactionDetails();
|
||||
const fetchStatus = useFetchTransactionStatus();
|
||||
|
@ -314,17 +312,14 @@ function AccountsCard({
|
|||
} else if (!details || details.status === FetchStatus.Fetching) {
|
||||
return <LoadingCard />;
|
||||
} else if (details.status === FetchStatus.FetchFailed) {
|
||||
return <ErrorCard retry={refreshDetails} text="Fetch Failed" />;
|
||||
return <ErrorCard retry={refreshDetails} text="Failed to fetch details" />;
|
||||
} else if (!details.data?.transaction || !message) {
|
||||
return <ErrorCard retry={refreshDetails} text="Not Found" />;
|
||||
return <ErrorCard text="Details are not available" />;
|
||||
}
|
||||
|
||||
const { meta } = details.data.transaction;
|
||||
if (!meta) {
|
||||
if (isCached(url, signature)) {
|
||||
return null;
|
||||
}
|
||||
return <ErrorCard retry={refreshDetails} text="Metadata Missing" />;
|
||||
return <ErrorCard text="Transaction metadata is missing" />;
|
||||
}
|
||||
|
||||
const accountRows = message.accountKeys.map((account, index) => {
|
||||
|
|
|
@ -1,290 +0,0 @@
|
|||
/**
|
||||
* TEMPORARY
|
||||
*
|
||||
* Adds the ability cache select transactions from mainnet-beta and return them as
|
||||
* if they came from the RPC node itself, until we have a longer transaction history
|
||||
*/
|
||||
|
||||
import { TransactionStatusInfo } from "./index";
|
||||
import {
|
||||
Transaction,
|
||||
ParsedConfirmedTransaction,
|
||||
Message,
|
||||
clusterApiUrl,
|
||||
} from "@solana/web3.js";
|
||||
import { intoParsedTransaction } from "utils/tx";
|
||||
|
||||
export const isCached = (url: string, signature: string): boolean => {
|
||||
return url === clusterApiUrl("mainnet-beta") && signature in CACHED_STATUSES;
|
||||
};
|
||||
|
||||
export const CACHED_STATUSES: { [key: string]: TransactionStatusInfo } = {
|
||||
uQf4pS38FjRF294QFEXizhYkZFjSR9ZSBvvV6MV5b4VpdfRnK3PY9TWZ2qHMQKtte3XwKVLcWqsTF6wL9NEZMty: {
|
||||
slot: 10440804,
|
||||
result: { err: null },
|
||||
timestamp: 1589212180,
|
||||
confirmations: "max",
|
||||
},
|
||||
DYrfStEEzbV5sftX8LgUa54Nwnc5m5E1731cqBtiiC66TeXgKpfqZEQTuFY3vhHZ2K1BsaFM3X9FqisR28EtZr8: {
|
||||
slot: 10451288,
|
||||
result: { err: null },
|
||||
timestamp: 1589216984,
|
||||
confirmations: "max",
|
||||
},
|
||||
"3bLx2PLpkxCxJA5P7HVe8asFdSWXVAh1DrxfkqWE9bWvPRxXE2hqwj1vuSC858fUw3XAGQcHbJknhtNdxY2sehab": {
|
||||
slot: 10516588,
|
||||
result: { err: null },
|
||||
timestamp: 1589247117,
|
||||
confirmations: "max",
|
||||
},
|
||||
"3fE8xNgyxbwbvA5MX3wM87ahDDgCVEaaMMSa8UCWWNxojaRYBgrQyiKXLSxcryMWb7sEyVLBWyqUaRWnQCroSqjY": {
|
||||
slot: 10575124,
|
||||
result: { err: null },
|
||||
timestamp: 1589274236,
|
||||
confirmations: "max",
|
||||
},
|
||||
"5PWymGjKV7T1oqeqGn139EHFyjNM2dnNhHCUcfD2bmdj8cfF95HpY1uJ84W89c4sJQnmyZxXcYrcjumx2jHUvxZQ": {
|
||||
slot: 12447825,
|
||||
result: { err: null },
|
||||
timestamp: 15901860565,
|
||||
confirmations: "max",
|
||||
},
|
||||
"5K4KuqTTRNtzfpxWiwnkePzGfsa3tBEmpMy7vQFR3KWFAZNVY9tvoSaz1Yt5dKxcgsZPio2EsASVDGbQB1HvirGD": {
|
||||
slot: 12450728,
|
||||
result: { err: null },
|
||||
timestamp: 15901874549,
|
||||
confirmations: "max",
|
||||
},
|
||||
"45pGoC4Rr3fJ1TKrsiRkhHRbdUeX7633XAGVec6XzVdpRbzQgHhe6ZC6Uq164MPWtiqMg7wCkC6Wy3jy2BqsDEKf": {
|
||||
slot: 12972684,
|
||||
result: { err: null },
|
||||
timestamp: 1590432412,
|
||||
confirmations: "max",
|
||||
},
|
||||
};
|
||||
|
||||
export const CACHED_DETAILS: { [key: string]: ParsedConfirmedTransaction } = {
|
||||
uQf4pS38FjRF294QFEXizhYkZFjSR9ZSBvvV6MV5b4VpdfRnK3PY9TWZ2qHMQKtte3XwKVLcWqsTF6wL9NEZMty: {
|
||||
meta: null,
|
||||
slot: 10440804,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 1,
|
||||
},
|
||||
instructions: [
|
||||
{ accounts: [0, 1], data: "3Bxs411UBrj8QXUb", programIdIndex: 2 },
|
||||
],
|
||||
recentBlockhash: "5Aw8MaMYdYtnfJyyrregWMWGgiMtWZ6GtRzeP6Ufo65Z",
|
||||
}),
|
||||
[
|
||||
"uQf4pS38FjRF294QFEXizhYkZFjSR9ZSBvvV6MV5b4VpdfRnK3PY9TWZ2qHMQKtte3XwKVLcWqsTF6wL9NEZMty",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
DYrfStEEzbV5sftX8LgUa54Nwnc5m5E1731cqBtiiC66TeXgKpfqZEQTuFY3vhHZ2K1BsaFM3X9FqisR28EtZr8: {
|
||||
meta: null,
|
||||
slot: 10451288,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 1,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [0, 1],
|
||||
data: "3Bxs3zwYHuDo723R",
|
||||
programIdIndex: 2,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "4hXYcBdfcadcjfWV17ZwMa4MXe8kbZHYHwr3GzfyqunL",
|
||||
}),
|
||||
[
|
||||
"DYrfStEEzbV5sftX8LgUa54Nwnc5m5E1731cqBtiiC66TeXgKpfqZEQTuFY3vhHZ2K1BsaFM3X9FqisR28EtZr8",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
"3bLx2PLpkxCxJA5P7HVe8asFdSWXVAh1DrxfkqWE9bWvPRxXE2hqwj1vuSC858fUw3XAGQcHbJknhtNdxY2sehab": {
|
||||
meta: null,
|
||||
slot: 10516588,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 1,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [0, 1],
|
||||
data: "3Bxs3zwYHuDo723R",
|
||||
programIdIndex: 2,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "HSzTGt3PJMeQtFr94gEdeZqTRaBxgS8Wf1zq3MDdNT3L",
|
||||
}),
|
||||
[
|
||||
"3bLx2PLpkxCxJA5P7HVe8asFdSWXVAh1DrxfkqWE9bWvPRxXE2hqwj1vuSC858fUw3XAGQcHbJknhtNdxY2sehab",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
"3fE8xNgyxbwbvA5MX3wM87ahDDgCVEaaMMSa8UCWWNxojaRYBgrQyiKXLSxcryMWb7sEyVLBWyqUaRWnQCroSqjY": {
|
||||
meta: null,
|
||||
slot: 10575124,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 1,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [0, 1],
|
||||
data: "3Bxs3zuKU6mRKSqD",
|
||||
programIdIndex: 2,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "6f6TBMhUoypfR5HHnEqC6VoooKxEcNad5W3Sf63j9MSD",
|
||||
}),
|
||||
[
|
||||
"3fE8xNgyxbwbvA5MX3wM87ahDDgCVEaaMMSa8UCWWNxojaRYBgrQyiKXLSxcryMWb7sEyVLBWyqUaRWnQCroSqjY",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
"5PWymGjKV7T1oqeqGn139EHFyjNM2dnNhHCUcfD2bmdj8cfF95HpY1uJ84W89c4sJQnmyZxXcYrcjumx2jHUvxZQ": {
|
||||
meta: null,
|
||||
slot: 12447825,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"HCV5dGFJXRrJ3jhDYA4DCeb9TEDTwGGYXtT3wHksu2Zr",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 1,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [0, 1],
|
||||
data: "3Bxs3zrfhSqZJTR1",
|
||||
programIdIndex: 2,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "3HJNFraT7XGAqMrQs83EKwDGB6LpHVwUMQKGaYMNY49E",
|
||||
}),
|
||||
[
|
||||
"5PWymGjKV7T1oqeqGn139EHFyjNM2dnNhHCUcfD2bmdj8cfF95HpY1uJ84W89c4sJQnmyZxXcYrcjumx2jHUvxZQ",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
"5K4KuqTTRNtzfpxWiwnkePzGfsa3tBEmpMy7vQFR3KWFAZNVY9tvoSaz1Yt5dKxcgsZPio2EsASVDGbQB1HvirGD": {
|
||||
meta: null,
|
||||
slot: 12450728,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"6yKHERk8rsbmJxvMpPuwPs1ct3hRiP7xaJF2tvnGU6nK",
|
||||
"4C6NCcLPUgGuBBkV2dJW96mrptMUCp3RG1ft9rqwjFi9",
|
||||
"3o6xgkJ9sTmDeQWyfj3sxwon18fXJB9PV5LDc8sfgR4a",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 2,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [1, 2],
|
||||
data: "3Bxs3ztRCp3tH1yZ",
|
||||
programIdIndex: 3,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "8eXVUNRxrDgpsEuoTWyLay1LUh2djc3Y8cw2owXRN8cU",
|
||||
}),
|
||||
[
|
||||
"5K4KuqTTRNtzfpxWiwnkePzGfsa3tBEmpMy7vQFR3KWFAZNVY9tvoSaz1Yt5dKxcgsZPio2EsASVDGbQB1HvirGD",
|
||||
"37tvpG1eAeEBizJPhJvmpC2BY8npwy6K1wrZdNwdRAfWSbkerY3ZwYAPMHbrzoq7tthvWC2qFU28niqLPxbukeXF",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
|
||||
"45pGoC4Rr3fJ1TKrsiRkhHRbdUeX7633XAGVec6XzVdpRbzQgHhe6ZC6Uq164MPWtiqMg7wCkC6Wy3jy2BqsDEKf": {
|
||||
meta: null,
|
||||
slot: 12972684,
|
||||
transaction: intoParsedTransaction(
|
||||
Transaction.populate(
|
||||
new Message({
|
||||
accountKeys: [
|
||||
"6yKHERk8rsbmJxvMpPuwPs1ct3hRiP7xaJF2tvnGU6nK",
|
||||
"3o6xgkJ9sTmDeQWyfj3sxwon18fXJB9PV5LDc8sfgR4a",
|
||||
"1nc1nerator11111111111111111111111111111111",
|
||||
"11111111111111111111111111111111",
|
||||
],
|
||||
header: {
|
||||
numReadonlySignedAccounts: 0,
|
||||
numReadonlyUnsignedAccounts: 1,
|
||||
numRequiredSignatures: 2,
|
||||
},
|
||||
instructions: [
|
||||
{
|
||||
accounts: [1, 2],
|
||||
data: "3Bxs4NNAyLXRbuZZ",
|
||||
programIdIndex: 3,
|
||||
},
|
||||
],
|
||||
recentBlockhash: "2xnatNUtSbeMRwi3k4vxPwXxeKFQYVuCNRg2rAgydWVP",
|
||||
}),
|
||||
[
|
||||
"45pGoC4Rr3fJ1TKrsiRkhHRbdUeX7633XAGVec6XzVdpRbzQgHhe6ZC6Uq164MPWtiqMg7wCkC6Wy3jy2BqsDEKf",
|
||||
"2E7CDMTssxTYkdetCKVWQv9X2KNDPiuZrT2Y7647PhFEXuAWWxmHJb3ryCmP29ocQ1SNc7VyJjjm4X3jE8xWDmGY",
|
||||
]
|
||||
)
|
||||
),
|
||||
},
|
||||
};
|
|
@ -6,7 +6,6 @@ import {
|
|||
ParsedConfirmedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { useCluster, Cluster } from "../cluster";
|
||||
import { CACHED_DETAILS, isCached } from "./cached";
|
||||
import * as Cache from "providers/cache";
|
||||
import { ActionType, FetchStatus } from "providers/cache";
|
||||
|
||||
|
@ -55,10 +54,6 @@ async function fetchDetails(
|
|||
|
||||
let fetchStatus;
|
||||
let transaction;
|
||||
if (isCached(url, signature)) {
|
||||
transaction = CACHED_DETAILS[signature];
|
||||
fetchStatus = FetchStatus.Fetched;
|
||||
} else {
|
||||
try {
|
||||
transaction = await new Connection(url).getParsedConfirmedTransaction(
|
||||
signature
|
||||
|
@ -70,7 +65,6 @@ async function fetchDetails(
|
|||
}
|
||||
fetchStatus = FetchStatus.FetchFailed;
|
||||
}
|
||||
}
|
||||
dispatch({
|
||||
type: ActionType.Update,
|
||||
status: fetchStatus,
|
||||
|
|
|
@ -9,7 +9,6 @@ import { useCluster, Cluster } from "../cluster";
|
|||
import { DetailsProvider } from "./details";
|
||||
import * as Cache from "providers/cache";
|
||||
import { ActionType, FetchStatus } from "providers/cache";
|
||||
import { CACHED_STATUSES, isCached } from "./cached";
|
||||
export { useTransactionDetails } from "./details";
|
||||
|
||||
export type Confirmations = number | "max";
|
||||
|
@ -68,11 +67,6 @@ export async function fetchTransactionStatus(
|
|||
|
||||
let fetchStatus;
|
||||
let data;
|
||||
if (isCached(url, signature)) {
|
||||
const info = CACHED_STATUSES[signature];
|
||||
data = { signature, info };
|
||||
fetchStatus = FetchStatus.Fetched;
|
||||
} else {
|
||||
try {
|
||||
const connection = new Connection(url);
|
||||
const { value } = await connection.getSignatureStatus(signature, {
|
||||
|
@ -91,8 +85,7 @@ export async function fetchTransactionStatus(
|
|||
});
|
||||
}
|
||||
}
|
||||
let timestamp: Timestamp =
|
||||
blockTime !== null ? blockTime : "unavailable";
|
||||
let timestamp: Timestamp = blockTime !== null ? blockTime : "unavailable";
|
||||
|
||||
let confirmations: Confirmations;
|
||||
if (typeof value.confirmations === "number") {
|
||||
|
@ -116,7 +109,6 @@ export async function fetchTransactionStatus(
|
|||
}
|
||||
fetchStatus = FetchStatus.FetchFailed;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ActionType.Update,
|
||||
|
|
Loading…
Reference in New Issue