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