explorer: wrap bytes on bpf-loader-2 write instruction (#13253)

This commit is contained in:
Josh 2020-10-28 21:08:24 -07:00 committed by GitHub
parent 61c2970141
commit 032a7d36ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 12 deletions

View File

@ -1,15 +1,7 @@
import React from "react";
import { TransactionInstruction } from "@solana/web3.js";
import { Address } from "components/common/Address";
function wrap(input: string, length: number): string {
var result = [];
while (input.length) {
result.push(input.substr(0, length));
input = input.substr(length);
}
return result.join("\n");
}
import { wrap } from "utils";
export function RawDetails({ ix }: { ix: TransactionInstruction }) {
const data = wrap(ix.data.toString("hex"), 50);

View File

@ -12,6 +12,7 @@ import { IX_STRUCTS } from "./types";
import { reportError } from "utils/sentry";
import { UnknownDetailsCard } from "../UnknownDetailsCard";
import { Address } from "components/common/Address";
import { wrap } from "utils";
type DetailsProps = {
tx: ParsedTransaction;
@ -50,7 +51,7 @@ type Props = {
export function BpfLoaderWriteDetailsCard(props: Props) {
const { ix, index, result, info } = props;
const bytes = wrap(info.bytes, 50);
return (
<InstructionCard
ix={ix}
@ -77,7 +78,7 @@ export function BpfLoaderWriteDetailsCard(props: Props) {
Bytes <span className="text-muted">(base 64)</span>
</td>
<td className="text-lg-right">
<code className="d-inline-block">{info.bytes}</code>
<pre className="d-inline-block text-left mb-0">{bytes}</pre>
</td>
</tr>

View File

@ -10,8 +10,8 @@ const Initialize = pick({
withdrawer: Pubkey,
}),
lockup: pick({
epoch: number(),
unixTimestamp: number(),
epoch: number(),
custodian: Pubkey,
}),
});

View File

@ -90,3 +90,12 @@ export function slotsToHumanString(
): string {
return HUMANIZER.humanize(slots * slotTime);
}
export function wrap(input: string, length: number): string {
var result = [];
while (input.length) {
result.push(input.substr(0, length));
input = input.substr(length);
}
return result.join("\n");
}