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