shawntabrizi / rust-state-machine

A tutorial for building a Polkadot SDK-like state machine written from scratch in Rust.
https://www.shawntabrizi.com/rust-state-machine/
MIT License
55 stars 18 forks source link

Ideas #1

Open shawntabrizi opened 9 months ago

shawntabrizi commented 9 months ago
kianenigma commented 3 months ago

show how users can use Type = u32 or similar patterns to bypass all the generics within the context of a pallet

The broad idea that we want people to learn is how to "dumb-down" FRAME such that they can be free from all the genericity, if it is not relevant.

One way to achieve this is to rewrite FRAME or parts of it, what we called a major ravamp of the whole system.

But we should first try and see how far we can get by just leveraging Rust syntax, for example your suggestion for <type = u32> aka. what is known as constrained associated type in Rust.

AssetId is an example where this trick worked. BlockNumber is one where it didn't, but I am still trying to find the right combination of Rust syntax for it. I will keep dumping further ideas along this line here.

PS. https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/trait_based_programming/index.html is a relevant article in polkadot-sdk-docs.