From 6845a35e7a85a9718a3b78d24d6620f840659940 Mon Sep 17 00:00:00 2001 From: Jameson Hodge Date: Wed, 20 Sep 2023 16:10:25 -0400 Subject: [PATCH] refactor: return dr_id in response.data in `post_data_request()` --- packages/data-requests/src/data_request.rs | 12 +++++++++--- packages/data-requests/src/msg.rs | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/data-requests/src/data_request.rs b/packages/data-requests/src/data_request.rs index 4cfa3606..1006cf0a 100644 --- a/packages/data-requests/src/data_request.rs +++ b/packages/data-requests/src/data_request.rs @@ -1,9 +1,10 @@ #[cfg(not(feature = "library"))] -use cosmwasm_std::{Deps, DepsMut, MessageInfo, Order, Response, StdResult}; +use cosmwasm_std::{to_binary, Deps, DepsMut, MessageInfo, Order, Response, StdResult}; use crate::state::{DATA_REQUESTS, DATA_REQUESTS_COUNT}; use crate::error::ContractError; +use crate::msg::PostDataRequestResponse; use common::msg::{GetDataRequestResponse, GetDataRequestsFromPoolResponse}; use common::state::DataRequest; use common::types::Hash; @@ -101,8 +102,13 @@ pub mod data_requests { })?; Ok(Response::new() - .add_attribute("action", "post_data_request") - .add_attribute("dr_id", posted_dr.dr_id)) + .set_data(to_binary(&PostDataRequestResponse { + dr_id: posted_dr.dr_id.clone(), + })?) + .add_attributes(vec![ + ("action", "post_data_request"), + ("dr_id", &posted_dr.dr_id), + ])) } /// Returns a data request from the pool with the given id, if it exists. diff --git a/packages/data-requests/src/msg.rs b/packages/data-requests/src/msg.rs index 35a55f31..00bbd136 100644 --- a/packages/data-requests/src/msg.rs +++ b/packages/data-requests/src/msg.rs @@ -1,3 +1,4 @@ +use common::types::Hash; use cosmwasm_schema::cw_serde; #[cw_serde] @@ -5,3 +6,8 @@ pub struct InstantiateMsg { pub token: String, pub proxy: String, } + +#[cw_serde] +pub struct PostDataRequestResponse { + pub dr_id: Hash, +}