Error: local ambiguity: multiple parsing options: built-in NTs meta

Error: local ambiguity: multiple parsing options: built-in NTs meta

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

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
             ^^^^^^^^^^^^^^^^^

知道问题出在哪里吗?

您正在混合使用 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