0

I am working on a Rust project where I have multiple modules. I'm facing an issue with unresolved imports when I try to compile my code. Here's the relevant code structure:

types.rs

pub mod Types {

    pub use crate::pallet::Config;
    use crate::structs::NFTStructs::{Collection, ShareProfitsInfo, NFT};
    use frame_support::traits::Currency;
    use frame_system::Config as SystemConfig;

    pub type BalanceOf<T> =
        <<T as Config>::NFTCurrency as Currency<<T as SystemConfig>::AccountId>>::Balance;

    pub type HashId<T> = <T as frame_system::Config>::Hash;

    pub type CollectionDetailsOf<T> = Collection<<T as SystemConfig>::AccountId, HashId<T>>;

    pub type SahreProfitDetailsOf<T> = ShareProfitsInfo<<T as SystemConfig>::AccountId>;

    pub type NFTDetailsOf<T> = NFT<<T as SystemConfig>::AccountId, BalanceOf<T>>;

    pub type AccountOf<T> = <T as SystemConfig>::AccountId;
}

lib.rs

#![cfg_attr(not(feature = "std"), no_std)]

use codec::{alloc::vec, Decode, Encode, HasCompact, MaxEncodedLen};
use frame_support::sp_runtime::{
    traits::{AtLeast32BitUnsigned, CheckedAdd, Hash, Member, One},
    DispatchError, SaturatedConversion,
};

use frame_support::{
    inherent::Vec,
    pallet_prelude::{ValueQuery, *},
    traits::{Currency, ExistenceRequirement, Get, ReservableCurrency},
    transactional, Twox64Concat,
};

pub use pallet::*;

pub mod structs;
pub use structs::NFTStructs::{Collection, Owners, NFT};

pub mod types;
pub use types::Types::{
    AccountOf, BalanceOf, CollectionDetailsOf, HashId, NFTDetailsOf, SahreProfitDetailsOf,
};


#[cfg(test)]
mod mock;

#[cfg(test)]
mod tests;

pub mod weights;
pub use weights::*;

#[frame_support::pallet]
pub mod pallet {

    use super::*;
    use frame_system::pallet_prelude::*;

    #[pallet::pallet]
    pub struct Pallet<T>(_);

    /// Configure the pallet by specifying the parameters and types on which it depends.
    #[pallet::config]
    pub trait Config: frame_system::Config {
        /// Because this pallet emits events, it depends on the runtime's definition of an event.
        type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
        /// Type representing the weight of this pallet
        type NFTPalletWeightInfo: WeightInfo;
        /// The currency mechanism, used for paying for reserves.
        type NFTCurrency: ReservableCurrency<Self::AccountId>;

        type NFTGallery: MarketPalceHelper<
            MarketHash = Self::Hash,
            UserAccountId = Self::AccountId,
            Balance = BalanceOf<Self>,
        >;
    }

}

but when i excute command cargo check it show me these errors :

error[E0432]: unresolved imports crate::pallet, crate::types::Types::Config, crate::AccountOf --> frame/new-nft/src/types.rs:2:17 | 2 | pub use crate::pallet::Config; // Import Config from the pallet module | ^^^^^^ | | | unresolved import | help: a similar path exists: frame_system::pallet

error[E0432]: unresolved import pallet --> frame/new-nft/src/lib.rs:17:9 | 17 | pub use pallet::*; | ^^^^^^ help: a similar path exists: utility::pallet

Utiles :

pub mod Utility {
    use crate::{
        types::Types::{BalanceOf, Config, SahreProfitDetailsOf},
        AccountOf,
    };
    use frame_support::{
        dispatch::DispatchError,
        inherent::Vec,
        sp_runtime::traits::SaturatedConversion,
        traits::{Currency, ExistenceRequirement},
    };
    use sp_runtime::traits::UniqueSaturatedFrom;

structs :

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{traits::ConstU32, BoundedVec};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use frame_support::inherent::Vec;

pub mod NFTStructs {
    use super::*;

Whats the Problem ? how can i solve the problem ?

1
  • I don't think this is the actual error. There were some issues with the #[pallet] and as a result, the pallet was not generated. Can you please provide the link to your code?
    – AurevoirXavier
    Sep 13, 2023 at 9:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.