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

construct_runtime! should generate ModuleToString #5148

Closed

Description

@shawntabrizi

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";

Activity

  1. added
    J0-enhancementAn additional feature request.
    Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
    on Mar 6, 2020
  2. gui1117 commented on Sep 24, 2020

    @gui1117
    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)

  3. gui1117 commented on Sep 24, 2020

    @gui1117
    Contributor

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

  4. gui1117 commented on Dec 24, 2020

    @gui1117
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    J0-enhancementAn additional feature request.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions