I am working on a Substrate-based blockchain project and I have the following function in my custom pallet:
#[pallet::call_index(8)]
#[pallet::weight(<T as Config>::WeightInfo::create_exchange())]
#[transactional]
pub fn call_smart_contract(
origin: OriginFor<T>,
dest: T::AccountId,
mut selector: Vec<u8>,
arg: u32,
gas_limit: Weight,
) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(selector.len() < MAX_LENGTH, Error::<T>::InputTooLarge);
let value: BalanceOf<T> = Default::default();
let mut arg_enc: Vec<u8> = arg.encode();
let mut data = Vec::new();
data.append(&mut selector);
data.append(&mut arg_enc);
pallet_contracts::Pallet::<T>::bare_call(
who,
dest.clone(),
value,
gas_limit,
data,
pallet_contracts::Pallet::<T>::deterministic(),
None,
false,
);
Self::deposit_event(Event::CalledContractFromPallet(dest));
Ok(())
}
I encountered the following errors when compiling my code:
1 - Error: no method named map_err found for struct ContractResult in the current scope
--> /home/kianoush/projects/music-chain/frame/dex/src/lib.rs:327:5
327 | .map_err(|e| {
| ^^^^^^^ method not found in `ContractResult<Result<ExecReturnValue, DispatchError>, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>`
2 - Error: no associated item named Deterministic found for struct Pallet in the current scope
--> /home/kianoush/projects/music-chain/frame/dex/src/lib.rs:323:36
323 | pallet_contracts::Pallet::<T>::Deterministic,
| ^^^^^^^^^^^^^ associated item not found in `Pallet<T>`
3 - Error: arguments to this function are incorrect
--> /home/kianoush/projects/music-chain/frame/dex/src/lib.rs:317:4
317 | pallet_contracts::Pallet::<T>::bare_call(
I am not sure how to resolve these errors. Can anyone help me understand what's wrong with my code and how to fix these issues?