From 9e39b815f7b4dd535f4f73834d2f81d726118b7f Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 8 Feb 2021 12:54:11 -0800 Subject: [PATCH] explorer: introduce stake merge instruction card (#15160) --- .../instruction/stake/MergeDetailsCard.tsx | 73 +++++++++++++++++++ .../instruction/stake/StakeDetailsCard.tsx | 6 ++ .../src/components/instruction/stake/types.ts | 10 +++ 3 files changed, 89 insertions(+) create mode 100644 explorer/src/components/instruction/stake/MergeDetailsCard.tsx diff --git a/explorer/src/components/instruction/stake/MergeDetailsCard.tsx b/explorer/src/components/instruction/stake/MergeDetailsCard.tsx new file mode 100644 index 0000000000..ad7b0b8b18 --- /dev/null +++ b/explorer/src/components/instruction/stake/MergeDetailsCard.tsx @@ -0,0 +1,73 @@ +import React from "react"; +import { + SignatureResult, + StakeProgram, + ParsedInstruction, +} from "@solana/web3.js"; +import { InstructionCard } from "../InstructionCard"; +import { Address } from "components/common/Address"; +import { MergeInfo } from "./types"; + +export function MergeDetailsCard(props: { + ix: ParsedInstruction; + index: number; + result: SignatureResult; + info: MergeInfo; + innerCards?: JSX.Element[]; + childIndex?: number; +}) { + const { ix, index, result, info, innerCards, childIndex } = props; + + return ( + + + Program + +
+ + + + + Stake Source + +
+ + + + + Stake Destination + +
+ + + + + Authority Address + +
+ + + + + Clock Sysvar + +
+ + + + + Stake History Sysvar + +
+ + + + ); +} diff --git a/explorer/src/components/instruction/stake/StakeDetailsCard.tsx b/explorer/src/components/instruction/stake/StakeDetailsCard.tsx index ec8e938aa8..a46a70b713 100644 --- a/explorer/src/components/instruction/stake/StakeDetailsCard.tsx +++ b/explorer/src/components/instruction/stake/StakeDetailsCard.tsx @@ -20,9 +20,11 @@ import { DeactivateInfo, DelegateInfo, InitializeInfo, + MergeInfo, SplitInfo, WithdrawInfo, } from "./types"; +import { MergeDetailsCard } from "./MergeDetailsCard"; type DetailsProps = { tx: ParsedTransaction; @@ -62,6 +64,10 @@ export function StakeDetailsCard(props: DetailsProps) { const info = coerce(parsed.info, DeactivateInfo); return ; } + case "merge": { + const info = coerce(parsed.info, MergeInfo); + return ; + } default: return ; } diff --git a/explorer/src/components/instruction/stake/types.ts b/explorer/src/components/instruction/stake/types.ts index 2b7cadad5e..ced4c02f91 100644 --- a/explorer/src/components/instruction/stake/types.ts +++ b/explorer/src/components/instruction/stake/types.ts @@ -54,6 +54,15 @@ export const DeactivateInfo = pick({ stakeAuthority: Pubkey, }); +export type MergeInfo = StructType; +export const MergeInfo = pick({ + source: Pubkey, + destination: Pubkey, + stakeAuthority: Pubkey, + stakeHistorySysvar: Pubkey, + clockSysvar: Pubkey, +}); + export type StakeInstructionType = StructType; export const StakeInstructionType = enums([ "initialize", @@ -62,4 +71,5 @@ export const StakeInstructionType = enums([ "split", "withdraw", "deactivate", + "merge", ]);