相关疑难解决方法(0)

在Substrate中,有没有一种方法可以使用另一个自定义模块中的存储和功能?

我已经看到了底教程创造单片基板运行模块的包装箱这里为了重复使用的功能,但我不知道是否有一个自定义模块的方式来访问在另一个自定义模块存储或功能?

遵循以下原则:

/// In ModuleA

    pub type IndexType = u64;

    decl_storage! {
        trait Store for Module<T: Trait> as ModuleA {
                pub MyIndexCount get(my_index_count): Option<IndexType>;
        }
    }
Run Code Online (Sandbox Code Playgroud)

然后在ModuleB内部-要使用/包括ModuleA的功能,我需要怎么做?如何称呼它?

/// In ModuleB

    decl_module! {
    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
        fn deposit_event<T>() = default;

        pub fn edit_index(origin) -> Result {
            let sender = ensure_signed(origin)?;

            // --->>>> I want to read some storage from ModuleA whilst inside ModuleB
            let c: IndexType = ReadStorageFromModuleA >>> my_index_count().ok_or("Storage Read …
Run Code Online (Sandbox Code Playgroud)

substrate

5
推荐指数
1
解决办法
203
查看次数

标签 统计

substrate ×1