Explorer: Support additional bpf upgradeable loader instructions (#28342)
This commit is contained in:
parent
bcbf4c7fb3
commit
928730ac94
|
@ -13,7 +13,9 @@ import { ParsedInfo } from "validators";
|
||||||
import { InstructionCard } from "../InstructionCard";
|
import { InstructionCard } from "../InstructionCard";
|
||||||
import { UnknownDetailsCard } from "../UnknownDetailsCard";
|
import { UnknownDetailsCard } from "../UnknownDetailsCard";
|
||||||
import {
|
import {
|
||||||
|
CloseInfo,
|
||||||
DeployWithMaxDataLenInfo,
|
DeployWithMaxDataLenInfo,
|
||||||
|
ExtendProgramInfo,
|
||||||
InitializeBufferInfo,
|
InitializeBufferInfo,
|
||||||
SetAuthorityInfo,
|
SetAuthorityInfo,
|
||||||
UpgradeInfo,
|
UpgradeInfo,
|
||||||
|
@ -33,15 +35,16 @@ export function BpfUpgradeableLoaderDetailsCard(props: DetailsProps) {
|
||||||
try {
|
try {
|
||||||
const parsed = create(props.ix.parsed, ParsedInfo);
|
const parsed = create(props.ix.parsed, ParsedInfo);
|
||||||
switch (parsed.type) {
|
switch (parsed.type) {
|
||||||
|
case "initializeBuffer": {
|
||||||
|
return renderDetails<InitializeBufferInfo>(
|
||||||
|
props,
|
||||||
|
parsed,
|
||||||
|
InitializeBufferInfo
|
||||||
|
);
|
||||||
|
}
|
||||||
case "write": {
|
case "write": {
|
||||||
return renderDetails<WriteInfo>(props, parsed, WriteInfo);
|
return renderDetails<WriteInfo>(props, parsed, WriteInfo);
|
||||||
}
|
}
|
||||||
case "upgrade": {
|
|
||||||
return renderDetails<UpgradeInfo>(props, parsed, UpgradeInfo);
|
|
||||||
}
|
|
||||||
case "setAuthority": {
|
|
||||||
return renderDetails<SetAuthorityInfo>(props, parsed, SetAuthorityInfo);
|
|
||||||
}
|
|
||||||
case "deployWithMaxDataLen": {
|
case "deployWithMaxDataLen": {
|
||||||
return renderDetails<DeployWithMaxDataLenInfo>(
|
return renderDetails<DeployWithMaxDataLenInfo>(
|
||||||
props,
|
props,
|
||||||
|
@ -49,11 +52,20 @@ export function BpfUpgradeableLoaderDetailsCard(props: DetailsProps) {
|
||||||
DeployWithMaxDataLenInfo
|
DeployWithMaxDataLenInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case "initializeBuffer": {
|
case "upgrade": {
|
||||||
return renderDetails<InitializeBufferInfo>(
|
return renderDetails<UpgradeInfo>(props, parsed, UpgradeInfo);
|
||||||
|
}
|
||||||
|
case "setAuthority": {
|
||||||
|
return renderDetails<SetAuthorityInfo>(props, parsed, SetAuthorityInfo);
|
||||||
|
}
|
||||||
|
case "close": {
|
||||||
|
return renderDetails<CloseInfo>(props, parsed, CloseInfo);
|
||||||
|
}
|
||||||
|
case "extendProgram": {
|
||||||
|
return renderDetails<ExtendProgramInfo>(
|
||||||
props,
|
props,
|
||||||
parsed,
|
parsed,
|
||||||
InitializeBufferInfo
|
ExtendProgramInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,51 +1,68 @@
|
||||||
/* eslint-disable @typescript-eslint/no-redeclare */
|
/* eslint-disable @typescript-eslint/no-redeclare */
|
||||||
|
|
||||||
import { enums, nullable, number, type, string, Infer } from "superstruct";
|
import { enums, number, type, string, Infer, optional } from "superstruct";
|
||||||
import { PublicKeyFromString } from "validators/pubkey";
|
import { PublicKeyFromString } from "validators/pubkey";
|
||||||
|
|
||||||
export type WriteInfo = Infer<typeof WriteInfo>;
|
|
||||||
export const WriteInfo = type({
|
|
||||||
account: PublicKeyFromString,
|
|
||||||
authority: PublicKeyFromString,
|
|
||||||
bytes: string(),
|
|
||||||
offset: number(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type InitializeBufferInfo = Infer<typeof InitializeBufferInfo>;
|
export type InitializeBufferInfo = Infer<typeof InitializeBufferInfo>;
|
||||||
export const InitializeBufferInfo = type({
|
export const InitializeBufferInfo = type({
|
||||||
account: PublicKeyFromString,
|
account: PublicKeyFromString,
|
||||||
authority: PublicKeyFromString,
|
authority: PublicKeyFromString,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type WriteInfo = Infer<typeof WriteInfo>;
|
||||||
|
export const WriteInfo = type({
|
||||||
|
offset: number(),
|
||||||
|
bytes: string(),
|
||||||
|
account: PublicKeyFromString,
|
||||||
|
authority: PublicKeyFromString,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type DeployWithMaxDataLenInfo = Infer<typeof DeployWithMaxDataLenInfo>;
|
||||||
|
export const DeployWithMaxDataLenInfo = type({
|
||||||
|
maxDataLen: number(),
|
||||||
|
payerAccount: PublicKeyFromString,
|
||||||
|
programDataAccount: PublicKeyFromString,
|
||||||
|
programAccount: PublicKeyFromString,
|
||||||
|
bufferAccount: PublicKeyFromString,
|
||||||
|
rentSysvar: PublicKeyFromString,
|
||||||
|
clockSysvar: PublicKeyFromString,
|
||||||
|
systemProgram: PublicKeyFromString,
|
||||||
|
authority: PublicKeyFromString,
|
||||||
|
});
|
||||||
|
|
||||||
export type UpgradeInfo = Infer<typeof UpgradeInfo>;
|
export type UpgradeInfo = Infer<typeof UpgradeInfo>;
|
||||||
export const UpgradeInfo = type({
|
export const UpgradeInfo = type({
|
||||||
programDataAccount: PublicKeyFromString,
|
programDataAccount: PublicKeyFromString,
|
||||||
programAccount: PublicKeyFromString,
|
programAccount: PublicKeyFromString,
|
||||||
bufferAccount: PublicKeyFromString,
|
bufferAccount: PublicKeyFromString,
|
||||||
spillAccount: PublicKeyFromString,
|
spillAccount: PublicKeyFromString,
|
||||||
authority: PublicKeyFromString,
|
|
||||||
rentSysvar: PublicKeyFromString,
|
rentSysvar: PublicKeyFromString,
|
||||||
clockSysvar: PublicKeyFromString,
|
clockSysvar: PublicKeyFromString,
|
||||||
|
authority: PublicKeyFromString,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type SetAuthorityInfo = Infer<typeof SetAuthorityInfo>;
|
export type SetAuthorityInfo = Infer<typeof SetAuthorityInfo>;
|
||||||
export const SetAuthorityInfo = type({
|
export const SetAuthorityInfo = type({
|
||||||
account: PublicKeyFromString,
|
account: PublicKeyFromString,
|
||||||
authority: PublicKeyFromString,
|
authority: PublicKeyFromString,
|
||||||
newAuthority: nullable(PublicKeyFromString),
|
newAuthority: optional(PublicKeyFromString),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type DeployWithMaxDataLenInfo = Infer<typeof DeployWithMaxDataLenInfo>;
|
export type CloseInfo = Infer<typeof CloseInfo>;
|
||||||
export const DeployWithMaxDataLenInfo = type({
|
export const CloseInfo = type({
|
||||||
|
account: PublicKeyFromString,
|
||||||
|
recipient: PublicKeyFromString,
|
||||||
|
authority: PublicKeyFromString,
|
||||||
|
programAccount: optional(PublicKeyFromString),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ExtendProgramInfo = Infer<typeof ExtendProgramInfo>;
|
||||||
|
export const ExtendProgramInfo = type({
|
||||||
|
additionalBytes: number(),
|
||||||
programDataAccount: PublicKeyFromString,
|
programDataAccount: PublicKeyFromString,
|
||||||
programAccount: PublicKeyFromString,
|
programAccount: PublicKeyFromString,
|
||||||
payerAccount: PublicKeyFromString,
|
systemProgram: optional(PublicKeyFromString),
|
||||||
bufferAccount: PublicKeyFromString,
|
payerAccount: optional(PublicKeyFromString),
|
||||||
authority: PublicKeyFromString,
|
|
||||||
rentSysvar: PublicKeyFromString,
|
|
||||||
clockSysvar: PublicKeyFromString,
|
|
||||||
systemProgram: PublicKeyFromString,
|
|
||||||
maxDataLen: number(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UpgradeableBpfLoaderInstructionType = Infer<
|
export type UpgradeableBpfLoaderInstructionType = Infer<
|
||||||
|
@ -53,8 +70,10 @@ export type UpgradeableBpfLoaderInstructionType = Infer<
|
||||||
>;
|
>;
|
||||||
export const UpgradeableBpfLoaderInstructionType = enums([
|
export const UpgradeableBpfLoaderInstructionType = enums([
|
||||||
"initializeBuffer",
|
"initializeBuffer",
|
||||||
"deployWithMaxDataLen",
|
|
||||||
"setAuthority",
|
|
||||||
"write",
|
"write",
|
||||||
"finalize",
|
"deployWithMaxDataLen",
|
||||||
|
"upgrade",
|
||||||
|
"setAuthority",
|
||||||
|
"close",
|
||||||
|
"extendProgram",
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue