message: Add system entry point to cosmwasm-std
diff: @@ -136,6 +136,26 @@ where
  release_buffer(v) as u32
  }
  +/// do_system should be wrapped in an external "C" export, containing a contract-specific function as arg
  +///
  +/// - `M`: message type for request
  +/// - `C`: custom response message type (see CosmosMsg)
  +/// - `E`: error type for responses
  +pub fn do_system<M, C, E>(
  + system_fn: &dyn Fn(DepsMut, Env, M) -> Result<Response<C>, E>,
  + env_ptr: u32,
  + msg_ptr: u32,
  +) -> u32
  +where
  + M: DeserializeOwned + JsonSchema,
  + C: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema,
  + E: ToString,
  +{
  + let res = _do_system(system_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
  + let v = to_vec(&res).unwrap();
  + release_buffer(v) as u32
  +}
  +
  /// do_query should be wrapped in an external "C" export, containing a contract-specific function as arg
  ///
  /// - `M`: message type for request
  @@ -220,6 +240,26 @@ where
  migrate_fn(deps.as_mut(), env, msg).into()
  }
  +fn _do_system<M, C, E>(
  + system_fn: &dyn Fn(DepsMut, Env, M) -> Result<Response<C>, E>,
  + env_ptr: *mut Region,
  + msg_ptr: *mut Region,
  +) -> ContractResult<Response<C>>
  +where
  + M: DeserializeOwned + JsonSchema,
  + C: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema,
  + E: ToString,
  +{
  + let env: Vec<u8> = unsafe { consume_region(env_ptr) };
  + let msg: Vec<u8> = unsafe { consume_region(msg_ptr) };
  +
  + let env: Env = try_into_contract_result!(from_slice(&env));
  + let msg: M = try_into_contract_result!(from_slice(&msg));
  +
  + let mut deps = make_dependencies();
  + system_fn(deps.as_mut(), env, msg).into()
  +}
  +
  fn _do_query<M, E>(
  query_fn: &dyn Fn(Deps, Env, M) -> Result<QueryResponse, E>,
  env_ptr: *mut Region,
  