Skip to content

Anchor v2 defined arg struct requires IdlAccountType impl #4850

Description

@rute-sophie

I'm trying out anchor-v2 and came up with an issue when creating custom argument structs.

I followed the example here and derived #[derive(Clone, Copy, wincode::SchemaRead, wincode::SchemaWrite)].

Compilation fails with

error[E0277]: Ensure that `instructions::my_instr::MyInstrArgs` has an `#[account]` attribute
  --> programs/my-program/src/lib.rs:18:15
   |
18 |         args: MyInstrArgs
   |               ^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `IdlAccountType` is not implemented for `instructions::my_instr::MyInstrArgs`

Was able to find two workarounds, both are very duck-tapey and not the desired solution:
1- Deriving #[account] - this one is odd and requires padding to the structure. Also not an account.
2- anchor build --no-idl - this is problematic as it skips idl generation.

Seems to be an issue with IDL generation for anchor v2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions