JoshOrndorff / recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
378 stars 186 forks source link

Convert sotrage for pallet v2. Need help! #468

Closed herou closed 2 years ago

herou commented 2 years ago

The title is very descriptive.

I would like to convert this Screenshot 2021-09-19 at 19 43 51

into V2. Below I have my translated version but it seems not working: Screenshot 2021-09-19 at 22 29 08

@JoshOrndorff Can you please take a look and tell me what's wrong. I would really appreciate it. Note: Some tests are failing Pallet link: https://github.com/herou/recipes/tree/recipes_pallet_v2/pallets/charity

JoshOrndorff commented 2 years ago

https://github.com/herou/recipes/pull/6

You weren't calling the genesis config for the charity pallet. I changed the code slightly to do that, but then I got a challenging compile error

  --> pallets/charity/src/tests.rs:99:4
   |
99 |         .assimilate_storage(&mut t)
   |          ^^^^^^^^^^^^^^^^^^ method not found in `Result<(), std::string::String>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `charity`

I'm guessing maybe you encountered this since there was some commented code around that area. The solution is to call assimilate_storage as a static method so you can explicitly tell it the type parameter. I can't say I understand 100% why it couldn't infer the type. I wish it could.

But this trick of calling as a static method is worth knowing.