错误:局部歧义:多个解析选项:内置nt元



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

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

最新更新