Skip to content

Commit

Permalink
refactor: change gateway get messages query name (#281)
Browse files Browse the repository at this point in the history
* refactor: change gateway get messages query name

* doc: one liner comment for the query
  • Loading branch information
maancham authored Feb 26, 2024
1 parent ba7b422 commit f86bbe1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions contracts/connection-router/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ pub fn mock_gateway_execute(

#[cw_serde]
pub enum MockGatewayQueryMsg {
GetMessages { ids: Vec<CrossChainId> },
GetOutgoingMessages { ids: Vec<CrossChainId> },
}
pub fn mock_gateway_query(deps: Deps, _env: Env, msg: MockGatewayQueryMsg) -> StdResult<Binary> {
let mut msgs = vec![];

match msg {
MockGatewayQueryMsg::GetMessages { ids } => {
MockGatewayQueryMsg::GetOutgoingMessages { ids } => {
for id in ids {
match MOCK_GATEWAY_MESSAGES.may_load(deps.storage, id)? {
Some(m) => msgs.push(m),
Expand All @@ -56,7 +56,7 @@ pub fn get_gateway_messages(
app.wrap()
.query_wasm_smart(
gateway_address,
&MockGatewayQueryMsg::GetMessages {
&MockGatewayQueryMsg::GetOutgoingMessages {
ids: msgs.iter().map(|msg| msg.cc_id.clone()).collect(),
},
)
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod internal {

pub(crate) fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, Error> {
match msg {
QueryMsg::GetMessages { message_ids } => {
QueryMsg::GetOutgoingMessages { message_ids } => {
let msgs = contract::query::get_outgoing_messages(deps.storage, message_ids)?;
to_binary(&msgs).change_context(Error::SerializeResponse)
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/gateway/tests/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn successful_route_outgoing() {
let router = "router";
instantiate_contract(deps.as_mut(), "verifier", router);

let query_msg = QueryMsg::GetMessages {
let query_msg = QueryMsg::GetOutgoingMessages {
message_ids: msgs.iter().map(|msg| msg.cc_id.clone()).collect(),
};

Expand Down
2 changes: 1 addition & 1 deletion contracts/multisig-prover/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn get_messages(
) -> Result<Vec<Message>, ContractError> {
let length = message_ids.len();

let query = gateway_api::msg::QueryMsg::GetMessages { message_ids };
let query = gateway_api::msg::QueryMsg::GetOutgoingMessages { message_ids };
let messages: Vec<Message> = querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: gateway.into(),
msg: to_binary(&query)?,
Expand Down
2 changes: 1 addition & 1 deletion contracts/multisig-prover/src/test/mocks/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn execute(

pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetMessages { message_ids: _ } => {
QueryMsg::GetOutgoingMessages { message_ids: _ } => {
let res = test_data::messages();
to_binary(&res)
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn get_messages_from_gateway(
) -> Vec<Message> {
let query_response = app.wrap().query_wasm_smart(
gateway_address,
&gateway_api::msg::QueryMsg::GetMessages {
&gateway_api::msg::QueryMsg::GetOutgoingMessages {
message_ids: message_ids.to_owned(),
},
);
Expand Down
3 changes: 2 additions & 1 deletion packages/gateway-api/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum ExecuteMsg {
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
// messages that can be relayed to the chain corresponding to this gateway
#[returns(Vec<Message>)]
GetMessages { message_ids: Vec<CrossChainId> },
GetOutgoingMessages { message_ids: Vec<CrossChainId> },
}

0 comments on commit f86bbe1

Please sign in to comment.