diff --git a/substrate/frame/contracts/fixtures/contracts/xcm_take_response.rs b/substrate/frame/contracts/fixtures/contracts/xcm_take_response.rs index 4b0740b9e36d..847dd1e4c572 100644 --- a/substrate/frame/contracts/fixtures/contracts/xcm_take_response.rs +++ b/substrate/frame/contracts/fixtures/contracts/xcm_take_response.rs @@ -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); } diff --git a/substrate/frame/contracts/src/wasm/runtime.rs b/substrate/frame/contracts/src/wasm/runtime.rs index 73a22cf184f0..e4af8043e8cf 100644 --- a/substrate/frame/contracts/src/wasm/runtime.rs +++ b/substrate/frame/contracts/src/wasm/runtime.rs @@ -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: _, @@ -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: _, @@ -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: _, @@ -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 <::Xcm>::query(origin, timeout, match_querier) { Ok(query_id) => { ctx.write_sandbox_memory(memory, output_ptr, &query_id.encode())?; @@ -2249,6 +2242,10 @@ pub mod env { ) -> Result { use xcm_builder::{QueryController, QueryControllerWeightInfo, QueryHandler}; + // TODO: + // - Ensure query_id belong to contract + // - Release deposit for query. + let query_id: <::Xcm as QueryHandler>::QueryId = ctx.read_sandbox_memory_as(memory, query_id_ptr)?;