Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

construct_runtime! should generate ModuleToString #5148

Closed
shawntabrizi opened this issue Mar 5, 2020 · 3 comments
Closed

construct_runtime! should generate ModuleToString #5148

shawntabrizi opened this issue Mar 5, 2020 · 3 comments
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

Comments

@shawntabrizi
Copy link
Contributor

It is likely we will not be able to get this done in time for merging: #5010

However, long term, we should have the construct_runtime! macro generate a ModuleToString type in each module's configuration trait.

This will be set to whatever string the user uses when configuring their runtime. i.e. :

construct_runtime!(
	pub enum Runtime where
		Block = Block,
		NodeBlock = opaque::Block,
		UncheckedExtrinsic = UncheckedExtrinsic
	{
		System: system::{Module, Call, Config, Storage, Event<T>},
		RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
		Timestamp: timestamp::{Module, Call, Storage, Inherent},
		Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
		Grandpa: grandpa::{Module, Call, Storage, Config, Event},
		Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},
		TransactionPayment: transaction_payment::{Module, Storage},
		Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
		// Used for the module template in `./template.rs`
		TemplateModule: template::{Module, Call, Storage, Event<T>},
	}
);

Would generate a ModuleToString of "TemplateModule".

This value should then automatically get used by the decl_storage macro.

Additionally, we could use this value for populating unique MODULE_IDs. For example:

const MODULE_ID: LockIdentifier = *b"py/elect";
@shawntabrizi shawntabrizi added J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Mar 6, 2020
@thiolliere
Copy link
Contributor

with #7148 we now have the name of the pallet.

For decl_storage usage we can do it in the macro attribute #6877
As suggested here #6877 (comment)

@thiolliere
Copy link
Contributor

maybe we should close this issue or renamed it with what needs to be done in storages and module_id

@thiolliere
Copy link
Contributor

The storages in pallet macro make use of PalletInfo::name to get its prefix.

So the only remaining task of this issue is:

Additionally, we could use this value for populating unique MODULE_IDs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants