lib.rs 35.3 KiB
Newer Older
Gavin Wood's avatar
Gavin Wood committed
		let instruction = QueryResponse { query_id, response, max_weight, querier };
		let message = Xcm(vec![instruction]);
		self.send(destination, message, fee_reason)
Gavin Wood's avatar
Gavin Wood committed
	}

	fn try_reanchor(
		asset: MultiAsset,
		destination: &MultiLocation,
	) -> Result<(MultiAsset, InteriorMultiLocation), XcmError> {
		let reanchor_context = Config::UniversalLocation::get();
		let asset = asset
			.reanchored(&destination, reanchor_context)
			.map_err(|()| XcmError::ReanchorFailed)?;
		Ok((asset, reanchor_context))
	}

	fn try_reanchor_multilocation(
		location: MultiLocation,
		destination: &MultiLocation,
	) -> Result<(MultiLocation, InteriorMultiLocation), XcmError> {
		let reanchor_context = Config::UniversalLocation::get();
		let location = location
			.reanchored(&destination, reanchor_context)
			.map_err(|_| XcmError::ReanchorFailed)?;
		Ok((location, reanchor_context))
	}

	/// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`.
	fn reanchored(
		mut assets: Assets,
		dest: &MultiLocation,
		maybe_failed_bin: Option<&mut Assets>,
	) -> MultiAssets {
Gavin Wood's avatar
Gavin Wood committed
		let reanchor_context = Config::UniversalLocation::get();
		assets.reanchor(dest, reanchor_context, maybe_failed_bin);
		assets.into_assets_iter().collect::<Vec<_>>().into()