From 0a64dab69659532dc8f70f55fdaab1eacb3bc21b Mon Sep 17 00:00:00 2001 From: Aryan Malik Date: Sat, 19 Oct 2024 10:46:11 +0530 Subject: [PATCH 1/2] Added Clone Trait This removes the errors one might get due to the unavailability of the `Clone` trait. --- .../en/Section_3/Lesson_3_Make_Balances_Pallet_Generic.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Rust_State_Machine/en/Section_3/Lesson_3_Make_Balances_Pallet_Generic.md b/Rust_State_Machine/en/Section_3/Lesson_3_Make_Balances_Pallet_Generic.md index efa66fcb5..d88f209ef 100644 --- a/Rust_State_Machine/en/Section_3/Lesson_3_Make_Balances_Pallet_Generic.md +++ b/Rust_State_Machine/en/Section_3/Lesson_3_Make_Balances_Pallet_Generic.md @@ -59,7 +59,7 @@ That will look like: ```rust impl Pallet where - AccountId: Ord, + AccountId: Ord + Clone, Balance: Zero + CheckedSub + CheckedAdd + Copy, { // functions which use these types and have access to the traits specified @@ -133,7 +133,7 @@ pub struct Pallet { /* TODO: The generic types need to satisfy certain traits in order to be used in the functions below. - - AccountId: Ord + - AccountId: Ord + Clone - Balance: Zero + CheckedSub + CheckedAdd + Copy You could figure these traits out yourself by letting the compiler tell you what you're missing. @@ -195,4 +195,4 @@ pub struct Runtime { Making the Balances Pallet generic is a crucial skill for creating flexible and scalable blockchain solutions. Great work on completing this lesson! 🌟 -Post a screenshot in [#progress](https://discord.com/channels/898706705779687435/980906289968345128) showing your runtime with the new generic Balances Pallet in action. It better not still be using &'static str! \ No newline at end of file +Post a screenshot in [#progress](https://discord.com/channels/898706705779687435/980906289968345128) showing your runtime with the new generic Balances Pallet in action. It better not still be using &'static str! From 5e230fa631c496bb16a167522c2af01253f89358 Mon Sep 17 00:00:00 2001 From: Aryan Malik Date: Sat, 19 Oct 2024 13:03:27 +0530 Subject: [PATCH 2/2] Fix: Added `Clone` Trait and some grammatical fixes --- .../en/Section_3/Lesson_5_Make_System_Configurable.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rust_State_Machine/en/Section_3/Lesson_5_Make_System_Configurable.md b/Rust_State_Machine/en/Section_3/Lesson_5_Make_System_Configurable.md index e68be2557..d44da9013 100644 --- a/Rust_State_Machine/en/Section_3/Lesson_5_Make_System_Configurable.md +++ b/Rust_State_Machine/en/Section_3/Lesson_5_Make_System_Configurable.md @@ -29,7 +29,7 @@ The more obvious use of traits is to define custom functions Let's say we want to expose a function which returns the name of something. -You could a trait `GetName`: +You could define a trait `GetName`: ```rust pub trait GetName { @@ -82,7 +82,7 @@ For this we will use a trait with a bunch of associated types: ```rust pub trait Config { - type AccountId: Ord; + type AccountId: Ord + Clone; type BlockNumber: Zero + One + AddAssign + Copy; type Nonce: Zero + One + Copy; // and more if needed @@ -159,7 +159,7 @@ Let's practice all you have learned to create `Config` trait for your System Pal 6. Go to your `main.rs` file, and implement `system::Config` for the `Runtime` struct. 7. Update your `Runtime` definition to instantiate `system::Pallet` with `Self`. -Again, this is a big step for new Rust developers, and a common place that people can get very confused. +Again, this is a big step for new Rust developers, and a commonplace where people can get very confused. You will have the opportunity to do this whole process again for the Balances Pallet, so don't be afraid to peek at the solution this time around if you cannot get your code working. @@ -233,4 +233,4 @@ mod test { ``` If you have any questions or need further assistance with implementing custom traits or configuring your System, feel free to reach out for support in the [#πŸ†˜γƒ»section-3](https://discord.com/channels/898706705779687435/980905695689998366) channel on Discord. -We're here to support you! 🌟 \ No newline at end of file +We're here to support you! 🌟