8000 IDL doesn't support `PhantomData` · Issue #3241 · solana-foundation/anchor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
IDL doesn't support PhantomData #3241
Open
@cryptopapi997

Description

@cryptopapi997

If we define an account like so

use std::marker::PhantomData;

use anchor_lang::prelude::*;

declare_id!("B8v9C4JA5CqMWcoKYfA2hQSEytFxPVk1iWeEjXQxCvS3");

#[program]
pub mod sample {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        msg!("Greetings from: {:?}", ctx.program_id);
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    pub data_obj_acc: Account<'info, MyAcc<MyStruct>>,
}

#[account]
pub struct MyAcc<T> {
    _p: PhantomData<T>,
}

#[derive(AnchorDeserialize, AnchorSerialize, Clone)]
pub struct MyStruct {}

it compiles fine if we compile with anchor build --no-idl. If we try to build the idl however, we get a bunch of errors (I'm guessing because the idl tries to include PhantomData in the idl itself but it isn't serializable). I'm not sure if this is intentional or not, but if it isn't it would be nice to support PhantomData.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureidlrelated to the IDL, either program or client side

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0