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:*
```[dependencies]
anchor-lang = "0.29.0"
anchor-spl = { version = "0.29.0", features = ["metadata"] }
mpl-token-metadata = "0.1.0" # Ensure this dependency is added
context.rs:
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Token, TokenAccount, Mint};
use crate::state::*;
use mpl_token_metadata::ID as MetadataProgramId; // Error here
// Other code...```
*lib.rs:*
```use crate::{context::*, state::*};
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; // Error here
// Other code...```
**Expected Behavior:**
The project should compile without any unresolved import errors or unknown field errors.