Fix explorer token crash on unknown instruction (#12329)
This commit is contained in:
parent
fdbb22dc07
commit
f03621d24a
|
@ -25,6 +25,7 @@ import {
|
||||||
TokenInstructionType,
|
TokenInstructionType,
|
||||||
IX_TITLES,
|
IX_TITLES,
|
||||||
} from "components/instruction/token/types";
|
} from "components/instruction/token/types";
|
||||||
|
import { reportError } from "utils/sentry";
|
||||||
|
|
||||||
export function TokenHistoryCard({ pubkey }: { pubkey: PublicKey }) {
|
export function TokenHistoryCard({ pubkey }: { pubkey: PublicKey }) {
|
||||||
const address = pubkey.toBase58();
|
const address = pubkey.toBase58();
|
||||||
|
@ -194,6 +195,21 @@ function TokenHistoryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instructionTypeName(
|
||||||
|
ix: ParsedInstruction,
|
||||||
|
tx: ConfirmedSignatureInfo
|
||||||
|
): string {
|
||||||
|
try {
|
||||||
|
const parsed = coerce(ix.parsed, ParsedInfo);
|
||||||
|
const { type: rawType } = parsed;
|
||||||
|
const type = coerce(rawType, TokenInstructionType);
|
||||||
|
return IX_TITLES[type];
|
||||||
|
} catch (err) {
|
||||||
|
reportError(err, { signature: tx.signature });
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function TokenTransactionRow({
|
function TokenTransactionRow({
|
||||||
mint,
|
mint,
|
||||||
tx,
|
tx,
|
||||||
|
@ -219,10 +235,7 @@ function TokenTransactionRow({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{tokenInstructions.map((ix, index) => {
|
{tokenInstructions.map((ix, index) => {
|
||||||
const parsed = coerce(ix.parsed, ParsedInfo);
|
const typeName = instructionTypeName(ix, tx);
|
||||||
const { type: rawType } = parsed;
|
|
||||||
const type = coerce(rawType, TokenInstructionType);
|
|
||||||
const typeName = IX_TITLES[type];
|
|
||||||
|
|
||||||
let statusText;
|
let statusText;
|
||||||
let statusClass;
|
let statusClass;
|
||||||
|
|
Loading…
Reference in New Issue