diff --git a/explorer/src/components/instruction/SerumDetailsCard.tsx b/explorer/src/components/instruction/SerumDetailsCard.tsx index 59154687a8..50a3897096 100644 --- a/explorer/src/components/instruction/SerumDetailsCard.tsx +++ b/explorer/src/components/instruction/SerumDetailsCard.tsx @@ -20,6 +20,7 @@ import { decodePrune, decodeSettleFunds, decodeSweepFees, + OPEN_BOOK_PROGRAM_ID, parseSerumInstructionKey, parseSerumInstructionTitle, } from "./serum/types"; @@ -40,7 +41,7 @@ import { InitOpenOrdersDetailsCard } from "./serum/InitOpenOrdersDetails"; import { PruneDetailsCard } from "./serum/PruneDetails"; import { ConsumeEventsPermissionedDetailsCard } from "./serum/ConsumeEventsPermissionedDetails"; -export function SerumDetailsCard(props: { +export function SerumDetailsCard(initialProps: { ix: TransactionInstruction; index: number; result: SignatureResult; @@ -48,7 +49,15 @@ export function SerumDetailsCard(props: { innerCards?: JSX.Element[]; childIndex?: number; }) { - const { ix, index, result, signature, innerCards, childIndex } = props; + const { ix, index, result, signature, innerCards, childIndex } = initialProps; + + const props = React.useMemo(() => { + const programName = + initialProps.ix.programId.toBase58() === OPEN_BOOK_PROGRAM_ID + ? "OpenBook" + : "Serum"; + return { ...initialProps, programName }; + }, [initialProps]); const { url } = useCluster(); @@ -143,7 +152,7 @@ export function SerumDetailsCard(props: { ix={ix} index={index} result={result} - title={`Serum Program: ${title || "Unknown"}`} + title={`${props.programName} Program: ${title || "Unknown"}`} innerCards={innerCards} childIndex={childIndex} defaultRaw diff --git a/explorer/src/components/instruction/serum/CancelOrderByClientIdDetails.tsx b/explorer/src/components/instruction/serum/CancelOrderByClientIdDetails.tsx index d782338f36..62099c5325 100644 --- a/explorer/src/components/instruction/serum/CancelOrderByClientIdDetails.tsx +++ b/explorer/src/components/instruction/serum/CancelOrderByClientIdDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { CancelOrderByClientId } from "./types"; +import { CancelOrderByClientId, SerumIxDetailsProps } from "./types"; -export function CancelOrderByClientIdDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: CancelOrderByClientId; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function CancelOrderByClientIdDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/CancelOrderByClientIdV2Details.tsx b/explorer/src/components/instruction/serum/CancelOrderByClientIdV2Details.tsx index 93cb3b6631..a6949a1791 100644 --- a/explorer/src/components/instruction/serum/CancelOrderByClientIdV2Details.tsx +++ b/explorer/src/components/instruction/serum/CancelOrderByClientIdV2Details.tsx @@ -1,17 +1,11 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { CancelOrderByClientIdV2 } from "./types"; +import { CancelOrderByClientIdV2, SerumIxDetailsProps } from "./types"; -export function CancelOrderByClientIdV2DetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: CancelOrderByClientIdV2; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { +export function CancelOrderByClientIdV2DetailsCard( + props: SerumIxDetailsProps +) { const { ix, index, result, info, innerCards, childIndex } = props; return ( diff --git a/explorer/src/components/instruction/serum/CancelOrderDetails.tsx b/explorer/src/components/instruction/serum/CancelOrderDetails.tsx index fcb244843c..7a10625c42 100644 --- a/explorer/src/components/instruction/serum/CancelOrderDetails.tsx +++ b/explorer/src/components/instruction/serum/CancelOrderDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { CancelOrder } from "./types"; +import { CancelOrder, SerumIxDetailsProps } from "./types"; -export function CancelOrderDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: CancelOrder; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function CancelOrderDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/CancelOrderV2Details.tsx b/explorer/src/components/instruction/serum/CancelOrderV2Details.tsx index 1a5f49f373..53c4e9f1c0 100644 --- a/explorer/src/components/instruction/serum/CancelOrderV2Details.tsx +++ b/explorer/src/components/instruction/serum/CancelOrderV2Details.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { CancelOrderV2 } from "./types"; +import { CancelOrderV2, SerumIxDetailsProps } from "./types"; -export function CancelOrderV2DetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: CancelOrderV2; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function CancelOrderV2DetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/CloseOpenOrdersDetails.tsx b/explorer/src/components/instruction/serum/CloseOpenOrdersDetails.tsx index 23485eb9b8..072e19a278 100644 --- a/explorer/src/components/instruction/serum/CloseOpenOrdersDetails.tsx +++ b/explorer/src/components/instruction/serum/CloseOpenOrdersDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { CloseOpenOrders } from "./types"; +import { CloseOpenOrders, SerumIxDetailsProps } from "./types"; -export function CloseOpenOrdersDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: CloseOpenOrders; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function CloseOpenOrdersDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/ConsumeEventsDetails.tsx b/explorer/src/components/instruction/serum/ConsumeEventsDetails.tsx index 2b6e764033..0cab2c92e0 100644 --- a/explorer/src/components/instruction/serum/ConsumeEventsDetails.tsx +++ b/explorer/src/components/instruction/serum/ConsumeEventsDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { ConsumeEvents } from "./types"; +import { ConsumeEvents, SerumIxDetailsProps } from "./types"; -export function ConsumeEventsDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: ConsumeEvents; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function ConsumeEventsDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/ConsumeEventsPermissionedDetails.tsx b/explorer/src/components/instruction/serum/ConsumeEventsPermissionedDetails.tsx index 42abd6c793..0eaf5dd63c 100644 --- a/explorer/src/components/instruction/serum/ConsumeEventsPermissionedDetails.tsx +++ b/explorer/src/components/instruction/serum/ConsumeEventsPermissionedDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { ConsumeEventsPermissioned } from "./types"; +import { ConsumeEventsPermissioned, SerumIxDetailsProps } from "./types"; -export function ConsumeEventsPermissionedDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: ConsumeEventsPermissioned; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function ConsumeEventsPermissionedDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/DisableMarketDetails.tsx b/explorer/src/components/instruction/serum/DisableMarketDetails.tsx index 5d49223f76..f2c68e6465 100644 --- a/explorer/src/components/instruction/serum/DisableMarketDetails.tsx +++ b/explorer/src/components/instruction/serum/DisableMarketDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { DisableMarket } from "./types"; +import { DisableMarket, SerumIxDetailsProps } from "./types"; -export function DisableMarketDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: DisableMarket; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function DisableMarketDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/InitOpenOrdersDetails.tsx b/explorer/src/components/instruction/serum/InitOpenOrdersDetails.tsx index daae90c3b5..56294bd0d3 100644 --- a/explorer/src/components/instruction/serum/InitOpenOrdersDetails.tsx +++ b/explorer/src/components/instruction/serum/InitOpenOrdersDetails.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { InitOpenOrders } from "./types"; +import { InitOpenOrders, SerumIxDetailsProps } from "./types"; -export function InitOpenOrdersDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: InitOpenOrders; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function InitOpenOrdersDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/InitializeMarketDetailsCard.tsx b/explorer/src/components/instruction/serum/InitializeMarketDetailsCard.tsx index 2e965f8a50..f6184f5f0a 100644 --- a/explorer/src/components/instruction/serum/InitializeMarketDetailsCard.tsx +++ b/explorer/src/components/instruction/serum/InitializeMarketDetailsCard.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { InitializeMarket } from "./types"; +import { InitializeMarket, SerumIxDetailsProps } from "./types"; -export function InitializeMarketDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: InitializeMarket; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function InitializeMarketDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/MatchOrdersDetailsCard.tsx b/explorer/src/components/instruction/serum/MatchOrdersDetailsCard.tsx index 63c841b0ab..239c44f812 100644 --- a/explorer/src/components/instruction/serum/MatchOrdersDetailsCard.tsx +++ b/explorer/src/components/instruction/serum/MatchOrdersDetailsCard.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { MatchOrders } from "./types"; +import { MatchOrders, SerumIxDetailsProps } from "./types"; -export function MatchOrdersDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: MatchOrders; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function MatchOrdersDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/NewOrderDetailsCard.tsx b/explorer/src/components/instruction/serum/NewOrderDetailsCard.tsx index 8244ad82ea..70d31db7f1 100644 --- a/explorer/src/components/instruction/serum/NewOrderDetailsCard.tsx +++ b/explorer/src/components/instruction/serum/NewOrderDetailsCard.tsx @@ -1,25 +1,18 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { NewOrder } from "./types"; +import { NewOrder, SerumIxDetailsProps } from "./types"; -export function NewOrderDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: NewOrder; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function NewOrderDetailsCard(props: SerumIxDetailsProps) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/NewOrderV3DetailsCard.tsx b/explorer/src/components/instruction/serum/NewOrderV3DetailsCard.tsx index f00ef3a5c9..26ad59bd98 100644 --- a/explorer/src/components/instruction/serum/NewOrderV3DetailsCard.tsx +++ b/explorer/src/components/instruction/serum/NewOrderV3DetailsCard.tsx @@ -1,25 +1,18 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { NewOrderV3 } from "./types"; +import { NewOrderV3, SerumIxDetailsProps } from "./types"; -export function NewOrderV3DetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: NewOrderV3; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function NewOrderV3DetailsCard(props: SerumIxDetailsProps) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/PruneDetails.tsx b/explorer/src/components/instruction/serum/PruneDetails.tsx index 89507f93e0..9f7620ca5c 100644 --- a/explorer/src/components/instruction/serum/PruneDetails.tsx +++ b/explorer/src/components/instruction/serum/PruneDetails.tsx @@ -1,25 +1,18 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { Prune } from "./types"; +import { Prune, SerumIxDetailsProps } from "./types"; -export function PruneDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: Prune; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function PruneDetailsCard(props: SerumIxDetailsProps) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/SettleFundsDetailsCard.tsx b/explorer/src/components/instruction/serum/SettleFundsDetailsCard.tsx index c4c73fa501..e40a9588fd 100644 --- a/explorer/src/components/instruction/serum/SettleFundsDetailsCard.tsx +++ b/explorer/src/components/instruction/serum/SettleFundsDetailsCard.tsx @@ -1,25 +1,20 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { SettleFunds } from "./types"; +import { SettleFunds, SerumIxDetailsProps } from "./types"; -export function SettleFundsDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: SettleFunds; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function SettleFundsDetailsCard( + props: SerumIxDetailsProps +) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/SweepFeesDetails.tsx b/explorer/src/components/instruction/serum/SweepFeesDetails.tsx index 3051f76983..ccc9c615bf 100644 --- a/explorer/src/components/instruction/serum/SweepFeesDetails.tsx +++ b/explorer/src/components/instruction/serum/SweepFeesDetails.tsx @@ -1,25 +1,18 @@ import React from "react"; -import { SignatureResult, TransactionInstruction } from "@solana/web3.js"; import { InstructionCard } from "../InstructionCard"; import { Address } from "components/common/Address"; -import { SweepFees } from "./types"; +import { SweepFees, SerumIxDetailsProps } from "./types"; -export function SweepFeesDetailsCard(props: { - ix: TransactionInstruction; - index: number; - result: SignatureResult; - info: SweepFees; - innerCards?: JSX.Element[]; - childIndex?: number; -}) { - const { ix, index, result, info, innerCards, childIndex } = props; +export function SweepFeesDetailsCard(props: SerumIxDetailsProps) { + const { ix, index, result, programName, info, innerCards, childIndex } = + props; return ( diff --git a/explorer/src/components/instruction/serum/types.ts b/explorer/src/components/instruction/serum/types.ts index 83af721e63..f5d0defeec 100644 --- a/explorer/src/components/instruction/serum/types.ts +++ b/explorer/src/components/instruction/serum/types.ts @@ -4,14 +4,19 @@ import { decodeInstruction, MARKETS } from "@project-serum/serum"; import { AccountMeta, PublicKey, + SignatureResult, TransactionInstruction, } from "@solana/web3.js"; import { enums, number, type, Infer, create } from "superstruct"; import { BigIntFromString } from "validators/number"; +export const OPEN_BOOK_PROGRAM_ID = + "srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"; + const SERUM_PROGRAM_IDS = [ "4ckmDgGdxQoPDLUkDT3vHgSAkzA3QRdNq5ywwY4sUSJn", "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin", + OPEN_BOOK_PROGRAM_ID, ]; export const SERUM_DECODED_MAX = 6; @@ -631,3 +636,13 @@ export function parseSerumInstructionTitle( return SERUM_CODE_LOOKUP[code]; } + +export type SerumIxDetailsProps = { + ix: TransactionInstruction; + index: number; + result: SignatureResult; + info: T; + programName: string; + innerCards?: JSX.Element[]; + childIndex?: number; +}; diff --git a/explorer/src/utils/tx.ts b/explorer/src/utils/tx.ts index 194fdc8a49..bd657f1d46 100644 --- a/explorer/src/utils/tx.ts +++ b/explorer/src/utils/tx.ts @@ -20,6 +20,7 @@ import { import { Cluster } from "providers/cluster"; import { SerumMarketRegistry } from "serumMarketRegistry"; import { TokenInfoMap } from "@solana/spl-token-registry"; +import { OPEN_BOOK_PROGRAM_ID } from "components/instruction/serum/types"; export enum PROGRAM_NAMES { // native built-ins @@ -99,6 +100,7 @@ export enum PROGRAM_NAMES { SOLANART = "Solanart", SOLANART_GO = "Solanart - Global offers", STEPN_DEX = "STEPN Dex", + OPENBOOK_DEX = "OpenBook Dex", } const ALL_CLUSTERS = [ @@ -415,6 +417,10 @@ export const PROGRAM_INFO_BY_ID: { [address: string]: ProgramInfo } = { name: PROGRAM_NAMES.STEPN_DEX, deployments: [Cluster.MainnetBeta], }, + [OPEN_BOOK_PROGRAM_ID]: { + name: PROGRAM_NAMES.OPENBOOK_DEX, + deployments: [Cluster.MainnetBeta], + }, }; export type LoaderName = typeof LOADER_IDS[keyof typeof LOADER_IDS];