Skip to content

Commit

Permalink
Add TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Feb 28, 2024
1 parent d665ccc commit c1fba21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ pub extern "C" fn call() {

#[allow(deprecated)]
api::xcm_take_response(query_id, &mut response_status).unwrap();

api::return_value(uapi::ReturnFlags::empty(), &response_status);
}
25 changes: 11 additions & 14 deletions substrate/frame/contracts/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ pub mod env {
}

/// Execute an XCM program locally, using the contract's address as the origin.
/// See [`pallet_contracts_uapi::HostFn::execute_xcm`].
/// See [`pallet_contracts_uapi::HostFn::xcm_execute`].
#[unstable]
fn xcm_execute(
ctx: _,
Expand Down Expand Up @@ -2143,7 +2143,7 @@ pub mod env {
}

/// Send an XCM program from the contract to the specified destination.
/// See [`pallet_contracts_uapi::HostFn::send_xcm`].
/// See [`pallet_contracts_uapi::HostFn::xcm_send`].
#[unstable]
fn xcm_send(
ctx: _,
Expand Down Expand Up @@ -2181,18 +2181,7 @@ pub mod env {
}

/// Create a new query, using the contract's address as the responder.
///
/// # Parameters
///
/// - `timeout_ptr`: the pointer into the linear memory where the timeout is placed.
/// - `match_querier_ptr`: the pointer into the linear memory where the match_querier is placed.
/// - `output_ptr`: the pointer into the linear memory where the
/// [`xcm_builder::QueryHandler::QueryId`] is placed.
///
/// # Return Value
///
/// Returns `ReturnCode::Success` when the query was successfully created. When the query
/// creation fails, `ReturnCode::XcmQueryFailed` is returned.
/// See [`pallet_contracts_uapi::HostFn::xcm_query`].
#[unstable]
fn xcm_query(
ctx: _,
Expand All @@ -2213,6 +2202,10 @@ pub mod env {
ctx.charge_gas(RuntimeCosts::CallRuntime(weight))?;
let origin = crate::RawOrigin::Signed(ctx.ext.address().clone()).into();

// TODO:
// - Take deposit for query.
// - Keep a map of account_id to query_id.

match <<E::T as Config>::Xcm>::query(origin, timeout, match_querier) {
Ok(query_id) => {
ctx.write_sandbox_memory(memory, output_ptr, &query_id.encode())?;
Expand Down Expand Up @@ -2249,6 +2242,10 @@ pub mod env {
) -> Result<ReturnErrorCode, TrapReason> {
use xcm_builder::{QueryController, QueryControllerWeightInfo, QueryHandler};

// TODO:
// - Ensure query_id belong to contract
// - Release deposit for query.

let query_id: <<E::T as Config>::Xcm as QueryHandler>::QueryId =
ctx.read_sandbox_memory_as(memory, query_id_ptr)?;

Expand Down

0 comments on commit c1fba21

Please sign in to comment.