【问题标题】:Error: local ambiguity: multiple parsing options: built-in NTs meta错误:局部歧义:多个解析选项:内置 NTs 元
【发布时间】:2021-10-07 19:40:58
【问题描述】:

我正在构建一个基板托盘,您可以在其中存放您的资金:

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

        /// Deposit funds
        #[pallet::weight(T::WeightInfo::deposit())]
        pub fn deposit(origin: OriginFor<T>, amount: BalanceOf<T>) -> DispatchResult {
            let user = ensure_signed(origin)?;

            // Get address info of extrinsic caller
            let mut address_info = <Accounts<T>>::get(&user);

            // Get current block
            let current_block = frame_system::Pallet::<T>::block_number();

            // Deposit funds to pallet
            T::Currency::transfer(
                &user,
                &Self::account_id(),
                amount,
                ExistenceRequirement::AllowDeath,
            )?;
        }
    }
}

然后我得到了这个错误:

error: local ambiguity: multiple parsing options: built-in NTs meta ('fn_attr') or 1 other option.
             /// Deposit funds
             ^^^^^^^^^^^^^^^^^

知道是什么问题吗?

【问题讨论】:

    标签: rust blockchain substrate


    【解决方案1】:

    您正在混合使用 FRAME 宏的版本,decl_* 不能与 #[pallet::*] 一起使用。我建议您完全迁移到新语法:

    示例:https://github.com/paritytech/substrate/commits/master/frame/example/src/lib.rs 升级指南FRAME v1->v2:https://crates.parity.io/frame_support/attr.pallet.html#upgrade-guidelines

    【讨论】:

    • 是的,我会完全做到这一点.. 谢谢。
    猜你喜欢
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多