anchor 显示错误“在当前范围内没有为 struct `anchor_spl::token::TokenAccount` 找到名为 `__anchor_private_gen_idl_type` 的关联项”

问题描述 投票:0回答:1

我运行我的代码,它显示,看起来我需要介绍一下

pub token_program: Program<'info, Token>,
但我做到了,您可以从下面的代码中获取更多信息


error[E0599]: no associated item named `__anchor_private_insert_idl_defined` found for struct `anchor_spl::token::Mint` in the current scope
   --> programs/sol404/src/instructions/createmint.rs:153:10
    |
153 | #[derive(Accounts)]
    |          ^^^^^^^^ associated item not found in `Mint`
    |
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)


error[E0599]: no associated item named `__anchor_private_insert_idl_defined` found for struct `anchor_spl::token::TokenAccount` in the current scope
   --> programs/sol404/src/instructions/createmint.rs:153:10
    |
153 | #[derive(Accounts)]
    |          ^^^^^^^^ associated item not found in `TokenAccount`
    |
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)


这是我的代码,我尝试创建一个铸币厂和一个 ATA 帐户,并且我使用了

#[derive(Accounts)]
pub struct CreateMint<'info> {
    // Use ADMIN_PUBKEY as constraint, only the specified admin can invoke this instruction
    #[account(
        mut,
        address = ADMIN_PUBKEY
    )]
    pub admin: Signer<'info>,

    // The PDA is both the address of the mint account and the mint authority
    #[account(
        init,
        seeds = [b"jelly"],
        bump,
        payer = admin,
        mint::decimals = 9,
        mint::authority = jelly_token_mint,
    )]
    pub jelly_token_mint: Account<'info, Mint>,
    
    ///CHECK: Using "address" constraint to validate metadata account address, this account is created via CPI in the instruction
    #[account(
        mut,
        address = MetadataAccount::find_pda(&jelly_token_mint.key()).0,
    )]
    pub jelly_metadata_account: UncheckedAccount<'info>,


    #[account(
        init,
        payer = admin,
        associated_token::mint = jelly_token_mint,
        associated_token::authority = admin,
    )]
    pub jelly_token_account: Account<'info, TokenAccount>,


    pub associated_token_program: Program<'info, AssociatedToken>,
    pub token_program: Program<'info, Token>,
    pub token_metadata_program: Program<'info, Metadata>,
    pub system_program: Program<'info, System>,
    pub rent: Sysvar<'info, Rent>,
}

这是我的

cargo.toml
,我不确定是否是版本问题

[package]
name = "sol404"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "sol404"

[features]
default = []
cpi = ["no-entrypoint"]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
idl-build = ["anchor-lang/idl-build"]

[dependencies]
anchor-lang = {version = "0.29.0", features = ["init-if-needed"]}
anchor-spl = {version = "0.29.0", features = ["metadata"]}
mpl-token-metadata = "4.1.2"
solana-program = "1.18.11"

我无法从google和GPT获得任何有用的信息,有人可以帮助我吗?

anchor solana anchor-solana solana-cli
1个回答
0
投票

请尝试将

"anchor-spl/idl-build"
添加到
idl-build

idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]

© www.soinside.com 2019 - 2024. All rights reserved.