Skip to content

Commit 40be4be

Browse files
committed
feat: add solution for ex08
1 parent 94c42ac commit 40be4be

File tree

1 file changed

+18
-4
lines changed
  • exercises/ex08-genesis-config/nft-with-genesis-config/src

1 file changed

+18
-4
lines changed

exercises/ex08-genesis-config/nft-with-genesis-config/src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,24 @@ pub mod pallet {
4949
#[pallet::genesis_build]
5050
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
5151
fn build(&self) {
52-
// TODO
53-
// iterate over the `GenesisAssetList` and:
54-
// 1) mint each asset
55-
// 2) transfer the correct amount of this asset to each account in the inner vec
52+
for (creator, metadata, supply, owners) in self.genesis_asset_list.iter() {
53+
let bounded_metadata: BoundedVec<u8, T::MaxLength> =
54+
metadata.clone().try_into().unwrap();
55+
56+
Pallet::<T>::inner_mint(creator.clone(), bounded_metadata, supply.clone()).unwrap();
57+
58+
let created_asset_id = Pallet::<T>::nonce() - 1;
59+
60+
for (recipient, amount) in (*owners).iter() {
61+
Pallet::<T>::inner_transfer(
62+
created_asset_id,
63+
creator.clone(),
64+
recipient.clone(),
65+
amount.clone(),
66+
)
67+
.unwrap();
68+
}
69+
}
5670
}
5771
}
5872

0 commit comments

Comments
 (0)