From 032a7d36ff0687ac799378411e29af1606c8af46 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 28 Oct 2020 21:08:24 -0700 Subject: [PATCH] explorer: wrap bytes on bpf-loader-2 write instruction (#13253) --- explorer/src/components/instruction/RawDetails.tsx | 10 +--------- .../instruction/bpf-loader/BpfLoaderDetailsCard.tsx | 5 +++-- explorer/src/components/instruction/stake/types.ts | 2 +- explorer/src/utils/index.tsx | 9 +++++++++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/explorer/src/components/instruction/RawDetails.tsx b/explorer/src/components/instruction/RawDetails.tsx index 8e64419d3..a9d5d6b7d 100644 --- a/explorer/src/components/instruction/RawDetails.tsx +++ b/explorer/src/components/instruction/RawDetails.tsx @@ -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); diff --git a/explorer/src/components/instruction/bpf-loader/BpfLoaderDetailsCard.tsx b/explorer/src/components/instruction/bpf-loader/BpfLoaderDetailsCard.tsx index 44ea0e0b8..4233bddb6 100644 --- a/explorer/src/components/instruction/bpf-loader/BpfLoaderDetailsCard.tsx +++ b/explorer/src/components/instruction/bpf-loader/BpfLoaderDetailsCard.tsx @@ -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 ( (base 64) - {info.bytes} +
{bytes}
diff --git a/explorer/src/components/instruction/stake/types.ts b/explorer/src/components/instruction/stake/types.ts index 3cb9067c8..5abb76cf7 100644 --- a/explorer/src/components/instruction/stake/types.ts +++ b/explorer/src/components/instruction/stake/types.ts @@ -10,8 +10,8 @@ const Initialize = pick({ withdrawer: Pubkey, }), lockup: pick({ - epoch: number(), unixTimestamp: number(), + epoch: number(), custodian: Pubkey, }), }); diff --git a/explorer/src/utils/index.tsx b/explorer/src/utils/index.tsx index 13fd4a324..d4f7f0113 100644 --- a/explorer/src/utils/index.tsx +++ b/explorer/src/utils/index.tsx @@ -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"); +}