Error Report
Issue: I am encountering compilation errors when trying to compile my Rust project. The errors are related to unresolved imports and unknown fields in my code.
Error Messages:
error[E0432]: unresolved import `mpl_token_metadata`
--> programs/context/src/context.rs:4:5
|
4 | use mpl_token_metadata::ID as MetadataProgramId;
| ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `mpl_token_metadata`
error[E0432]: unresolved import `mpl_token_metadata`
--> programs/context/src/lib.rs:8:5
|
8 | use mpl_token_metadata::instruction as mpl_instruction;
| ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `mpl_token_metadata`
warning: unused import: `self`
--> programs/context/src/context.rs:2:25
|
2 | use anchor_spl::token::{self, Token, TokenAccount, Mint};
| ^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `Metadata`
--> programs/context/src/lib.rs:6:28
|
6 | use anchor_spl::metadata::{Metadata, MetadataAccount};
| ^^^^^^^^
warning: unused import: `Token`
--> programs/context/src/lib.rs:7:31
|
7 | use anchor_spl::token::{self, Token, Transfer};
| ^^^^^
error[E0609]: no field `token_metadata_program` on type `&mut ImportCollection<'_>`
--> programs/context/src/lib.rs:45:26
|
45 | ctx.accounts.token_metadata_program.key(),
| ^^^^^^^^^^^^^^^^^^^^^^ unknown field
|
= note: available fields are: `collection`, `authority`, `metadata`, `system_program`, `marketplace_authority`
error[E0609]: no field `token_metadata_program` on type `&mut ImportCollection<'_>`
--> programs/context/src/lib.rs:58:30
|
58 | ctx.accounts.token_metadata_program.to_account_info(),
| ^^^^^^^^^^^^^^^^^^^^^^ unknown field
|
= note: available fields are: `collection`, `authority`, `metadata`, `system_program`, `marketplace_authority`
Some errors have detailed explanations: E0432, E0609.
For more information about an error, try `rustc --explain E0432`.
warning: `context` (lib) generated 3 warnings
error: could not compile `context` (lib) due to 4 previous errors; 3 warnings emitted
Code Context: Here are the relevant parts of my code: Cargo.toml:
[package]
name = "context"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"
[lib]
crate-type = ["cdylib", "lib"]
name = "context"
[features]
no-entrypoint = []
idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
cpi = ["no-entrypoint"]
default = []
[dependencies]
anchor-lang = "0.29.0"
anchor-spl = { version = "0.29.0", features = ["metadata"] }
context.rs:
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Token, TokenAccount, Mint};
use crate::state::*;
use mpl_token_metadata::ID as MetadataProgramId;
lib.rs:
use anchor_lang::prelude::*;
use anchor_spl::metadata::{Metadata, MetadataAccount};
use anchor_spl::token::{self, Token, Transfer};
use mpl_token_metadata::instruction as mpl_instruction;
Expected Behavior: The project should compile without any unresolved import errors or unknown field errors.