Skip to content

Commit

Permalink
refactor(minor): make the main flow msgs consistent (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgorenflo authored Jul 24, 2024
1 parent febb75b commit e4ef307
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 139 deletions.
2 changes: 1 addition & 1 deletion contracts/gateway/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod internal {

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

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

// check no messages are outgoing
let query_response = query(deps.as_ref(), mock_env(), query_msg.clone());
Expand Down Expand Up @@ -398,7 +397,7 @@ fn correctly_working_verifier_handler(
{
move |msg: voting_verifier::msg::QueryMsg| -> Result<Vec<MessageStatus>, ContractError> {
match msg {
voting_verifier::msg::QueryMsg::GetMessagesStatus { messages } => Ok(messages
voting_verifier::msg::QueryMsg::GetMessagesStatus(messages) => Ok(messages
.into_iter()
.map(|msg| {
MessageStatus::new(
Expand Down
14 changes: 7 additions & 7 deletions contracts/gateway/tests/test_verify.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions contracts/multisig-prover/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ pub fn execute(
msg: ExecuteMsg,
) -> Result<Response, axelar_wasm_std::error::ContractError> {
match msg.ensure_permissions(deps.storage, &info.sender)? {
ExecuteMsg::ConstructProof { message_ids } => {
Ok(execute::construct_proof(deps, message_ids)?)
}
ExecuteMsg::ConstructProof(message_ids) => Ok(execute::construct_proof(deps, message_ids)?),
ExecuteMsg::UpdateVerifierSet {} => Ok(execute::update_verifier_set(deps, env)?),
ExecuteMsg::ConfirmVerifierSet {} => Ok(execute::confirm_verifier_set(deps, info.sender)?),
ExecuteMsg::UpdateSigningThreshold {
Expand Down Expand Up @@ -229,7 +227,7 @@ mod tests {
.collect::<Vec<CrossChainId>>()
});

let msg = ExecuteMsg::ConstructProof { message_ids };
let msg = ExecuteMsg::ConstructProof(message_ids);
execute(deps, mock_env(), mock_info(RELAYER, &[]), msg)
}

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

let query = gateway_api::msg::QueryMsg::GetOutgoingMessages { 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_json_binary(&query)?,
Expand Down Expand Up @@ -288,9 +288,7 @@ fn ensure_verifier_set_verification(
config: &Config,
deps: &DepsMut,
) -> Result<(), ContractError> {
let query = voting_verifier::msg::QueryMsg::GetVerifierSetStatus {
new_verifier_set: verifier_set.clone(),
};
let query = voting_verifier::msg::QueryMsg::GetVerifierSetStatus(verifier_set.clone());

let status: VerificationStatus = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.voting_verifier.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion contracts/multisig-prover/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum ExecuteMsg {
// Start building a proof that includes specified messages
// Queries the gateway for actual message contents
#[permission(Any)]
ConstructProof { message_ids: Vec<CrossChainId> },
ConstructProof(Vec<CrossChainId>),
#[permission(Elevated)]
UpdateVerifierSet,

Expand Down
10 changes: 4 additions & 6 deletions contracts/voting-verifier/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ pub struct Client<'a> {

impl<'a> Client<'a> {
pub fn verify_messages(&self, messages: Vec<Message>) -> Option<WasmMsg> {
ignore_empty(messages).map(|messages| {
self.client
.execute(&ExecuteMsg::VerifyMessages { messages })
})
ignore_empty(messages)
.map(|messages| self.client.execute(&ExecuteMsg::VerifyMessages(messages)))
}

pub fn vote(&self, poll_id: PollId, votes: Vec<Vote>) -> WasmMsg {
Expand Down Expand Up @@ -69,14 +67,14 @@ impl<'a> Client<'a> {
[] => Ok(vec![]),
_ => self
.client
.query(&QueryMsg::GetMessagesStatus { messages })
.query(&QueryMsg::GetMessagesStatus(messages))
.change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone())),
}
}

pub fn verifier_set_status(&self, new_verifier_set: VerifierSet) -> Result<VerificationStatus> {
self.client
.query(&QueryMsg::GetVerifierSetStatus { new_verifier_set })
.query(&QueryMsg::GetVerifierSetStatus(new_verifier_set))
.change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone()))
}

Expand Down
Loading

0 comments on commit e4ef307

Please sign in to comment.