diff --git a/ts/src/idl.ts b/ts/src/idl.ts index 7587c1a48..3fe002bd8 100644 --- a/ts/src/idl.ts +++ b/ts/src/idl.ts @@ -7,7 +7,7 @@ export type Idl = { name: string; instructions: IdlInstruction[]; state?: IdlState; - accounts?: IdlTypeDef[]; + accounts?: IdlAccountDef[]; types?: IdlTypeDef[]; events?: IdlEvent[]; errors?: IdlErrorCode[]; @@ -79,6 +79,11 @@ export type IdlTypeDef = { type: IdlTypeDefTy; }; +export type IdlAccountDef = { + name: string; + type: IdlTypeDefTyStruct; +}; + export type IdlTypeDefTyStruct = { kind: "struct"; fields: IdlTypeDefStruct; diff --git a/ts/src/program/namespace/account.ts b/ts/src/program/namespace/account.ts index 3793cfc6c..5563900c5 100644 --- a/ts/src/program/namespace/account.ts +++ b/ts/src/program/namespace/account.ts @@ -10,7 +10,7 @@ import { AccountInfo, } from "@solana/web3.js"; import Provider, { getProvider } from "../../provider.js"; -import { Idl, IdlTypeDef } from "../../idl.js"; +import { Idl, IdlAccountDef } from "../../idl.js"; import { Coder, BorshCoder } from "../../coder/index.js"; import { Subscription, Address, translateAddress } from "../common.js"; import { AllAccountsMap, IdlTypes, TypeDef } from "./types.js"; @@ -42,7 +42,7 @@ export default class AccountFactory { } type NullableIdlAccount = IDL["accounts"] extends undefined - ? IdlTypeDef + ? IdlAccountDef : NonNullable[number]; /** @@ -72,7 +72,7 @@ export type AccountNamespace = { export class AccountClient< IDL extends Idl = Idl, A extends NullableIdlAccount = IDL["accounts"] extends undefined - ? IdlTypeDef + ? IdlAccountDef : NonNullable[number], T = TypeDef> > {