substrate-docs icon indicating copy to clipboard operation
substrate-docs copied to clipboard

Update write-up for Kitties tutorial

Open sacha-l opened this issue 2 years ago • 4 comments

The Kitties write-up (from the published tutorial) needs updating based on the latest improved solution, also based on this workshop.

sacha-l avatar Mar 10 '22 12:03 sacha-l

Hi @sacha-l - I'm happy to help on ths.

srinivasnarula avatar Mar 11 '22 05:03 srinivasnarula

Hi @sacha-l - I'm new to substrate and I want to make sure that I follow this requirement clearly.

Here are the steps, I'm following.

  1. Running kitties to tutorial from the current article.
  2. In event of compilation issues, I'm referring to latest code from this link.
  3. All modified changes need to be updated in article by forking it.

Eg: In pallet_kitties scaffold, after using the default code and compiling, it is throwing use of undeclared crate or module sp_io`` as error.

image

So I referred the updated solution and moved sp-io from [dev-dependencies] to [dependencies]. This fixed the issue.

Please help me out, if my understanding it correct.

srinivasnarula avatar Mar 12 '22 08:03 srinivasnarula

Hi @sacha-l - I need a small help with below error. I tried in different ways to resolve this issue.

I'm getting this issue in both published article and your workshop article.

image

srinivasnarula avatar Mar 24 '22 22:03 srinivasnarula

I checked the similar issue was raised in Stack Overflow and I was able to get around this issue with below code.

Add a simple "hint" to the compiler in the form of #[codec(mel_bound())].

// Struct for holding Kitty information.
#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[scale_info(skip_type_params(T))]
#[codec(mel_bound())] // <---------------- Here
pub struct Kitty<T: Config> {
    pub dna: [u8; 16],   // Using 16 bytes to represent a kitty DNA
    pub price: Option<BalanceOf<T>>,
    pub gender: Gender,
    pub owner: AccountOf<T>,
}

Hope this helps someone :)

srinivasnarula avatar Mar 24 '22 22:03 srinivasnarula