Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Discriminator trait of CoreAsset and CoreCollection for Anchor 0.30.0 #151

Open
alphafitz11 opened this issue Jun 25, 2024 · 1 comment

Comments

@alphafitz11
Copy link

Anchor 0.30.0 require CoreAsset and CoreCollection to implement the Discriminator trait to build IDL.
When using anchor 0.30.0, compiling IDL will encounter the following errors:

error[E0599]: no function or associated item named `create_type` found for struct `mpl_core::CoreAsset` in the current scope
  --> programs/solana-marketplace/src/ins/mpl/mpl_core/core_sell_nft.rs:20:10
   |
20 | #[derive(Accounts)]
   |          ^^^^^^^^ function or associated item not found in `CoreAsset`
   |
  ::: programs/solana-marketplace/src/ins/mpl/mpl_core/mod.rs:20:1
   |
20 | pub struct CoreAsset(mpl_core::accounts::BaseAssetV1);
   | -------------------- function or associated item `create_type` not found for this struct
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `create_type`, perhaps you need to implement it:
           candidate #1: `anchor_lang::IdlBuild`
   = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `mpl_core::CoreAsset: Discriminator` is not satisfied
  --> programs/solana-marketplace/src/ins/mpl/mpl_core/core_sell_nft.rs:56:40
   |
56 |     pub core_asset: Box<Account<'info, CoreAsset>>,
   |                                        ^^^^^^^^^ the trait `Discriminator` is not implemented for `mpl_core::CoreAsset`
   |
   = help: the following other types implement trait `Discriminator`:
             BuyCnft
             CancelBuyCnft
             CancelCollectionBuyCnft
             CancelSellCnft
             CollectionBuyCnft
             ExecuteBuyCnft
             ExecuteCollectionBuyCnft
             ExecuteSellCnft
           and 49 others
@blockiosaurus
Copy link
Contributor

Hey @alphafitz11, thanks for calling this out. Right now Core isn't supported as an explicit account in the Accounts structure. This is because of the way it's composed of a set of base data and a collection of plugins, with most users only needing to read a subset. However integrating this into the Anchor Accounts is something we're actively working on. Right now the recommended way to work with Core in Anchor is to treat it as an UncheckedAccount and deserialize it within the instruction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants