Explorer: use explicit types for instruction info (#13257)
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { coerce } from "superstruct";
|
import { coerce } from "superstruct";
|
||||||
import { ParsedInfo } from "validators";
|
import { ParsedInfo } from "validators";
|
||||||
import { IX_STRUCTS } from "./types";
|
import { WriteInfo, FinalizeInfo } from "./types";
|
||||||
import { reportError } from "utils/sentry";
|
import { reportError } from "utils/sentry";
|
||||||
import { UnknownDetailsCard } from "../UnknownDetailsCard";
|
import { UnknownDetailsCard } from "../UnknownDetailsCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
@@ -24,13 +24,16 @@ type DetailsProps = {
|
|||||||
export function BpfLoaderDetailsCard(props: DetailsProps) {
|
export function BpfLoaderDetailsCard(props: DetailsProps) {
|
||||||
try {
|
try {
|
||||||
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
||||||
const info = coerce(parsed.info, IX_STRUCTS[parsed.type]);
|
|
||||||
|
|
||||||
switch (parsed.type) {
|
switch (parsed.type) {
|
||||||
case "write":
|
case "write": {
|
||||||
|
const info = coerce(parsed.info, WriteInfo);
|
||||||
return <BpfLoaderWriteDetailsCard info={info} {...props} />;
|
return <BpfLoaderWriteDetailsCard info={info} {...props} />;
|
||||||
case "finalize":
|
}
|
||||||
|
case "finalize": {
|
||||||
|
const info = coerce(parsed.info, FinalizeInfo);
|
||||||
return <BpfLoaderFinalizeDetailsCard info={info} {...props} />;
|
return <BpfLoaderFinalizeDetailsCard info={info} {...props} />;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return <UnknownDetailsCard {...props} />;
|
return <UnknownDetailsCard {...props} />;
|
||||||
}
|
}
|
||||||
@@ -42,14 +45,14 @@ export function BpfLoaderDetailsCard(props: DetailsProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props<T> = {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: T;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function BpfLoaderWriteDetailsCard(props: Props) {
|
export function BpfLoaderWriteDetailsCard(props: Props<WriteInfo>) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
const bytes = wrap(info.bytes, 50);
|
const bytes = wrap(info.bytes, 50);
|
||||||
return (
|
return (
|
||||||
@@ -90,7 +93,7 @@ export function BpfLoaderWriteDetailsCard(props: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BpfLoaderFinalizeDetailsCard(props: Props) {
|
export function BpfLoaderFinalizeDetailsCard(props: Props<FinalizeInfo>) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -3,13 +3,15 @@
|
|||||||
import { enums, number, pick, string, StructType } from "superstruct";
|
import { enums, number, pick, string, StructType } from "superstruct";
|
||||||
import { Pubkey } from "validators/pubkey";
|
import { Pubkey } from "validators/pubkey";
|
||||||
|
|
||||||
const Write = pick({
|
export type WriteInfo = StructType<typeof WriteInfo>;
|
||||||
|
export const WriteInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
bytes: string(),
|
bytes: string(),
|
||||||
offset: number(),
|
offset: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Finalize = pick({
|
export type FinalizeInfo = StructType<typeof FinalizeInfo>;
|
||||||
|
export const FinalizeInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -17,8 +19,3 @@ export type BpfLoaderInstructionType = StructType<
|
|||||||
typeof BpfLoaderInstructionType
|
typeof BpfLoaderInstructionType
|
||||||
>;
|
>;
|
||||||
export const BpfLoaderInstructionType = enums(["write", "finalize"]);
|
export const BpfLoaderInstructionType = enums(["write", "finalize"]);
|
||||||
|
|
||||||
export const IX_STRUCTS: { [id: string]: any } = {
|
|
||||||
write: Write,
|
|
||||||
finalize: Finalize,
|
|
||||||
};
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AuthorizeInfo } from "./types";
|
||||||
|
|
||||||
export function AuthorizeDetailsCard(props: {
|
export function AuthorizeDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AuthorizeInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { DeactivateInfo } from "./types";
|
||||||
|
|
||||||
export function DeactivateDetailsCard(props: {
|
export function DeactivateDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: DeactivateInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { DelegateInfo } from "./types";
|
||||||
|
|
||||||
export function DelegateDetailsCard(props: {
|
export function DelegateDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: DelegateInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { InitializeInfo } from "./types";
|
||||||
|
|
||||||
export function InitializeDetailsCard(props: {
|
export function InitializeDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: InitializeInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { lamportsToSolString } from "utils";
|
import { lamportsToSolString } from "utils";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { SplitInfo } from "./types";
|
||||||
|
|
||||||
export function SplitDetailsCard(props: {
|
export function SplitDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: SplitInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -15,7 +15,14 @@ import { DeactivateDetailsCard } from "./DeactivateDetailsCard";
|
|||||||
import { ParsedInfo } from "validators";
|
import { ParsedInfo } from "validators";
|
||||||
import { reportError } from "utils/sentry";
|
import { reportError } from "utils/sentry";
|
||||||
import { coerce } from "superstruct";
|
import { coerce } from "superstruct";
|
||||||
import { IX_STRUCTS } from "./types";
|
import {
|
||||||
|
AuthorizeInfo,
|
||||||
|
DeactivateInfo,
|
||||||
|
DelegateInfo,
|
||||||
|
InitializeInfo,
|
||||||
|
SplitInfo,
|
||||||
|
WithdrawInfo,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
tx: ParsedTransaction;
|
tx: ParsedTransaction;
|
||||||
@@ -27,21 +34,32 @@ type DetailsProps = {
|
|||||||
export function StakeDetailsCard(props: DetailsProps) {
|
export function StakeDetailsCard(props: DetailsProps) {
|
||||||
try {
|
try {
|
||||||
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
||||||
const info = coerce(parsed.info, IX_STRUCTS[parsed.type]);
|
|
||||||
|
|
||||||
switch (parsed.type) {
|
switch (parsed.type) {
|
||||||
case "initialize":
|
case "initialize": {
|
||||||
|
const info = coerce(parsed.info, InitializeInfo);
|
||||||
return <InitializeDetailsCard info={info} {...props} />;
|
return <InitializeDetailsCard info={info} {...props} />;
|
||||||
case "delegate":
|
}
|
||||||
|
case "delegate": {
|
||||||
|
const info = coerce(parsed.info, DelegateInfo);
|
||||||
return <DelegateDetailsCard info={info} {...props} />;
|
return <DelegateDetailsCard info={info} {...props} />;
|
||||||
case "authorize":
|
}
|
||||||
|
case "authorize": {
|
||||||
|
const info = coerce(parsed.info, AuthorizeInfo);
|
||||||
return <AuthorizeDetailsCard info={info} {...props} />;
|
return <AuthorizeDetailsCard info={info} {...props} />;
|
||||||
case "split":
|
}
|
||||||
|
case "split": {
|
||||||
|
const info = coerce(parsed.info, SplitInfo);
|
||||||
return <SplitDetailsCard info={info} {...props} />;
|
return <SplitDetailsCard info={info} {...props} />;
|
||||||
case "withdraw":
|
}
|
||||||
|
case "withdraw": {
|
||||||
|
const info = coerce(parsed.info, WithdrawInfo);
|
||||||
return <WithdrawDetailsCard info={info} {...props} />;
|
return <WithdrawDetailsCard info={info} {...props} />;
|
||||||
case "deactivate":
|
}
|
||||||
|
case "deactivate": {
|
||||||
|
const info = coerce(parsed.info, DeactivateInfo);
|
||||||
return <DeactivateDetailsCard info={info} {...props} />;
|
return <DeactivateDetailsCard info={info} {...props} />;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return <UnknownDetailsCard {...props} />;
|
return <UnknownDetailsCard {...props} />;
|
||||||
}
|
}
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { lamportsToSolString } from "utils";
|
import { lamportsToSolString } from "utils";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { WithdrawInfo } from "./types";
|
||||||
|
|
||||||
export function WithdrawDetailsCard(props: {
|
export function WithdrawDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: WithdrawInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
import { enums, number, pick, string, StructType } from "superstruct";
|
import { enums, number, pick, string, StructType } from "superstruct";
|
||||||
import { Pubkey } from "validators/pubkey";
|
import { Pubkey } from "validators/pubkey";
|
||||||
|
|
||||||
const Initialize = pick({
|
export type InitializeInfo = StructType<typeof InitializeInfo>;
|
||||||
|
export const InitializeInfo = pick({
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
authorized: pick({
|
authorized: pick({
|
||||||
staker: Pubkey,
|
staker: Pubkey,
|
||||||
@@ -16,34 +17,39 @@ const Initialize = pick({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Delegate = pick({
|
export type DelegateInfo = StructType<typeof DelegateInfo>;
|
||||||
|
export const DelegateInfo = pick({
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
voteAccount: Pubkey,
|
voteAccount: Pubkey,
|
||||||
stakeAuthority: Pubkey,
|
stakeAuthority: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Authorize = pick({
|
export type AuthorizeInfo = StructType<typeof AuthorizeInfo>;
|
||||||
|
export const AuthorizeInfo = pick({
|
||||||
authorityType: string(),
|
authorityType: string(),
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
authority: Pubkey,
|
authority: Pubkey,
|
||||||
newAuthority: Pubkey,
|
newAuthority: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Split = pick({
|
export type SplitInfo = StructType<typeof SplitInfo>;
|
||||||
|
export const SplitInfo = pick({
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
stakeAuthority: Pubkey,
|
stakeAuthority: Pubkey,
|
||||||
newSplitAccount: Pubkey,
|
newSplitAccount: Pubkey,
|
||||||
lamports: number(),
|
lamports: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Withdraw = pick({
|
export type WithdrawInfo = StructType<typeof WithdrawInfo>;
|
||||||
|
export const WithdrawInfo = pick({
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
withdrawAuthority: Pubkey,
|
withdrawAuthority: Pubkey,
|
||||||
destination: Pubkey,
|
destination: Pubkey,
|
||||||
lamports: number(),
|
lamports: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const Deactivate = pick({
|
export type DeactivateInfo = StructType<typeof DeactivateInfo>;
|
||||||
|
export const DeactivateInfo = pick({
|
||||||
stakeAccount: Pubkey,
|
stakeAccount: Pubkey,
|
||||||
stakeAuthority: Pubkey,
|
stakeAuthority: Pubkey,
|
||||||
});
|
});
|
||||||
@@ -57,12 +63,3 @@ export const StakeInstructionType = enums([
|
|||||||
"withdraw",
|
"withdraw",
|
||||||
"deactivate",
|
"deactivate",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const IX_STRUCTS: { [id: string]: any } = {
|
|
||||||
initialize: Initialize,
|
|
||||||
delegate: Delegate,
|
|
||||||
authorize: Authorize,
|
|
||||||
split: Split,
|
|
||||||
withdraw: Withdraw,
|
|
||||||
deactivate: Deactivate,
|
|
||||||
};
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AllocateInfo } from "./types";
|
||||||
|
|
||||||
export function AllocateDetailsCard(props: {
|
export function AllocateDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AllocateInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Copyable } from "components/common/Copyable";
|
import { Copyable } from "components/common/Copyable";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AllocateWithSeedInfo } from "./types";
|
||||||
|
|
||||||
export function AllocateWithSeedDetailsCard(props: {
|
export function AllocateWithSeedDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AllocateWithSeedInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AssignInfo } from "./types";
|
||||||
|
|
||||||
export function AssignDetailsCard(props: {
|
export function AssignDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AssignInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Copyable } from "components/common/Copyable";
|
import { Copyable } from "components/common/Copyable";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AssignWithSeedInfo } from "./types";
|
||||||
|
|
||||||
export function AssignWithSeedDetailsCard(props: {
|
export function AssignWithSeedDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AssignWithSeedInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { lamportsToSolString } from "utils";
|
import { lamportsToSolString } from "utils";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { CreateAccountInfo } from "./types";
|
||||||
|
|
||||||
export function CreateDetailsCard(props: {
|
export function CreateDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: CreateAccountInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -8,12 +8,13 @@ import { lamportsToSolString } from "utils";
|
|||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Copyable } from "components/common/Copyable";
|
import { Copyable } from "components/common/Copyable";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { CreateAccountWithSeedInfo } from "./types";
|
||||||
|
|
||||||
export function CreateWithSeedDetailsCard(props: {
|
export function CreateWithSeedDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: CreateAccountWithSeedInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AdvanceNonceAccountInfo } from "./types";
|
||||||
|
|
||||||
export function NonceAdvanceDetailsCard(props: {
|
export function NonceAdvanceDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AdvanceNonceAccountInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { AuthorizeNonceAccountInfo } from "./types";
|
||||||
|
|
||||||
export function NonceAuthorizeDetailsCard(props: {
|
export function NonceAuthorizeDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: AuthorizeNonceAccountInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -6,12 +6,13 @@ import {
|
|||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { InitializeNonceAccountInfo } from "./types";
|
||||||
|
|
||||||
export function NonceInitializeDetailsCard(props: {
|
export function NonceInitializeDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: InitializeNonceAccountInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { lamportsToSolString } from "utils";
|
import { lamportsToSolString } from "utils";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { WithdrawNonceAccountInfo } from "./types";
|
||||||
|
|
||||||
export function NonceWithdrawDetailsCard(props: {
|
export function NonceWithdrawDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: WithdrawNonceAccountInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -20,7 +20,19 @@ import { NonceAuthorizeDetailsCard } from "./NonceAuthorizeDetailsCard";
|
|||||||
import { ParsedInfo } from "validators";
|
import { ParsedInfo } from "validators";
|
||||||
import { coerce } from "superstruct";
|
import { coerce } from "superstruct";
|
||||||
import { reportError } from "utils/sentry";
|
import { reportError } from "utils/sentry";
|
||||||
import { IX_STRUCTS } from "./types";
|
import {
|
||||||
|
CreateAccountInfo,
|
||||||
|
CreateAccountWithSeedInfo,
|
||||||
|
AllocateInfo,
|
||||||
|
AllocateWithSeedInfo,
|
||||||
|
AssignInfo,
|
||||||
|
AssignWithSeedInfo,
|
||||||
|
TransferInfo,
|
||||||
|
AdvanceNonceAccountInfo,
|
||||||
|
AuthorizeNonceAccountInfo,
|
||||||
|
InitializeNonceAccountInfo,
|
||||||
|
WithdrawNonceAccountInfo,
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
tx: ParsedTransaction;
|
tx: ParsedTransaction;
|
||||||
@@ -32,31 +44,51 @@ type DetailsProps = {
|
|||||||
export function SystemDetailsCard(props: DetailsProps) {
|
export function SystemDetailsCard(props: DetailsProps) {
|
||||||
try {
|
try {
|
||||||
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
const parsed = coerce(props.ix.parsed, ParsedInfo);
|
||||||
const info = coerce(parsed.info, IX_STRUCTS[parsed.type]);
|
|
||||||
|
|
||||||
switch (parsed.type) {
|
switch (parsed.type) {
|
||||||
case "createAccount":
|
case "createAccount": {
|
||||||
|
const info = coerce(parsed.info, CreateAccountInfo);
|
||||||
return <CreateDetailsCard info={info} {...props} />;
|
return <CreateDetailsCard info={info} {...props} />;
|
||||||
case "createAccountWithSeed":
|
}
|
||||||
|
case "createAccountWithSeed": {
|
||||||
|
const info = coerce(parsed.info, CreateAccountWithSeedInfo);
|
||||||
return <CreateWithSeedDetailsCard info={info} {...props} />;
|
return <CreateWithSeedDetailsCard info={info} {...props} />;
|
||||||
case "allocate":
|
}
|
||||||
|
case "allocate": {
|
||||||
|
const info = coerce(parsed.info, AllocateInfo);
|
||||||
return <AllocateDetailsCard info={info} {...props} />;
|
return <AllocateDetailsCard info={info} {...props} />;
|
||||||
case "allocateWithSeed":
|
}
|
||||||
|
case "allocateWithSeed": {
|
||||||
|
const info = coerce(parsed.info, AllocateWithSeedInfo);
|
||||||
return <AllocateWithSeedDetailsCard info={info} {...props} />;
|
return <AllocateWithSeedDetailsCard info={info} {...props} />;
|
||||||
case "assign":
|
}
|
||||||
|
case "assign": {
|
||||||
|
const info = coerce(parsed.info, AssignInfo);
|
||||||
return <AssignDetailsCard info={info} {...props} />;
|
return <AssignDetailsCard info={info} {...props} />;
|
||||||
case "assignWithSeed":
|
}
|
||||||
|
case "assignWithSeed": {
|
||||||
|
const info = coerce(parsed.info, AssignWithSeedInfo);
|
||||||
return <AssignWithSeedDetailsCard info={info} {...props} />;
|
return <AssignWithSeedDetailsCard info={info} {...props} />;
|
||||||
case "transfer":
|
}
|
||||||
|
case "transfer": {
|
||||||
|
const info = coerce(parsed.info, TransferInfo);
|
||||||
return <TransferDetailsCard info={info} {...props} />;
|
return <TransferDetailsCard info={info} {...props} />;
|
||||||
case "advanceNonceAccount":
|
}
|
||||||
|
case "advanceNonceAccount": {
|
||||||
|
const info = coerce(parsed.info, AdvanceNonceAccountInfo);
|
||||||
return <NonceAdvanceDetailsCard info={info} {...props} />;
|
return <NonceAdvanceDetailsCard info={info} {...props} />;
|
||||||
case "withdrawNonceAccount":
|
}
|
||||||
|
case "withdrawNonceAccount": {
|
||||||
|
const info = coerce(parsed.info, WithdrawNonceAccountInfo);
|
||||||
return <NonceWithdrawDetailsCard info={info} {...props} />;
|
return <NonceWithdrawDetailsCard info={info} {...props} />;
|
||||||
case "authorizeNonceAccount":
|
}
|
||||||
|
case "authorizeNonceAccount": {
|
||||||
|
const info = coerce(parsed.info, AuthorizeNonceAccountInfo);
|
||||||
return <NonceAuthorizeDetailsCard info={info} {...props} />;
|
return <NonceAuthorizeDetailsCard info={info} {...props} />;
|
||||||
case "initializeNonceAccount":
|
}
|
||||||
|
case "initializeNonceAccount": {
|
||||||
|
const info = coerce(parsed.info, InitializeNonceAccountInfo);
|
||||||
return <NonceInitializeDetailsCard info={info} {...props} />;
|
return <NonceInitializeDetailsCard info={info} {...props} />;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return <UnknownDetailsCard {...props} />;
|
return <UnknownDetailsCard {...props} />;
|
||||||
}
|
}
|
||||||
|
@@ -7,12 +7,13 @@ import {
|
|||||||
import { lamportsToSolString } from "utils";
|
import { lamportsToSolString } from "utils";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { Address } from "components/common/Address";
|
import { Address } from "components/common/Address";
|
||||||
|
import { TransferInfo } from "./types";
|
||||||
|
|
||||||
export function TransferDetailsCard(props: {
|
export function TransferDetailsCard(props: {
|
||||||
ix: ParsedInstruction;
|
ix: ParsedInstruction;
|
||||||
index: number;
|
index: number;
|
||||||
result: SignatureResult;
|
result: SignatureResult;
|
||||||
info: any;
|
info: TransferInfo;
|
||||||
}) {
|
}) {
|
||||||
const { ix, index, result, info } = props;
|
const { ix, index, result, info } = props;
|
||||||
|
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
import { enums, number, pick, string, StructType } from "superstruct";
|
import { enums, number, pick, string, StructType } from "superstruct";
|
||||||
import { Pubkey } from "validators/pubkey";
|
import { Pubkey } from "validators/pubkey";
|
||||||
|
|
||||||
const CreateAccount = pick({
|
export type CreateAccountInfo = StructType<typeof CreateAccountInfo>;
|
||||||
|
export const CreateAccountInfo = pick({
|
||||||
source: Pubkey,
|
source: Pubkey,
|
||||||
newAccount: Pubkey,
|
newAccount: Pubkey,
|
||||||
lamports: number(),
|
lamports: number(),
|
||||||
@@ -11,18 +12,23 @@ const CreateAccount = pick({
|
|||||||
owner: Pubkey,
|
owner: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Assign = pick({
|
export type AssignInfo = StructType<typeof AssignInfo>;
|
||||||
|
export const AssignInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
owner: Pubkey,
|
owner: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Transfer = pick({
|
export type TransferInfo = StructType<typeof TransferInfo>;
|
||||||
|
export const TransferInfo = pick({
|
||||||
source: Pubkey,
|
source: Pubkey,
|
||||||
destination: Pubkey,
|
destination: Pubkey,
|
||||||
lamports: number(),
|
lamports: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const CreateAccountWithSeed = pick({
|
export type CreateAccountWithSeedInfo = StructType<
|
||||||
|
typeof CreateAccountWithSeedInfo
|
||||||
|
>;
|
||||||
|
export const CreateAccountWithSeedInfo = pick({
|
||||||
source: Pubkey,
|
source: Pubkey,
|
||||||
newAccount: Pubkey,
|
newAccount: Pubkey,
|
||||||
base: Pubkey,
|
base: Pubkey,
|
||||||
@@ -32,35 +38,49 @@ const CreateAccountWithSeed = pick({
|
|||||||
owner: Pubkey,
|
owner: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AdvanceNonceAccount = pick({
|
export type AdvanceNonceAccountInfo = StructType<
|
||||||
|
typeof AdvanceNonceAccountInfo
|
||||||
|
>;
|
||||||
|
export const AdvanceNonceAccountInfo = pick({
|
||||||
nonceAccount: Pubkey,
|
nonceAccount: Pubkey,
|
||||||
nonceAuthority: Pubkey,
|
nonceAuthority: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const WithdrawNonceAccount = pick({
|
export type WithdrawNonceAccountInfo = StructType<
|
||||||
|
typeof WithdrawNonceAccountInfo
|
||||||
|
>;
|
||||||
|
export const WithdrawNonceAccountInfo = pick({
|
||||||
nonceAccount: Pubkey,
|
nonceAccount: Pubkey,
|
||||||
destination: Pubkey,
|
destination: Pubkey,
|
||||||
nonceAuthority: Pubkey,
|
nonceAuthority: Pubkey,
|
||||||
lamports: number(),
|
lamports: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const InitializeNonceAccount = pick({
|
export type InitializeNonceAccountInfo = StructType<
|
||||||
|
typeof InitializeNonceAccountInfo
|
||||||
|
>;
|
||||||
|
export const InitializeNonceAccountInfo = pick({
|
||||||
nonceAccount: Pubkey,
|
nonceAccount: Pubkey,
|
||||||
nonceAuthority: Pubkey,
|
nonceAuthority: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AuthorizeNonceAccount = pick({
|
export type AuthorizeNonceAccountInfo = StructType<
|
||||||
|
typeof AuthorizeNonceAccountInfo
|
||||||
|
>;
|
||||||
|
export const AuthorizeNonceAccountInfo = pick({
|
||||||
nonceAccount: Pubkey,
|
nonceAccount: Pubkey,
|
||||||
nonceAuthority: Pubkey,
|
nonceAuthority: Pubkey,
|
||||||
newAuthorized: Pubkey,
|
newAuthorized: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const Allocate = pick({
|
export type AllocateInfo = StructType<typeof AllocateInfo>;
|
||||||
|
export const AllocateInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
space: number(),
|
space: number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const AllocateWithSeed = pick({
|
export type AllocateWithSeedInfo = StructType<typeof AllocateWithSeedInfo>;
|
||||||
|
export const AllocateWithSeedInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
base: Pubkey,
|
base: Pubkey,
|
||||||
seed: string(),
|
seed: string(),
|
||||||
@@ -68,14 +88,16 @@ const AllocateWithSeed = pick({
|
|||||||
owner: Pubkey,
|
owner: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AssignWithSeed = pick({
|
export type AssignWithSeedInfo = StructType<typeof AssignWithSeedInfo>;
|
||||||
|
export const AssignWithSeedInfo = pick({
|
||||||
account: Pubkey,
|
account: Pubkey,
|
||||||
base: Pubkey,
|
base: Pubkey,
|
||||||
seed: string(),
|
seed: string(),
|
||||||
owner: Pubkey,
|
owner: Pubkey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const TransferWithSeed = pick({
|
export type TransferWithSeedInfo = StructType<typeof TransferWithSeedInfo>;
|
||||||
|
export const TransferWithSeedInfo = pick({
|
||||||
source: Pubkey,
|
source: Pubkey,
|
||||||
sourceBase: Pubkey,
|
sourceBase: Pubkey,
|
||||||
destination: Pubkey,
|
destination: Pubkey,
|
||||||
@@ -97,19 +119,5 @@ export const SystemInstructionType = enums([
|
|||||||
"withdrawNonceAccount",
|
"withdrawNonceAccount",
|
||||||
"authorizeNonceAccount",
|
"authorizeNonceAccount",
|
||||||
"initializeNonceAccount",
|
"initializeNonceAccount",
|
||||||
|
// "transferWithSeed", TODO: Add support for transfer with seed
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const IX_STRUCTS: { [id: string]: any } = {
|
|
||||||
createAccount: CreateAccount,
|
|
||||||
createAccountWithSeed: CreateAccountWithSeed,
|
|
||||||
allocate: Allocate,
|
|
||||||
allocateWithSeed: AllocateWithSeed,
|
|
||||||
assign: Assign,
|
|
||||||
assignWithSeed: AssignWithSeed,
|
|
||||||
transfer: Transfer,
|
|
||||||
advanceNonceAccount: AdvanceNonceAccount,
|
|
||||||
withdrawNonceAccount: WithdrawNonceAccount,
|
|
||||||
authorizeNonceAccount: AuthorizeNonceAccount,
|
|
||||||
initializeNonceAccount: InitializeNonceAccount,
|
|
||||||
transferWithSeed: TransferWithSeed, // TODO: Add support for transfer with seed
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user