Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: return dr_id in response.data in PostDataRequest message #66

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}