diff --git a/steps/30/src/tests.rs b/steps/30/src/tests.rs index aa3f699c..f60af86b 100644 --- a/steps/30/src/tests.rs +++ b/steps/30/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/31/src/tests.rs b/steps/31/src/tests.rs index aa3f699c..f60af86b 100644 --- a/steps/31/src/tests.rs +++ b/steps/31/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/32/src/tests.rs b/steps/32/src/tests.rs index cae6b527..a4bb7648 100644 --- a/steps/32/src/tests.rs +++ b/steps/32/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/33/src/tests.rs b/steps/33/src/tests.rs index cae6b527..a4bb7648 100644 --- a/steps/33/src/tests.rs +++ b/steps/33/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/34/src/tests.rs b/steps/34/src/tests.rs index d37fb7fb..f2fb1d01 100644 --- a/steps/34/src/tests.rs +++ b/steps/34/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/35/src/tests.rs b/steps/35/src/tests.rs index d37fb7fb..f2fb1d01 100644 --- a/steps/35/src/tests.rs +++ b/steps/35/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/36/src/tests.rs b/steps/36/src/tests.rs index 6f253534..89c0ab15 100644 --- a/steps/36/src/tests.rs +++ b/steps/36/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/37/src/tests.rs b/steps/37/src/tests.rs index 6f253534..89c0ab15 100644 --- a/steps/37/src/tests.rs +++ b/steps/37/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/38/src/tests.rs b/steps/38/src/tests.rs index 6f253534..89c0ab15 100644 --- a/steps/38/src/tests.rs +++ b/steps/38/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/39/src/tests.rs b/steps/39/src/tests.rs index 73757372..96402459 100644 --- a/steps/39/src/tests.rs +++ b/steps/39/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/40/src/tests.rs b/steps/40/src/tests.rs index 73757372..96402459 100644 --- a/steps/40/src/tests.rs +++ b/steps/40/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/41/src/tests.rs b/steps/41/src/tests.rs index 4fd315fb..ffe1390d 100644 --- a/steps/41/src/tests.rs +++ b/steps/41/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/42/src/tests.rs b/steps/42/src/tests.rs index 4fd315fb..ffe1390d 100644 --- a/steps/42/src/tests.rs +++ b/steps/42/src/tests.rs @@ -187,7 +187,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/43/src/tests.rs b/steps/43/src/tests.rs index a62fef25..37a2ddd4 100644 --- a/steps/43/src/tests.rs +++ b/steps/43/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/44/README.md b/steps/44/README.md index 18385623..61bfc6a1 100644 --- a/steps/44/README.md +++ b/steps/44/README.md @@ -147,4 +147,8 @@ Now that you know how to create and use the `BalanceOf` type, add the type al Then add a new field to the `Kitty` struct called `price`, which is an `Option>`. -Finally, update the `mint` function to create a new `Kitty` with the new `price` field set as `None`. +Update the `mint` function to create a new `Kitty` with the new `price` field set as `None`. + +Update the `do_transfer` function to reset the `kitty.price` to `None` when the kitty gets a new owner. + +Finally, update your `tests.rs` file so that `DEFAULT_KITTY` has the field and value `price: None`. diff --git a/steps/44/src/tests.rs b/steps/44/src/tests.rs index a62fef25..37a2ddd4 100644 --- a/steps/44/src/tests.rs +++ b/steps/44/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/45/src/tests.rs b/steps/45/src/tests.rs index 1e9b3921..ff914c8e 100644 --- a/steps/45/src/tests.rs +++ b/steps/45/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/46/src/tests.rs b/steps/46/src/tests.rs index 1e9b3921..ff914c8e 100644 --- a/steps/46/src/tests.rs +++ b/steps/46/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) diff --git a/steps/47/src/tests.rs b/steps/47/src/tests.rs index 1d72a3c0..4c486fd5 100644 --- a/steps/47/src/tests.rs +++ b/steps/47/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/48/src/tests.rs b/steps/48/src/tests.rs index 1d72a3c0..4c486fd5 100644 --- a/steps/48/src/tests.rs +++ b/steps/48/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/49/src/tests.rs b/steps/49/src/tests.rs index 9cfbc71f..77ffa1bc 100644 --- a/steps/49/src/tests.rs +++ b/steps/49/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/50/src/tests.rs b/steps/50/src/tests.rs index 9cfbc71f..77ffa1bc 100644 --- a/steps/50/src/tests.rs +++ b/steps/50/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/51/src/tests.rs b/steps/51/src/tests.rs index f7e3cd32..905bebfe 100644 --- a/steps/51/src/tests.rs +++ b/steps/51/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/52/src/tests.rs b/steps/52/src/tests.rs index f7e3cd32..905bebfe 100644 --- a/steps/52/src/tests.rs +++ b/steps/52/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); diff --git a/steps/53/src/tests.rs b/steps/53/src/tests.rs index fd6554a4..d3d623db 100644 --- a/steps/53/src/tests.rs +++ b/steps/53/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); @@ -400,5 +400,8 @@ fn do_buy_kitty_logic_works() { assert_eq!(kitty.owner, BOB); // Price is reset to `None`. assert_eq!(kitty.price, None); + // BOB transferred funds to ALICE. + assert_eq!(Balances::balance(&ALICE), 1337); + assert_eq!(Balances::balance(&BOB), 100_000); }) } diff --git a/steps/54/src/tests.rs b/steps/54/src/tests.rs index fd6554a4..d3d623db 100644 --- a/steps/54/src/tests.rs +++ b/steps/54/src/tests.rs @@ -188,7 +188,7 @@ fn kitty_struct_has_expected_traits() { new_test_ext().execute_with(|| { let kitty = DEFAULT_KITTY; let bytes = kitty.encode(); - let _new_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); + let _decoded_kitty = Kitty::::decode(&mut &bytes[..]).unwrap(); assert!(Kitty::::max_encoded_len() > 0); let _info = Kitty::::type_info(); }) @@ -319,7 +319,7 @@ fn set_price_emits_event() { assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE))); let kitty_id = Kitties::::iter_keys().collect::>()[0]; assert_ok!(PalletKitties::set_price(RuntimeOrigin::signed(ALICE), kitty_id, Some(1337))); - // Assert the last event by our blockchain is the `Created` event with the correct owner. + // Assert the last event is `PriceSet` event with the correct information. System::assert_last_event( Event::::PriceSet { owner: ALICE, kitty_id, new_price: Some(1337) }.into(), ); @@ -400,5 +400,8 @@ fn do_buy_kitty_logic_works() { assert_eq!(kitty.owner, BOB); // Price is reset to `None`. assert_eq!(kitty.price, None); + // BOB transferred funds to ALICE. + assert_eq!(Balances::balance(&ALICE), 1337); + assert_eq!(Balances::balance(&BOB), 100_000); }) }