Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'bank' does not exist on type 'AccountNamespace<Idl>'. #3476

Closed
cxp-13 opened this issue Jan 10, 2025 · 1 comment
Closed

Property 'bank' does not exist on type 'AccountNamespace<Idl>'. #3476

cxp-13 opened this issue Jan 10, 2025 · 1 comment
Labels

Comments

@cxp-13
Copy link

cxp-13 commented Jan 10, 2025

When I try to apply the anchor client to the Eliza framework project and test its fetch function,

let program = new anchor.Program(idl as anchor.Idl, anchorProvider);

    // bank
    const bankInfos = await program.account.bank.fetchMultiple([
      rayTokenBank,
      wifTokenBank,
    ]);

It works during the test process but has problems when building.

packages/plugin-solana/src/tests/anchor.test.ts:32:45 - error TS2339: Property 'bank' does not exist on type 'AccountNamespace<Idl>'.

32     const bankInfos = await program.account.bank.fetchMultiple([
                                               ~~~~
@acheroncrypto
Copy link
Collaborator

It's because of the casting of the idl variable to anchor.Idl. The correct way is to cast it to the IDL type generated by Anchor in target/types, which will give you a full type support for your program.

Also FYI, this will be simplified in v0.31 (see Simpler Program construction).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants