Skip to content

Commit

Permalink
refactor: return dr_id in response.data in post_data_request()
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesondh committed Sep 25, 2023
1 parent 39e8bf9 commit 6845a35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/data-requests/src/data_request.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions packages/data-requests/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
use common::types::Hash;
use cosmwasm_schema::cw_serde;

#[cw_serde]
pub struct InstantiateMsg {
pub token: String,
pub proxy: String,
}

#[cw_serde]
pub struct PostDataRequestResponse {
pub dr_id: Hash,
}

0 comments on commit 6845a35

Please sign in to comment.