metaplex-foundation / solita

Genrates an SDK API from solana contract IDL.
Apache License 2.0
138 stars 31 forks source link

Parse context account into instruction accounts #58

Open zhmoly opened 2 years ago

zhmoly commented 2 years ago

Hi, there I'm using solita as useful framework. By the way, I found some issue.

I'm using anchor and includes context into instruction.

#[derive(Accounts)]
pub struct SetSubModule<'info> {
    module_ctx: SetModule<'info>,

    #[account(mut)]
    pub signer: UncheckedAccount<'info>,
}

But when I try with Solita, get error.

Generating TypeScript SDK to /home/john/Documents/personal/unloc-contracts/client-generated/src/generated
/home/john/Documents/personal/unloc-contracts/client-generated/node_modules/@metaplex-foundation/solita/dist/src/render-instruction.js:92
      isWritable: ${isMut.toString()},
                          ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /home/john/Documents/personal/unloc-contracts/client-generated/node_modules/@metaplex-foundation/solita/dist/src/render-instruction.js:92:27

Is there any way to resolve this error? Any help will be appreciated.

Regards, John

thlorenz commented 2 years ago

Sorry it is really hart to parse what you're requesting.

Could you please properly format the code blocks as well as the error messages using github markdown features? See here.

Thanks

roberts-pumpurs commented 2 years ago

If I understood correctly, the issue that he's facing right now is that for some reason Solita is unable to parse the module_ctx: SetModule<'info> structure.

I am facing a similar issue, where I have a structure identified with #[derive(Accounts)], it has a field which is also attributed as #[derive(Accounts)]. Because of this field, Solita fails exactly as described in the original post.

thlorenz commented 2 years ago

OK I think I understand a bit better now. Could you please provide the IDL that solita is operating on when encountering those errors? And I assume that IDL is generated with anchor?

thlorenz commented 1 year ago

Hi, I cannot help you unless you provide some Rust code that reproduces the problem or the IDL that shank produced.

My guess is that shank trips on the life time 'info and fails to even generate the IDL, but without some sample code I'm left guessing.