explorer: introduce details card for memo instruction (#13538)

This commit is contained in:
Josh 2020-11-19 14:05:55 -08:00 committed by GitHub
parent f9acbd6e3f
commit b33e5b87dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import React from "react";
import { ParsedInstruction, SignatureResult } from "@solana/web3.js";
import { InstructionCard } from "./InstructionCard";
import { wrap } from "utils";
export function MemoDetailsCard({
ix,
index,
result,
}: {
ix: ParsedInstruction;
index: number;
result: SignatureResult;
}) {
const data = wrap(ix.parsed, 50);
return (
<InstructionCard ix={ix} index={index} result={result} title="Memo">
<tr>
<td>Data (UTF-8)</td>
<td className="text-lg-right">
<pre className="d-inline-block text-left mb-0">{data}</pre>
</td>
</tr>
</InstructionCard>
);
}

View File

@ -32,6 +32,7 @@ import { Slot } from "components/common/Slot";
import { isTokenSwapInstruction } from "components/instruction/token-swap/types";
import { TokenSwapDetailsCard } from "components/instruction/TokenSwapDetailsCard";
import { isSerumInstruction } from "components/instruction/serum/types";
import { MemoDetailsCard } from "components/instruction/MemoDetailsCard";
const AUTO_REFRESH_INTERVAL = 2000;
const ZERO_CONFIRMATION_BAILOUT = 5;
@ -449,6 +450,15 @@ function InstructionsSection({ signature }: SignatureProps) {
index={index}
/>
);
case "spl-memo":
return (
<MemoDetailsCard
key={index}
ix={next}
result={result}
index={index}
/>
);
default:
const props = { ix: next, result, index };
return <UnknownDetailsCard key={index} {...props} />;