fix: support uninitialized upgradeable program account in AccountSection (#19268)
This commit is contained in:
@ -13,6 +13,7 @@ import { Slot } from "components/common/Slot";
|
|||||||
import { addressLabel } from "utils/tx";
|
import { addressLabel } from "utils/tx";
|
||||||
import { useCluster } from "providers/cluster";
|
import { useCluster } from "providers/cluster";
|
||||||
import { ErrorCard } from "components/common/ErrorCard";
|
import { ErrorCard } from "components/common/ErrorCard";
|
||||||
|
import { UnknownAccountCard } from "components/account/UnknownAccountCard";
|
||||||
|
|
||||||
export function UpgradeableLoaderAccountSection({
|
export function UpgradeableLoaderAccountSection({
|
||||||
account,
|
account,
|
||||||
@ -52,6 +53,9 @@ export function UpgradeableLoaderAccountSection({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
case "uninitialized": {
|
||||||
|
return <UnknownAccountCard account={account} />;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
union,
|
union,
|
||||||
coerce,
|
coerce,
|
||||||
create,
|
create,
|
||||||
|
any,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { ParsedInfo } from "validators";
|
import { ParsedInfo } from "validators";
|
||||||
import { PublicKeyFromString } from "validators/pubkey";
|
import { PublicKeyFromString } from "validators/pubkey";
|
||||||
@ -49,9 +50,27 @@ export const ProgramBufferAccount = type({
|
|||||||
info: ProgramBufferAccountInfo,
|
info: ProgramBufferAccountInfo,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type ProgramUninitializedAccountInfo = Infer<
|
||||||
|
typeof ProgramUninitializedAccountInfo
|
||||||
|
>;
|
||||||
|
export const ProgramUninitializedAccountInfo = any();
|
||||||
|
|
||||||
|
export type ProgramUninitializedAccount = Infer<
|
||||||
|
typeof ProgramUninitializedAccount
|
||||||
|
>;
|
||||||
|
export const ProgramUninitializedAccount = type({
|
||||||
|
type: literal("uninitialized"),
|
||||||
|
info: ProgramUninitializedAccountInfo,
|
||||||
|
});
|
||||||
|
|
||||||
export type UpgradeableLoaderAccount = Infer<typeof UpgradeableLoaderAccount>;
|
export type UpgradeableLoaderAccount = Infer<typeof UpgradeableLoaderAccount>;
|
||||||
export const UpgradeableLoaderAccount = coerce(
|
export const UpgradeableLoaderAccount = coerce(
|
||||||
union([ProgramAccount, ProgramDataAccount, ProgramBufferAccount]),
|
union([
|
||||||
|
ProgramAccount,
|
||||||
|
ProgramDataAccount,
|
||||||
|
ProgramBufferAccount,
|
||||||
|
ProgramUninitializedAccount,
|
||||||
|
]),
|
||||||
ParsedInfo,
|
ParsedInfo,
|
||||||
(value) => {
|
(value) => {
|
||||||
// Coercions like `PublicKeyFromString` are not applied within
|
// Coercions like `PublicKeyFromString` are not applied within
|
||||||
@ -75,6 +94,12 @@ export const UpgradeableLoaderAccount = coerce(
|
|||||||
info: create(value.info, ProgramBufferAccountInfo),
|
info: create(value.info, ProgramBufferAccountInfo),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case "uninitialized": {
|
||||||
|
return {
|
||||||
|
type: value.type,
|
||||||
|
info: create(value.info, ProgramUninitializedAccountInfo),
|
||||||
|
};
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(`Unknown program account type: ${value.type}`);
|
throw new Error(`Unknown program account type: ${value.type}`);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user