-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17d04bd
commit 9b60c47
Showing
173 changed files
with
51,508 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# Kitties Tutorial | ||
|
||
Welcome to the new Substrate Collectables Workshop. | ||
|
||
TODO: Content. | ||
- Blockchain | ||
- Runtime | ||
- Pallet | ||
- NFTs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Kitties Tutorial | ||
# FRAME Macros | ||
|
||
- TODO: Teach the basics of FRAME macros. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Solution | ||
|
||
Here you will find the solution for the previous step. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
diff --git a/src/lib.rs b/src/lib.rs | ||
index 3b445c2..446ce3c 100644 | ||
--- a/src/lib.rs | ||
+++ b/src/lib.rs | ||
@@ -22,8 +22,7 @@ pub mod pallet { | ||
|
||
/// Learn about storage value. | ||
#[pallet::storage] | ||
- /* TODO: Update this storage to use a `QueryKind` of `ValueQuery`. */ | ||
- pub(super) type CountForKitties<T: Config> = StorageValue<Value = u64>; | ||
+ pub(super) type CountForKitties<T: Config> = StorageValue<Value = u64, QueryKind = ValueQuery>; | ||
|
||
// Learn about events. | ||
#[pallet::event] | ||
@@ -52,11 +51,9 @@ pub mod pallet { | ||
impl<T: Config> Pallet<T> { | ||
// Learn about `AccountId`. | ||
fn mint(owner: T::AccountId) -> DispatchResult { | ||
- /* TODO: Remove the `unwrap_or` which is not needed when using `ValueQuery`. */ | ||
- let current_count: u64 = CountForKitties::<T>::get().unwrap_or(0); | ||
+ let current_count: u64 = CountForKitties::<T>::get(); | ||
let new_count = current_count.checked_add(1).ok_or(Error::<T>::TooManyKitties)?; | ||
- /* TODO: Remove the `Option` wrapper when setting the `new_count`. */ | ||
- CountForKitties::<T>::set(Some(new_count)); | ||
+ CountForKitties::<T>::set(new_count); | ||
Self::deposit_event(Event::<T>::Created { owner }); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Value Query | ||
|
||
- TODO: | ||
- Explain storage as an option | ||
- Explain `OptionQuery` and `ValueQuery` | ||
- Explain default value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
diff --git a/src/lib.rs b/src/lib.rs | ||
index 2ed0e74..3b445c2 100644 | ||
--- a/src/lib.rs | ||
+++ b/src/lib.rs | ||
@@ -22,6 +22,7 @@ pub mod pallet { | ||
|
||
/// Learn about storage value. | ||
#[pallet::storage] | ||
+ /* TODO: Update this storage to use a `QueryKind` of `ValueQuery`. */ | ||
pub(super) type CountForKitties<T: Config> = StorageValue<Value = u64>; | ||
|
||
// Learn about events. | ||
@@ -51,8 +52,10 @@ pub mod pallet { | ||
impl<T: Config> Pallet<T> { | ||
// Learn about `AccountId`. | ||
fn mint(owner: T::AccountId) -> DispatchResult { | ||
+ /* TODO: Remove the `unwrap_or` which is not needed when using `ValueQuery`. */ | ||
let current_count: u64 = CountForKitties::<T>::get().unwrap_or(0); | ||
let new_count = current_count.checked_add(1).ok_or(Error::<T>::TooManyKitties)?; | ||
+ /* TODO: Remove the `Option` wrapper when setting the `new_count`. */ | ||
CountForKitties::<T>::set(Some(new_count)); | ||
Self::deposit_event(Event::<T>::Created { owner }); | ||
Ok(()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.