Recently, I am working on a toy project to learn Solana blockchain, Metaplex Core and NFTs. Everything went well until I try to use the feature called “Oracle plugin”, provided by Metaplex. I shortly explain what I want to do with it. According the document, I can use it to control the lifecycle of a NFT (built on Metaplex Core Asset). However, I encountered an error when building the project:
error[E0599]: no variant or associated item named `get_full_path` found for enum `OracleValidation` in the current scope
--> programs/life_helper/src/lib.rs:16:1
|
16 | #[account]
| ^^^^^^^^^^ variant or associated item not found in `OracleValidation`
|
= note: this error originates in the derive macro `AnchorSerialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: no variant or associated item named `create_type` found for enum `OracleValidation` in the current scope
--> programs/life_helper/src/lib.rs:16:1
|
16 | #[account]
| ^^^^^^^^^^ variant or associated item not found in `OracleValidation`
|
= note: this error originates in the derive macro `AnchorSerialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: no variant or associated item named `insert_types` found for enum `OracleValidation` in the current scope
--> programs/life_helper/src/lib.rs:16:1
|
16 | #[account]
| ^^^^^^^^^^ variant or associated item not found in `OracleValidation`
|
= note: this error originates in the derive macro `AnchorSerialize` (in Nightly builds, run with -Z macro-backtrace for more info)
The error code is here:
use anchor_lang::prelude::*;
use mpl_core::types::{OracleValidation, ExternalValidationResult};
////////////////////////////////////////////////////////////////////////////////
declare_id!("6qjMzebX6DBJMbrNPk2UejZSkF7i8H5Nc5gbQAgKw7ay");
////////////////////////////////////////////////////////////////////////////////
#[account]
pub struct Validation {
pub validation: OracleValidation,
pub transfer_limit: u16,
pub curr_transfer: u16,
}
impl Validation {
pub fn size() -> usize {
8 // anchor discriminator
+ 5 // validation
+ 2 // transfer_limit
+ 2 // curr_transfer
}
}
////////////////////////////////////////////////////////////////////////////////
#[derive(Accounts)]
pub struct Accounts4Init<'info> {
pub signer: Signer<'info>,
#[account(mut)]
pub payer: Signer<'info>,
#[account(init, payer = payer, space = Validation::size())]
pub oracle_account: Account<'info, Validation>,
pub system_program: Program<'info, System>,
}
#[derive(AnchorDeserialize, AnchorSerialize)]
pub struct Args4Init {
pub transfer_limit: u16,
}
////////////////////////////////////////////////////////////////////////////////
#[program]
pub mod life_helper {
use super::*;
pub fn initialize(ctx: Context<Accounts4Init>, args: Args4Init) -> Result<()> {
ctx.accounts.oracle_account.transfer_limit = args.transfer_limit;
ctx.accounts.oracle_account.curr_transfer = 0;
ctx.accounts.oracle_account.validation = OracleValidation::V1 {
create: ExternalValidationResult::Rejected,
transfer: ExternalValidationResult::Pass,
burn: ExternalValidationResult::Rejected,
update: ExternalValidationResult::Rejected,
};
Ok(())
}
}
My toy project repo: https://github.com/WangWilly/solana-poneglyph
I did a little research but end up with nothing about this issue. I also checked out if there are some questions talking about the similar errors.
Thank for any response! Marry coming up Christmas!
I traced the source codes to find out the actual expectation from the compiler. Furthermore, I also check this issue anchor shows errors “no associated item named `__anchor_private_gen_idl_type` found for struct `anchor_spl::token::TokenAccount` in the current scope”, but I thought it is irrelevant to my question.
What I expect is that maybe add derive
to the struct can solve the issue? Idk 🙁
1