3

I need to mint an NFT and create metaverse for our auction pallet benchmarking. Both of these are handled by external pallet functionality and wondered if there is a FRAME-base benchmarking solution for using external calls from this pallet. Here is a code example from the benchmarking of the auction pallet:

fn mint_NFT<T: Config>(caller: T::AccountId) {
    //T::NFTHandler::mint_land_nft(caller.clone().into(), vec![1], test_attributes(1));
    T::NFTHandler::create_token_class(
        &caller.clone(),
        vec![1],
        test_attributes(1),
        0u32.into(),
        TokenType::Transferable,
        CollectionType::Collectable,
        Perbill::from_percent(0u32),
    );

    T::NFTHandler::mint_token(&caller.clone(), 0u32.into(), vec![1], test_attributes(1));
    /*
        pallet_nft::Pallet::<T>::create_group(RawOrigin::Root.into(), vec![1], vec![1]);
        pallet_nft::Pallet::<T>::create_class(
            RawOrigin::Signed(caller.clone()).into(),
            vec![1],
            test_attributes(1),
            0u32.into(),
            TokenType::Transferable,
            CollectionType::Collectable,
            Perbill::from_percent(0u32),
        );
        pallet_nft::Pallet::<T>::mint(
            RawOrigin::Signed(caller.clone()).into(),
            0u32.into(),
            vec![1],
            test_attributes(1),
            3,
        );
    */
}

fn create_metaverse_for_account<T: Config>(caller: T::AccountId) {
    //pallet_metaverse::Pallet::<T>::create_metaverse(
    //  RawOrigin::Signed(caller.clone()).into(),
    //  vec![1u8],
    //);
}

The benchmarking builds successfully when using the code that is not commented but it does not seem to work when running it on the pallet. If I use the commented code instead, I get the following error

[E0599]: the function or associated item mint exists for struct pallet_nft::Pallet<T>, but its trait bounds were not satisfied

We found a possible solution using the orml benchmarking pallet but wondered if there is a way to fix the issue using FRAME?

2
  • Could you provide the source code of the pallet please? Where did you get the example code for the minting from? Apr 19, 2022 at 21:37
  • The example code is from the benchmarking of the auction pallet link to the full source code can be found here @oliver-tale-yazdi
    – chexware
    Apr 19, 2022 at 23:59

1 Answer 1

4

Your code assumes that the pallet you are benchmarking has a tight coupling with pallet_nft, however this is an assumption that you must satsify within the rust trait bounds.

The solution, as the compiler is hinting to you, is to explicitly define the tight coupling in your T generic:

T: Config + pallet_nft::Config

This change ensures that your runtime will have the pallet_nft in order to compile the benchmarking code.

The even better solution is to write a benchmark which does not assume that specifically pallet_nft is used, but instead the NFT trait like T::NFTHandler will expose the functions you are trying to call, keeping your benchmarks flexible beyond just a single specific pallet.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.