Skip to content

Commit

Permalink
feat: add solution for ex08
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro committed Mar 9, 2023
1 parent 190ebd2 commit c8f2e56
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions exercises/ex08-genesis-config/nft-with-genesis-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,24 @@ pub mod pallet {
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
// TODO
// iterate over the `GenesisAssetList` and:
// 1) mint each asset
// 2) transfer the correct amount of this asset to each account in the inner vec
for (creator, metadata, supply, owners) in self.genesis_asset_list.iter() {
let bounded_metadata: BoundedVec<u8, T::MaxLength> =
metadata.clone().try_into().unwrap();

Pallet::<T>::inner_mint(creator.clone(), bounded_metadata, supply.clone()).unwrap();

let created_asset_id = Pallet::<T>::nonce() - 1;

for (recipient, amount) in (*owners).iter() {
Pallet::<T>::inner_transfer(
created_asset_id,
creator.clone(),
recipient.clone(),
amount.clone(),
)
.unwrap();
}
}
}
}

Expand Down

0 comments on commit c8f2e56

Please sign in to comment.