diff --git a/ampd/proto/ampd.proto b/ampd/proto/ampd.proto index 59bb0ebe6..fa477adda 100644 --- a/ampd/proto/ampd.proto +++ b/ampd/proto/ampd.proto @@ -15,9 +15,9 @@ message SubscribeRequest { bool include_block_begin_end = 2; } -message EventBlockBegin { uint64 height = 1; } +message EventBlockBegin {uint64 height = 1;} -message EventBlockEnd { uint64 height = 1; } +message EventBlockEnd {uint64 height = 1;} message Event { string event_type = 1; @@ -32,7 +32,7 @@ message SubscribeResponse { } } -message BroadcastRequest { google.protobuf.Any msg = 1; } +message BroadcastRequest {google.protobuf.Any msg = 1;} message BroadcastResponse {} @@ -47,16 +47,16 @@ message SignRequest { Algorithm algorithm = 3; } -message SignResponse { bytes signature = 1; } +message SignResponse {bytes signature = 1;} -message GetKeyRequest { +message KeyRequest { string key_id = 1; Algorithm algorithm = 2; } -message GetKeyResponse { bytes pub_key = 1; } +message KeyResponse {bytes pub_key = 1;} service Crypto { rpc Sign(SignRequest) returns (SignResponse) {} - rpc GetKey(GetKeyRequest) returns (GetKeyResponse) {} + rpc Key(KeyRequest) returns (KeyResponse) {} } diff --git a/ampd/src/broadcaster/confirm_tx.rs b/ampd/src/broadcaster/confirm_tx.rs index c9770ec97..7499af9e3 100644 --- a/ampd/src/broadcaster/confirm_tx.rs +++ b/ampd/src/broadcaster/confirm_tx.rs @@ -135,13 +135,7 @@ where hash: tx_hash.clone(), }; - match client - .lock() - .await - .get_tx(req) - .await - .then(evaluate_tx_response) - { + match client.lock().await.tx(req).await.then(evaluate_tx_response) { ConfirmationResult::Confirmed(tx) => return Ok(*tx), ConfirmationResult::NotFound if i == attempts.saturating_sub(1) => { return Err(report!(Error::Confirmation { tx_hash })) @@ -198,7 +192,7 @@ mod test { let mut client = MockBroadcastClient::new(); client - .expect_get_tx() + .expect_tx() .with(predicate::eq(GetTxRequest { hash: tx_hash.clone(), })) @@ -245,7 +239,7 @@ mod test { let mut client = MockBroadcastClient::new(); client - .expect_get_tx() + .expect_tx() .with(predicate::eq(GetTxRequest { hash: tx_hash.clone(), })) @@ -283,7 +277,7 @@ mod test { let mut client = MockBroadcastClient::new(); client - .expect_get_tx() + .expect_tx() .with(predicate::eq(GetTxRequest { hash: tx_hash.clone(), })) @@ -317,7 +311,7 @@ mod test { let mut client = MockBroadcastClient::new(); client - .expect_get_tx() + .expect_tx() .with(predicate::eq(GetTxRequest { hash: tx_hash.clone(), })) diff --git a/ampd/src/broadcaster/cosmos.rs b/ampd/src/broadcaster/cosmos.rs index f77134e4b..5f0dabeb9 100644 --- a/ampd/src/broadcaster/cosmos.rs +++ b/ampd/src/broadcaster/cosmos.rs @@ -24,7 +24,7 @@ use tonic::{Response, Status}; pub trait BroadcastClient { async fn broadcast_tx(&mut self, request: BroadcastTxRequest) -> Result; async fn simulate(&mut self, request: SimulateRequest) -> Result; - async fn get_tx(&mut self, request: GetTxRequest) -> Result; + async fn tx(&mut self, request: GetTxRequest) -> Result; } #[async_trait] @@ -42,7 +42,7 @@ impl BroadcastClient for ServiceClient { self.simulate(request).await.map(Response::into_inner) } - async fn get_tx(&mut self, request: GetTxRequest) -> Result { + async fn tx(&mut self, request: GetTxRequest) -> Result { self.get_tx(request).await.map(Response::into_inner) } } diff --git a/ampd/src/broadcaster/mod.rs b/ampd/src/broadcaster/mod.rs index 487c4e53f..d328eb02f 100644 --- a/ampd/src/broadcaster/mod.rs +++ b/ampd/src/broadcaster/mod.rs @@ -668,7 +668,7 @@ mod tests { client .expect_broadcast_tx() .returning(|_| Ok(TxResponse::default())); - client.expect_get_tx().returning(|_| { + client.expect_tx().returning(|_| { Ok(GetTxResponse { tx_response: Some(TxResponse { code: 0, diff --git a/ampd/src/commands/register_public_key.rs b/ampd/src/commands/register_public_key.rs index e0e8d0c7a..b31f45f1a 100644 --- a/ampd/src/commands/register_public_key.rs +++ b/ampd/src/commands/register_public_key.rs @@ -49,7 +49,7 @@ pub struct Args { pub async fn run(config: Config, args: Args) -> Result, Error> { let pub_key = verifier_pub_key(config.tofnd_config.clone()).await?; - let multisig_address = get_multisig_address(&config)?; + let multisig_address = multisig_address(&config)?; let tofnd_config = config.tofnd_config.clone(); @@ -105,7 +105,7 @@ pub async fn run(config: Config, args: Args) -> Result, Error> { ))) } -fn get_multisig_address(config: &Config) -> Result { +fn multisig_address(config: &Config) -> Result { config .handlers .iter() diff --git a/ampd/src/evm/verifier.rs b/ampd/src/evm/verifier.rs index 120d4313c..b29c702f0 100644 --- a/ampd/src/evm/verifier.rs +++ b/ampd/src/evm/verifier.rs @@ -50,7 +50,7 @@ fn has_failed(tx_receipt: &TransactionReceipt) -> bool { tx_receipt.status == Some(0u64.into()) } -fn get_event<'a>( +fn event<'a>( gateway_address: &EVMAddress, tx_receipt: &'a TransactionReceipt, log_index: u32, @@ -83,7 +83,7 @@ where return Vote::FailedOnChain; } - match get_event(gateway_address, tx_receipt, expected_event_index) { + match event(gateway_address, tx_receipt, expected_event_index) { Some(event) if tx_receipt.transaction_hash == expected_transaction_hash && to_verify == event => { @@ -135,7 +135,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_tx_id_does_not_match() { let (gateway_address, tx_receipt, mut verifier_set) = - get_matching_verifier_set_and_tx_receipt(); + matching_verifier_set_and_tx_receipt(); verifier_set.tx_id = Hash::random(); assert_eq!( @@ -147,7 +147,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_tx_failed() { let (gateway_address, mut tx_receipt, verifier_set) = - get_matching_verifier_set_and_tx_receipt(); + matching_verifier_set_and_tx_receipt(); tx_receipt.status = Some(0u64.into()); assert_eq!( @@ -158,7 +158,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_gateway_address_does_not_match() { - let (_, tx_receipt, verifier_set) = get_matching_verifier_set_and_tx_receipt(); + let (_, tx_receipt, verifier_set) = matching_verifier_set_and_tx_receipt(); let gateway_address = EVMAddress::random(); assert_eq!( @@ -170,7 +170,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_log_index_does_not_match() { let (gateway_address, tx_receipt, mut verifier_set) = - get_matching_verifier_set_and_tx_receipt(); + matching_verifier_set_and_tx_receipt(); verifier_set.event_index = 0; assert_eq!( @@ -192,7 +192,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_verifier_set_does_not_match() { let (gateway_address, tx_receipt, mut verifier_set) = - get_matching_verifier_set_and_tx_receipt(); + matching_verifier_set_and_tx_receipt(); verifier_set.verifier_set.threshold = Uint128::from(50u64); assert_eq!( @@ -203,8 +203,7 @@ mod tests { #[test] fn should_verify_verifier_set_if_correct() { - let (gateway_address, tx_receipt, verifier_set) = - get_matching_verifier_set_and_tx_receipt(); + let (gateway_address, tx_receipt, verifier_set) = matching_verifier_set_and_tx_receipt(); assert_eq!( verify_verifier_set(&gateway_address, &tx_receipt, &verifier_set), @@ -214,7 +213,7 @@ mod tests { #[test] fn should_not_verify_msg_if_tx_id_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_receipt(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_receipt(); msg.tx_id = Hash::random(); assert_eq!( @@ -225,7 +224,7 @@ mod tests { #[test] fn should_not_verify_msg_if_tx_failed() { - let (gateway_address, mut tx_receipt, msg) = get_matching_msg_and_tx_receipt(); + let (gateway_address, mut tx_receipt, msg) = matching_msg_and_tx_receipt(); tx_receipt.status = Some(0u64.into()); assert_eq!( @@ -236,7 +235,7 @@ mod tests { #[test] fn should_not_verify_msg_if_gateway_address_does_not_match() { - let (_, tx_receipt, msg) = get_matching_msg_and_tx_receipt(); + let (_, tx_receipt, msg) = matching_msg_and_tx_receipt(); let gateway_address = EVMAddress::random(); assert_eq!( @@ -247,7 +246,7 @@ mod tests { #[test] fn should_not_verify_msg_if_log_index_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_receipt(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_receipt(); msg.event_index = 0; assert_eq!( @@ -268,7 +267,7 @@ mod tests { #[test] fn should_not_verify_msg_if_msg_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_receipt(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_receipt(); msg.source_address = EVMAddress::random(); assert_eq!( @@ -279,7 +278,7 @@ mod tests { #[test] fn should_verify_msg_if_correct() { - let (gateway_address, tx_receipt, msg) = get_matching_msg_and_tx_receipt(); + let (gateway_address, tx_receipt, msg) = matching_msg_and_tx_receipt(); assert_eq!( verify_message(&gateway_address, &tx_receipt, &msg), @@ -287,7 +286,7 @@ mod tests { ); } - fn get_matching_verifier_set_and_tx_receipt( + fn matching_verifier_set_and_tx_receipt( ) -> (EVMAddress, TransactionReceipt, VerifierSetConfirmation) { let tx_id = Hash::random(); let log_index = 1; @@ -326,7 +325,7 @@ mod tests { (gateway_address, tx_receipt, verifier_set) } - fn get_matching_msg_and_tx_receipt() -> (EVMAddress, TransactionReceipt, Message) { + fn matching_msg_and_tx_receipt() -> (EVMAddress, TransactionReceipt, Message) { let tx_id = Hash::random(); let log_index = 1; let gateway_address = EVMAddress::random(); diff --git a/ampd/src/grpc/client.rs b/ampd/src/grpc/client.rs index 4ea5b8f13..44822fbc9 100644 --- a/ampd/src/grpc/client.rs +++ b/ampd/src/grpc/client.rs @@ -51,7 +51,7 @@ mod tests { use crate::event_sub::MockEventSub; use crate::grpc; use crate::proto::{ - Algorithm, BroadcastRequest, BroadcastResponse, GetKeyRequest, GetKeyResponse, SignRequest, + Algorithm, BroadcastRequest, BroadcastResponse, KeyRequest, KeyResponse, SignRequest, SignResponse, SubscribeRequest, }; use crate::queue::queued_broadcaster::MockBroadcasterClient; @@ -80,7 +80,7 @@ mod tests { } #[test] - async fn get_key_should_work() { + async fn key_should_work() { let key_id = "key_id"; let key: PublicKey = SigningKey::random(&mut OsRng).verifying_key().into(); let algorithm = Algorithm::Ed25519; @@ -105,14 +105,14 @@ mod tests { .await .unwrap() .crypto - .get_key(GetKeyRequest { + .key(KeyRequest { key_id: key_id.to_string(), algorithm: algorithm.into(), }) .await .unwrap() .into_inner(), - GetKeyResponse { + KeyResponse { pub_key: key.to_bytes() } ); diff --git a/ampd/src/grpc/server/crypto.rs b/ampd/src/grpc/server/crypto.rs index 690988c0e..48e912616 100644 --- a/ampd/src/grpc/server/crypto.rs +++ b/ampd/src/grpc/server/crypto.rs @@ -67,17 +67,17 @@ where Ok(Response::new(proto::SignResponse { signature })) } - async fn get_key( + async fn key( &self, - req: Request, - ) -> Result, Status> { + req: Request, + ) -> Result, Status> { let req = req.into_inner(); let algorithm = proto::Algorithm::from_i32(req.algorithm) .ok_or(Status::invalid_argument("invalid algorithm"))?; let key = self.key(&req.key_id, algorithm).await?; - Ok(Response::new(proto::GetKeyResponse { + Ok(Response::new(proto::KeyResponse { pub_key: key.to_bytes(), })) } @@ -92,9 +92,10 @@ mod tests { use tokio::test; use tonic::Code; - use super::proto::crypto_server::Crypto; use super::proto::{self}; use super::Server; + use crate::proto::crypto_server; + use crate::proto::crypto_server::Crypto; use crate::tofnd; use crate::tofnd::grpc::MockMultisig; use crate::types::PublicKey; @@ -158,7 +159,7 @@ mod tests { } #[test] - async fn get_key_should_return_correct_key() { + async fn key_should_return_correct_key() { let key_id = "key_id"; let algorithm = proto::Algorithm::Ecdsa; let key: PublicKey = SigningKey::random(&mut OsRng).verifying_key().into(); @@ -173,27 +174,30 @@ mod tests { .return_once(move |_, _| Ok(key)); let server = Server::new(multisig_client); - let req = tonic::Request::new(proto::GetKeyRequest { + let req = tonic::Request::new(proto::KeyRequest { key_id: key_id.to_string(), algorithm: algorithm.into(), }); - let res = server.get_key(req).await.unwrap().into_inner(); + let res = crypto_server::Crypto::key(&server, req) + .await + .unwrap() + .into_inner(); assert_eq!(res.pub_key, key.to_bytes()); } #[test] - async fn get_key_should_return_error_when_algorithm_is_invalid() { + async fn key_should_return_error_when_algorithm_is_invalid() { let key_id = "key_id"; let multisig_client = MockMultisig::default(); let server = Server::new(multisig_client); - let req = tonic::Request::new(proto::GetKeyRequest { + let req = tonic::Request::new(proto::KeyRequest { key_id: key_id.to_string(), algorithm: 2, }); - let res = server.get_key(req).await.unwrap_err(); + let res = crypto_server::Crypto::key(&server, req).await.unwrap_err(); assert_eq!(res.code(), Code::InvalidArgument); } diff --git a/ampd/src/handlers/evm_verify_msg.rs b/ampd/src/handlers/evm_verify_msg.rs index 9133e4c8a..7abb4cc1d 100644 --- a/ampd/src/handlers/evm_verify_msg.rs +++ b/ampd/src/handlers/evm_verify_msg.rs @@ -246,7 +246,7 @@ mod tests { use crate::types::{EVMAddress, Hash, TMAddress}; use crate::PREFIX; - fn get_poll_started_event(participants: Vec, expires_at: u64) -> PollStarted { + fn poll_started_event(participants: Vec, expires_at: u64) -> PollStarted { PollStarted::Messages { metadata: PollMetadata { poll_id: "100".parse().unwrap(), @@ -293,8 +293,8 @@ mod tests { #[test] fn should_not_deserialize_incorrect_event() { // incorrect event type - let mut event: Event = get_event( - get_poll_started_event(participants(5, None), 100), + let mut event: Event = to_event( + poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ); match event { @@ -313,8 +313,8 @@ mod tests { )); // invalid field - let mut event: Event = get_event( - get_poll_started_event(participants(5, None), 100), + let mut event: Event = to_event( + poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ); match event { @@ -336,8 +336,8 @@ mod tests { #[test] fn should_deserialize_correct_event() { - let event: Event = get_event( - get_poll_started_event(participants(5, None), 100), + let event: Event = to_event( + poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ); let event: Result = event.try_into(); @@ -357,8 +357,8 @@ mod tests { let voting_verifier_contract = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); let expiration = 100u64; - let event: Event = get_event( - get_poll_started_event(participants(5, Some(verifier.clone())), expiration), + let event: Event = to_event( + poll_started_event(participants(5, Some(verifier.clone())), expiration), &voting_verifier_contract, ); @@ -382,7 +382,7 @@ mod tests { assert_eq!(handler.handle(&event).await.unwrap(), vec![]); } - fn get_event(event: impl Into, contract_address: &TMAddress) -> Event { + fn to_event(event: impl Into, contract_address: &TMAddress) -> Event { let mut event: cosmwasm_std::Event = event.into(); event.ty = format!("wasm-{}", event.ty); diff --git a/ampd/src/handlers/evm_verify_verifier_set.rs b/ampd/src/handlers/evm_verify_verifier_set.rs index 9e936f248..7b7179c6c 100644 --- a/ampd/src/handlers/evm_verify_verifier_set.rs +++ b/ampd/src/handlers/evm_verify_verifier_set.rs @@ -223,7 +223,7 @@ mod tests { #[test] fn should_deserialize_correct_event() { - let event: Event = get_event( + let event: Event = to_event( poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ); @@ -245,7 +245,7 @@ mod tests { let voting_verifier = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); let expiration = 100u64; - let event: Event = get_event( + let event: Event = to_event( poll_started_event(participants(5, Some(verifier.clone())), expiration), &voting_verifier, ); @@ -293,7 +293,7 @@ mod tests { } } - fn get_event(event: impl Into, contract_address: &TMAddress) -> Event { + fn to_event(event: impl Into, contract_address: &TMAddress) -> Event { let mut event: cosmwasm_std::Event = event.into(); event.ty = format!("wasm-{}", event.ty); diff --git a/ampd/src/handlers/mod.rs b/ampd/src/handlers/mod.rs index 026238768..8a15b92fd 100644 --- a/ampd/src/handlers/mod.rs +++ b/ampd/src/handlers/mod.rs @@ -18,7 +18,10 @@ mod tests { use crate::types::TMAddress; /// Convert a CosmWasm event into an ABCI event - pub fn get_event(event: impl Into, contract_address: &TMAddress) -> Event { + pub fn into_structured_event( + event: impl Into, + contract_address: &TMAddress, + ) -> Event { let mut event: cosmwasm_std::Event = event.into(); event.ty = format!("wasm-{}", event.ty); diff --git a/ampd/src/handlers/multisig.rs b/ampd/src/handlers/multisig.rs index c05936889..978ee4bdb 100644 --- a/ampd/src/handlers/multisig.rs +++ b/ampd/src/handlers/multisig.rs @@ -301,7 +301,7 @@ mod test { .unwrap() } - fn get_handler( + fn handler( verifier: TMAddress, multisig: TMAddress, signer: MockMultisig, @@ -376,7 +376,7 @@ mod test { async fn should_not_handle_event_with_missing_fields_if_multisig_address_does_not_match() { let client = MockMultisig::default(); - let handler = get_handler( + let handler = handler( rand_account(), TMAddress::from(MULTISIG_ADDRESS.parse::().unwrap()), client, @@ -398,7 +398,7 @@ mod test { async fn should_error_on_event_with_missing_fields_if_multisig_address_does_match() { let client = MockMultisig::default(); - let handler = get_handler( + let handler = handler( rand_account(), TMAddress::from(MULTISIG_ADDRESS.parse::().unwrap()), client, @@ -415,7 +415,7 @@ mod test { async fn should_not_handle_event_if_multisig_address_does_not_match() { let client = MockMultisig::default(); - let handler = get_handler(rand_account(), rand_account(), client, 100u64); + let handler = handler(rand_account(), rand_account(), client, 100u64); assert_eq!( handler.handle(&signing_started_event()).await.unwrap(), @@ -430,7 +430,7 @@ mod test { .expect_sign() .returning(move |_, _, _, _| Err(Report::from(tofnd::error::Error::SignFailed))); - let handler = get_handler( + let handler = handler( rand_account(), TMAddress::from(MULTISIG_ADDRESS.parse::().unwrap()), client, @@ -453,7 +453,7 @@ mod test { let event = signing_started_event(); let signing_started: SigningStartedEvent = ((&event).try_into() as Result<_, _>).unwrap(); let verifier = signing_started.pub_keys.keys().next().unwrap().clone(); - let handler = get_handler( + let handler = handler( verifier, TMAddress::from(MULTISIG_ADDRESS.parse::().unwrap()), client, @@ -476,7 +476,7 @@ mod test { let event = signing_started_event(); let signing_started: SigningStartedEvent = ((&event).try_into() as Result<_, _>).unwrap(); let verifier = signing_started.pub_keys.keys().next().unwrap().clone(); - let handler = get_handler( + let handler = handler( verifier, TMAddress::from(MULTISIG_ADDRESS.parse::().unwrap()), client, diff --git a/ampd/src/handlers/sui_verify_msg.rs b/ampd/src/handlers/sui_verify_msg.rs index 53dcbfdcf..3d60cb2b0 100644 --- a/ampd/src/handlers/sui_verify_msg.rs +++ b/ampd/src/handlers/sui_verify_msg.rs @@ -166,7 +166,7 @@ mod tests { use super::PollStartedEvent; use crate::event_processor::EventHandler; use crate::handlers::errors::Error; - use crate::handlers::tests::get_event; + use crate::handlers::tests::into_structured_event; use crate::sui::json_rpc::MockSuiClient; use crate::types::{EVMAddress, Hash, TMAddress}; @@ -174,7 +174,7 @@ mod tests { #[test] fn should_deserialize_poll_started_event() { - let event: Result = get_event( + let event: Result = into_structured_event( poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ) @@ -186,7 +186,7 @@ mod tests { // Should not handle event if it is not a poll started event #[async_test] async fn not_poll_started_event() { - let event = get_event( + let event = into_structured_event( cosmwasm_std::Event::new("transfer"), &TMAddress::random(PREFIX), ); @@ -204,7 +204,7 @@ mod tests { // Should not handle event if it is not emitted from voting verifier #[async_test] async fn contract_is_not_voting_verifier() { - let event = get_event( + let event = into_structured_event( poll_started_event(participants(5, None), 100), &TMAddress::random(PREFIX), ); @@ -223,7 +223,7 @@ mod tests { #[async_test] async fn verifier_is_not_a_participant() { let voting_verifier = TMAddress::random(PREFIX); - let event = get_event( + let event = into_structured_event( poll_started_event(participants(5, None), 100), &voting_verifier, ); @@ -252,7 +252,7 @@ mod tests { let voting_verifier = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); - let event = get_event( + let event = into_structured_event( poll_started_event(participants(5, Some(verifier.clone())), 100), &voting_verifier, ); @@ -275,7 +275,7 @@ mod tests { let voting_verifier = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); - let event = get_event( + let event = into_structured_event( poll_started_event(participants(5, Some(verifier.clone())), 100), &voting_verifier, ); @@ -303,7 +303,7 @@ mod tests { let voting_verifier = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); let expiration = 100u64; - let event: Event = get_event( + let event: Event = into_structured_event( poll_started_event(participants(5, Some(verifier.clone())), expiration), &voting_verifier, ); diff --git a/ampd/src/handlers/sui_verify_verifier_set.rs b/ampd/src/handlers/sui_verify_verifier_set.rs index 8b12a701b..4a159c916 100644 --- a/ampd/src/handlers/sui_verify_verifier_set.rs +++ b/ampd/src/handlers/sui_verify_verifier_set.rs @@ -167,7 +167,7 @@ mod tests { use super::PollStartedEvent; use crate::event_processor::EventHandler; - use crate::handlers::tests::get_event; + use crate::handlers::tests::into_structured_event; use crate::sui::json_rpc::MockSuiClient; use crate::types::TMAddress; use crate::PREFIX; @@ -176,7 +176,7 @@ mod tests { fn should_deserialize_verifier_set_poll_started_event() { let participants = (0..5).map(|_| TMAddress::random(PREFIX)).collect(); - let event: Result = get_event( + let event: Result = into_structured_event( verifier_set_poll_started_event(participants, 100), &TMAddress::random(PREFIX), ) @@ -200,7 +200,7 @@ mod tests { let voting_verifier = TMAddress::random(PREFIX); let verifier = TMAddress::random(PREFIX); let expiration = 100u64; - let event: Event = get_event( + let event: Event = into_structured_event( verifier_set_poll_started_event( vec![verifier.clone()].into_iter().collect(), expiration, diff --git a/ampd/src/sui/verifier.rs b/ampd/src/sui/verifier.rs index 7dcf603e0..d49efb5bb 100644 --- a/ampd/src/sui/verifier.rs +++ b/ampd/src/sui/verifier.rs @@ -226,7 +226,7 @@ mod tests { #[test] fn should_not_verify_msg_if_tx_id_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.tx_id = TransactionDigest::random(); assert_eq!( @@ -237,7 +237,7 @@ mod tests { #[test] fn should_not_verify_msg_if_event_index_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.event_index = rand::random::(); assert_eq!( @@ -248,7 +248,7 @@ mod tests { #[test] fn should_not_verify_msg_if_source_address_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.source_address = SuiAddress::random_for_testing_only(); assert_eq!( @@ -259,7 +259,7 @@ mod tests { #[test] fn should_not_verify_msg_if_destination_chain_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.destination_chain = rand_chain_name(); assert_eq!( @@ -270,7 +270,7 @@ mod tests { #[test] fn should_not_verify_msg_if_destination_address_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.destination_address = EVMAddress::random().to_string(); assert_eq!( @@ -281,7 +281,7 @@ mod tests { #[test] fn should_not_verify_msg_if_payload_hash_does_not_match() { - let (gateway_address, tx_receipt, mut msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_receipt, mut msg) = matching_msg_and_tx_block(); msg.payload_hash = Hash::random(); assert_eq!( @@ -292,7 +292,7 @@ mod tests { #[test] fn should_verify_msg_if_correct() { - let (gateway_address, tx_block, msg) = get_matching_msg_and_tx_block(); + let (gateway_address, tx_block, msg) = matching_msg_and_tx_block(); assert_eq!( verify_message(&gateway_address, &tx_block, &msg), Vote::SucceededOnChain @@ -301,7 +301,7 @@ mod tests { #[test] fn should_verify_verifier_set_if_correct() { - let (gateway_address, tx_block, verifier_set) = get_matching_verifier_set_and_tx_block(); + let (gateway_address, tx_block, verifier_set) = matching_verifier_set_and_tx_block(); assert_eq!( verify_verifier_set(&gateway_address, &tx_block, &verifier_set), @@ -311,7 +311,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_gateway_address_mismatch() { - let (_, tx_block, verifier_set) = get_matching_verifier_set_and_tx_block(); + let (_, tx_block, verifier_set) = matching_verifier_set_and_tx_block(); assert_eq!( verify_verifier_set( @@ -325,8 +325,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_tx_digest_mismatch() { - let (gateway_address, mut tx_block, verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, mut tx_block, verifier_set) = matching_verifier_set_and_tx_block(); tx_block.digest = TransactionDigest::random(); assert_eq!( @@ -337,8 +336,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_event_seq_mismatch() { - let (gateway_address, tx_block, mut verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, tx_block, mut verifier_set) = matching_verifier_set_and_tx_block(); verifier_set.event_index = rand::random(); assert_eq!( @@ -349,8 +347,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_struct_tag_mismatch() { - let (gateway_address, mut tx_block, verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, mut tx_block, verifier_set) = matching_verifier_set_and_tx_block(); tx_block .events .as_mut() @@ -373,8 +370,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_threshold_mismatch() { - let (gateway_address, tx_block, mut verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, tx_block, mut verifier_set) = matching_verifier_set_and_tx_block(); verifier_set.verifier_set.threshold = Uint128::new(2); assert_eq!( @@ -385,8 +381,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_nonce_mismatch() { - let (gateway_address, tx_block, mut verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, tx_block, mut verifier_set) = matching_verifier_set_and_tx_block(); verifier_set.verifier_set.created_at = rand::random(); assert_eq!( @@ -397,8 +392,7 @@ mod tests { #[test] fn should_not_verify_verifier_set_if_signers_mismatch() { - let (gateway_address, tx_block, mut verifier_set) = - get_matching_verifier_set_and_tx_block(); + let (gateway_address, tx_block, mut verifier_set) = matching_verifier_set_and_tx_block(); let signer = random_signer(); verifier_set .verifier_set @@ -411,7 +405,7 @@ mod tests { ); } - fn get_matching_msg_and_tx_block() -> (SuiAddress, SuiTransactionBlockResponse, Message) { + fn matching_msg_and_tx_block() -> (SuiAddress, SuiTransactionBlockResponse, Message) { let gateway_address = SuiAddress::random_for_testing_only(); let msg = Message { @@ -476,7 +470,7 @@ mod tests { } } - fn get_matching_verifier_set_and_tx_block() -> ( + fn matching_verifier_set_and_tx_block() -> ( SuiAddress, SuiTransactionBlockResponse, VerifierSetConfirmation, diff --git a/contracts/gateway/src/contract.rs b/contracts/gateway/src/contract.rs index 91b5fe956..6c8a2f9ff 100644 --- a/contracts/gateway/src/contract.rs +++ b/contracts/gateway/src/contract.rs @@ -140,8 +140,8 @@ mod internal { pub(crate) fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result { match msg { - QueryMsg::GetOutgoingMessages { message_ids } => { - let msgs = contract::query::get_outgoing_messages(deps.storage, message_ids)?; + QueryMsg::OutgoingMessages { message_ids } => { + let msgs = contract::query::outgoing_messages(deps.storage, message_ids)?; to_json_binary(&msgs).change_context(Error::SerializeResponse) } } diff --git a/contracts/gateway/src/contract/query.rs b/contracts/gateway/src/contract/query.rs index c6b1a632d..62835b162 100644 --- a/contracts/gateway/src/contract/query.rs +++ b/contracts/gateway/src/contract/query.rs @@ -6,7 +6,7 @@ use router_api::{CrossChainId, Message}; use crate::contract::Error; use crate::state; -pub fn get_outgoing_messages( +pub fn outgoing_messages( storage: &dyn Storage, cross_chain_ids: Vec, ) -> Result, Error> { @@ -45,7 +45,7 @@ mod test { use crate::state; #[test] - fn get_outgoing_messages_all_messages_present_returns_all() { + fn outgoing_messages_all_messages_present_returns_all() { let mut deps = mock_dependencies(); let messages = generate_messages(); @@ -56,25 +56,25 @@ mod test { let ids = messages.iter().map(|msg| msg.cc_id.clone()).collect(); - let res = super::get_outgoing_messages(&deps.storage, ids).unwrap(); + let res = super::outgoing_messages(&deps.storage, ids).unwrap(); assert_eq!(res, messages); } #[test] - fn get_outgoing_messages_nothing_stored_returns_not_found_error() { + fn outgoing_messages_nothing_stored_returns_not_found_error() { let deps = mock_dependencies(); let messages = generate_messages(); let ids = messages.iter().map(|msg| msg.cc_id.clone()).collect(); - let res = super::get_outgoing_messages(&deps.storage, ids); + let res = super::outgoing_messages(&deps.storage, ids); assert!(res.is_err()); assert_eq!(res.unwrap_err().current_frames().len(), messages.len()); } #[test] - fn get_outgoing_messages_only_partially_found_returns_not_found_error() { + fn outgoing_messages_only_partially_found_returns_not_found_error() { let mut deps = mock_dependencies(); let messages = generate_messages(); @@ -83,7 +83,7 @@ mod test { let ids = messages.iter().map(|msg| msg.cc_id.clone()).collect(); - let res = super::get_outgoing_messages(&deps.storage, ids); + let res = super::outgoing_messages(&deps.storage, ids); assert!(res.is_err()); assert_eq!(res.unwrap_err().current_frames().len(), messages.len() - 1); diff --git a/contracts/gateway/tests/contract.rs b/contracts/gateway/tests/contract.rs index 541e8eb63..753e03ed8 100644 --- a/contracts/gateway/tests/contract.rs +++ b/contracts/gateway/tests/contract.rs @@ -138,7 +138,7 @@ fn successful_route_outgoing() { let router = "router"; instantiate_contract(deps.as_mut(), "verifier", router); - let query_msg = QueryMsg::GetOutgoingMessages { + let query_msg = QueryMsg::OutgoingMessages { message_ids: msgs.iter().map(|msg| msg.cc_id.clone()).collect(), }; @@ -398,7 +398,7 @@ fn correctly_working_verifier_handler( { move |msg: voting_verifier::msg::QueryMsg| -> Result, ContractError> { match msg { - voting_verifier::msg::QueryMsg::GetMessagesStatus { messages } => Ok(messages + voting_verifier::msg::QueryMsg::MessagesStatus { messages } => Ok(messages .into_iter() .map(|msg| { MessageStatus::new( diff --git a/contracts/multisig-prover/src/contract.rs b/contracts/multisig-prover/src/contract.rs index 1a01ce10e..edad8f7a0 100644 --- a/contracts/multisig-prover/src/contract.rs +++ b/contracts/multisig-prover/src/contract.rs @@ -98,9 +98,9 @@ pub fn query( msg: QueryMsg, ) -> Result { match msg { - QueryMsg::GetProof { + QueryMsg::Proof { multisig_session_id, - } => to_json_binary(&query::get_proof(deps, multisig_session_id)?), + } => to_json_binary(&query::proof(deps, multisig_session_id)?), QueryMsg::CurrentVerifierSet {} => to_json_binary(&query::current_verifier_set(deps)?), QueryMsg::NextVerifierSet {} => to_json_binary(&query::next_verifier_set(deps)?), } @@ -139,7 +139,7 @@ mod tests { use super::*; use crate::contract::execute::should_update_verifier_set; use crate::encoding::Encoder; - use crate::msg::{GetProofResponse, ProofStatus, VerifierSetResponse}; + use crate::msg::{ProofResponse, ProofStatus, VerifierSetResponse}; use crate::test::test_data::{self, TestOperator}; use crate::test::test_utils::{ mock_querier_handler, ADMIN, COORDINATOR_ADDRESS, GATEWAY_ADDRESS, GOVERNANCE, @@ -258,10 +258,10 @@ mod tests { ) } - fn query_get_proof( + fn query_proof( deps: Deps, multisig_session_id: Option, - ) -> Result { + ) -> Result { let multisig_session_id = match multisig_session_id { Some(id) => id, None => MULTISIG_SESSION_ID, @@ -270,14 +270,14 @@ mod tests { query( deps, mock_env(), - QueryMsg::GetProof { + QueryMsg::Proof { multisig_session_id, }, ) .map(|res| from_json(res).unwrap()) } - fn query_get_verifier_set( + fn query_verifier_set( deps: Deps, ) -> Result, axelar_wasm_std::error::ContractError> { query(deps, mock_env(), QueryMsg::CurrentVerifierSet {}).map(|res| from_json(res).unwrap()) @@ -387,14 +387,14 @@ mod tests { #[test] fn test_update_verifier_set_fresh() { let mut deps = setup_test_case(); - let verifier_set = query_get_verifier_set(deps.as_ref()); + let verifier_set = query_verifier_set(deps.as_ref()); assert!(verifier_set.is_ok()); assert!(verifier_set.unwrap().is_none()); let res = execute_update_verifier_set(deps.as_mut()); assert!(res.is_ok()); - let verifier_set = query_get_verifier_set(deps.as_ref()); + let verifier_set = query_verifier_set(deps.as_ref()); assert!(verifier_set.is_ok()); let verifier_set = verifier_set.unwrap().unwrap(); @@ -470,7 +470,7 @@ mod tests { assert!(res.is_ok()); - let verifier_set = query_get_verifier_set(deps.as_ref()); + let verifier_set = query_verifier_set(deps.as_ref()); assert!(verifier_set.is_ok()); let verifier_set = verifier_set.unwrap().unwrap(); @@ -504,7 +504,7 @@ mod tests { let res = execute_update_verifier_set(deps.as_mut()); assert!(res.is_ok()); - let verifier_set = query_get_verifier_set(deps.as_ref()); + let verifier_set = query_verifier_set(deps.as_ref()); assert!(verifier_set.is_ok()); let verifier_set = verifier_set.unwrap().unwrap(); @@ -538,7 +538,7 @@ mod tests { assert!(res.is_ok()); - let verifier_set = query_get_verifier_set(deps.as_ref()); + let verifier_set = query_verifier_set(deps.as_ref()); assert!(verifier_set.is_ok()); let verifier_set = verifier_set.unwrap().unwrap(); @@ -655,7 +655,7 @@ mod tests { execute_construct_proof(deps.as_mut(), None).unwrap(); reply_construct_proof(deps.as_mut()).unwrap(); // simulate reply from multisig - let res = query_get_proof(deps.as_ref(), None).unwrap(); + let res = query_proof(deps.as_ref(), None).unwrap(); assert_eq!(res.multisig_session_id, MULTISIG_SESSION_ID); assert_eq!(res.message_ids.len(), 1); @@ -704,7 +704,7 @@ mod tests { /// Calls update_signing_threshold, increasing the threshold by one. /// Returns (initial threshold, new threshold) fn update_signing_threshold_increase_by_one(deps: DepsMut) -> (Uint128, Uint128) { - let verifier_set = query_get_verifier_set(deps.as_ref()) + let verifier_set = query_verifier_set(deps.as_ref()) .unwrap() .unwrap() .verifier_set; @@ -742,7 +742,7 @@ mod tests { update_signing_threshold_increase_by_one(deps.as_mut()); assert_ne!(initial_threshold, new_threshold); - let verifier_set = query_get_verifier_set(deps.as_ref()) + let verifier_set = query_verifier_set(deps.as_ref()) .unwrap() .unwrap() .verifier_set; @@ -763,7 +763,7 @@ mod tests { let governance = Addr::unchecked(GOVERNANCE); confirm_verifier_set(deps.as_mut(), governance).unwrap(); - let verifier_set = query_get_verifier_set(deps.as_ref()) + let verifier_set = query_verifier_set(deps.as_ref()) .unwrap() .unwrap() .verifier_set; @@ -784,7 +784,7 @@ mod tests { let res = confirm_verifier_set(deps.as_mut(), Addr::unchecked("relayer")); assert!(res.is_ok()); - let verifier_set = query_get_verifier_set(deps.as_ref()) + let verifier_set = query_verifier_set(deps.as_ref()) .unwrap() .unwrap() .verifier_set; diff --git a/contracts/multisig-prover/src/contract/execute.rs b/contracts/multisig-prover/src/contract/execute.rs index 677ec8d55..40e861dce 100644 --- a/contracts/multisig-prover/src/contract/execute.rs +++ b/contracts/multisig-prover/src/contract/execute.rs @@ -27,7 +27,7 @@ pub fn construct_proof( let config = CONFIG.load(deps.storage).map_err(ContractError::from)?; let payload_id = message_ids.as_slice().into(); - let messages = get_messages( + let messages = messages( deps.querier, message_ids, config.gateway.clone(), @@ -74,7 +74,7 @@ pub fn construct_proof( Ok(Response::new().add_submessage(SubMsg::reply_on_success(wasm_msg, START_MULTISIG_REPLY_ID))) } -fn get_messages( +fn messages( querier: QuerierWrapper, message_ids: Vec, gateway: Addr, @@ -82,7 +82,7 @@ fn get_messages( ) -> Result, ContractError> { let length = message_ids.len(); - let query = gateway_api::msg::QueryMsg::GetOutgoingMessages { message_ids }; + let query = gateway_api::msg::QueryMsg::OutgoingMessages { message_ids }; let messages: Vec = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: gateway.into(), msg: to_json_binary(&query)?, @@ -109,7 +109,7 @@ fn make_verifier_set( env: &Env, config: &Config, ) -> Result { - let active_verifiers_query = service_registry::msg::QueryMsg::GetActiveVerifiers { + let active_verifiers_query = service_registry::msg::QueryMsg::ActiveVerifiers { service_name: config.service_name.clone(), chain_name: config.chain_name.clone(), }; @@ -124,7 +124,7 @@ fn make_verifier_set( .querier .query::(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: config.service_registry.to_string(), - msg: to_json_binary(&service_registry::msg::QueryMsg::GetService { + msg: to_json_binary(&service_registry::msg::QueryMsg::Service { service_name: config.service_name.clone(), })?, }))? @@ -133,7 +133,7 @@ fn make_verifier_set( let participants_with_pubkeys = verifiers .into_iter() .filter_map(|verifier| { - let pub_key_query = multisig::msg::QueryMsg::GetPublicKey { + let pub_key_query = multisig::msg::QueryMsg::PublicKey { verifier_address: verifier.verifier_info.address.to_string(), key_type: config.key_type, }; @@ -168,7 +168,7 @@ fn make_verifier_set( )) } -fn get_next_verifier_set( +fn next_verifier_set( deps: &DepsMut, env: &Env, config: &Config, @@ -237,7 +237,7 @@ pub fn update_verifier_set( )) } Some(cur_verifier_set) => { - let new_verifier_set = get_next_verifier_set(&deps, &env, &config)? + let new_verifier_set = next_verifier_set(&deps, &env, &config)? .ok_or(ContractError::VerifierSetUnchanged)?; save_next_verifier_set(deps.storage, &new_verifier_set)?; @@ -288,7 +288,7 @@ fn ensure_verifier_set_verification( config: &Config, deps: &DepsMut, ) -> Result<(), ContractError> { - let query = voting_verifier::msg::QueryMsg::GetVerifierSetStatus { + let query = voting_verifier::msg::QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }; @@ -415,7 +415,7 @@ mod tests { use cosmwasm_std::Addr; use router_api::ChainName; - use super::{different_set_in_progress, get_next_verifier_set, should_update_verifier_set}; + use super::{different_set_in_progress, next_verifier_set, should_update_verifier_set}; use crate::state::{Config, NEXT_VERIFIER_SET}; use crate::test::test_data; @@ -523,14 +523,14 @@ mod tests { } #[test] - fn get_next_verifier_set_should_return_pending() { + fn next_verifier_set_should_return_pending() { let mut deps = mock_dependencies(); let env = mock_env(); let new_verifier_set = test_data::new_verifier_set(); NEXT_VERIFIER_SET .save(deps.as_mut().storage, &new_verifier_set) .unwrap(); - let ret_verifier_set = get_next_verifier_set(&deps.as_mut(), &env, &mock_config()); + let ret_verifier_set = next_verifier_set(&deps.as_mut(), &env, &mock_config()); assert_eq!(ret_verifier_set.unwrap().unwrap(), new_verifier_set); } diff --git a/contracts/multisig-prover/src/contract/query.rs b/contracts/multisig-prover/src/contract/query.rs index 82f620f47..14c35a102 100644 --- a/contracts/multisig-prover/src/contract/query.rs +++ b/contracts/multisig-prover/src/contract/query.rs @@ -4,22 +4,19 @@ use multisig::multisig::Multisig; use multisig::types::MultisigState; use crate::error::ContractError; -use crate::msg::{GetProofResponse, ProofStatus, VerifierSetResponse}; +use crate::msg::{ProofResponse, ProofStatus, VerifierSetResponse}; use crate::state::{ CONFIG, CURRENT_VERIFIER_SET, MULTISIG_SESSION_PAYLOAD, NEXT_VERIFIER_SET, PAYLOAD, }; -pub fn get_proof( - deps: Deps, - multisig_session_id: Uint64, -) -> Result { +pub fn proof(deps: Deps, multisig_session_id: Uint64) -> Result { let config = CONFIG.load(deps.storage).map_err(ContractError::from)?; let payload_id = MULTISIG_SESSION_PAYLOAD .load(deps.storage, multisig_session_id.u64()) .map_err(ContractError::from)?; - let query_msg = multisig::msg::QueryMsg::GetMultisig { + let query_msg = multisig::msg::QueryMsg::Multisig { session_id: multisig_session_id, }; @@ -49,7 +46,7 @@ pub fn get_proof( } }; - Ok(GetProofResponse { + Ok(ProofResponse { multisig_session_id, message_ids: payload.message_ids().unwrap_or_default(), payload, diff --git a/contracts/multisig-prover/src/msg.rs b/contracts/multisig-prover/src/msg.rs index 5a7f7001a..f86347a11 100644 --- a/contracts/multisig-prover/src/msg.rs +++ b/contracts/multisig-prover/src/msg.rs @@ -82,8 +82,8 @@ pub enum ExecuteMsg { #[cw_serde] #[derive(QueryResponses)] pub enum QueryMsg { - #[returns(GetProofResponse)] - GetProof { multisig_session_id: Uint64 }, + #[returns(ProofResponse)] + Proof { multisig_session_id: Uint64 }, /// Returns a `VerifierSetResponse` with the current verifier set id and the verifier set itself. #[returns(Option)] @@ -101,7 +101,7 @@ pub enum ProofStatus { } #[cw_serde] -pub struct GetProofResponse { +pub struct ProofResponse { pub multisig_session_id: Uint64, pub message_ids: Vec, pub payload: Payload, diff --git a/contracts/multisig-prover/src/test/test_utils.rs b/contracts/multisig-prover/src/test/test_utils.rs index 5db7060f8..1553a98a4 100644 --- a/contracts/multisig-prover/src/test/test_utils.rs +++ b/contracts/multisig-prover/src/test/test_utils.rs @@ -49,10 +49,10 @@ fn multisig_mock_querier_handler( operators: Vec, ) -> QuerierResult { let result = match msg { - multisig::msg::QueryMsg::GetMultisig { session_id: _ } => { - to_json_binary(&mock_get_multisig(operators)) + multisig::msg::QueryMsg::Multisig { session_id: _ } => { + to_json_binary(&mock_multisig(operators)) } - multisig::msg::QueryMsg::GetPublicKey { + multisig::msg::QueryMsg::PublicKey { verifier_address, key_type: _, } => to_json_binary( @@ -68,7 +68,7 @@ fn multisig_mock_querier_handler( Ok(result.into()).into() } -fn mock_get_multisig(operators: Vec) -> Multisig { +fn mock_multisig(operators: Vec) -> Multisig { let quorum = test_data::quorum(); let signers = operators @@ -117,7 +117,7 @@ fn service_registry_mock_querier_handler( operators: Vec, ) -> QuerierResult { let result = match msg { - service_registry::msg::QueryMsg::GetService { service_name } => { + service_registry::msg::QueryMsg::Service { service_name } => { to_json_binary(&service_registry::state::Service { name: service_name.to_string(), coordinator_contract: Addr::unchecked(COORDINATOR_ADDRESS), @@ -129,7 +129,7 @@ fn service_registry_mock_querier_handler( description: "verifiers".to_string(), }) } - service_registry::msg::QueryMsg::GetActiveVerifiers { + service_registry::msg::QueryMsg::ActiveVerifiers { service_name: _, chain_name: _, } => to_json_binary( diff --git a/contracts/multisig/src/contract.rs b/contracts/multisig/src/contract.rs index 4f0ea8120..b9116cf07 100644 --- a/contracts/multisig/src/contract.rs +++ b/contracts/multisig/src/contract.rs @@ -14,7 +14,7 @@ use router_api::ChainName; use crate::events::Event; use crate::msg::{ExecuteMsg, InstantiateMsg, MigrationMsg, QueryMsg}; use crate::state::{ - get_verifier_set, Config, CONFIG, SIGNING_SESSIONS, SIGNING_SESSION_COUNTER, VERIFIER_SETS, + verifier_set, Config, CONFIG, SIGNING_SESSIONS, SIGNING_SESSION_COUNTER, VERIFIER_SETS, }; use crate::types::{MsgToSign, MultisigState}; use crate::ContractError; @@ -167,16 +167,14 @@ fn can_start_signing_session( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetMultisig { session_id } => { - to_json_binary(&query::get_multisig(deps, session_id)?) + QueryMsg::Multisig { session_id } => to_json_binary(&query::multisig(deps, session_id)?), + QueryMsg::VerifierSet { verifier_set_id } => { + to_json_binary(&query::verifier_set(deps, verifier_set_id)?) } - QueryMsg::GetVerifierSet { verifier_set_id } => { - to_json_binary(&query::get_verifier_set(deps, verifier_set_id)?) - } - QueryMsg::GetPublicKey { + QueryMsg::PublicKey { verifier_address, key_type, - } => to_json_binary(&query::get_public_key( + } => to_json_binary(&query::public_key( deps, deps.api.addr_validate(&verifier_address)?, key_type, @@ -261,7 +259,7 @@ mod tests { query( deps, env, - QueryMsg::GetVerifierSet { + QueryMsg::VerifierSet { verifier_set_id: verifier_set_id.to_string(), }, ) @@ -375,7 +373,7 @@ mod tests { query( deps, env, - QueryMsg::GetPublicKey { + QueryMsg::PublicKey { verifier_address: verifier.to_string(), key_type, }, @@ -402,7 +400,7 @@ mod tests { } // TODO: move to external crate? - fn get_event_attribute<'a>( + fn event_attribute<'a>( event: &'a cosmwasm_std::Event, attribute_name: &'a str, ) -> Option<&'a str> { @@ -514,7 +512,7 @@ mod tests { .unwrap(); let verifier_set_id = subkey.to_string(); - let verifier_set = get_verifier_set(deps.as_ref().storage, &verifier_set_id).unwrap(); + let verifier_set = verifier_set(deps.as_ref().storage, &verifier_set_id).unwrap(); let message = match subkey { _ if subkey == ecdsa_subkey => ecdsa_test_data::message(), _ if subkey == ed25519_subkey => ed25519_test_data::message(), @@ -536,18 +534,18 @@ mod tests { let event = res.events.first().unwrap(); assert_eq!(event.ty, "signing_started".to_string()); assert_eq!( - get_event_attribute(event, "session_id").unwrap(), + event_attribute(event, "session_id").unwrap(), session.id.to_string() ); assert_eq!( - get_event_attribute(event, "verifier_set_id").unwrap(), + event_attribute(event, "verifier_set_id").unwrap(), session.verifier_set_id ); assert_eq!( - verifier_set.get_pub_keys(), - from_str(get_event_attribute(event, "pub_keys").unwrap()).unwrap() + verifier_set.pub_keys(), + from_str(event_attribute(event, "pub_keys").unwrap()).unwrap() ); - assert_eq!(get_event_attribute(event, "msg").unwrap(), message.to_hex()); + assert_eq!(event_attribute(event, "msg").unwrap(), message.to_hex()); } } @@ -635,15 +633,15 @@ mod tests { let event = res.events.first().unwrap(); assert_eq!(event.ty, "signature_submitted".to_string()); assert_eq!( - get_event_attribute(event, "session_id").unwrap(), + event_attribute(event, "session_id").unwrap(), session_id.to_string() ); assert_eq!( - get_event_attribute(event, "participant").unwrap(), + event_attribute(event, "participant").unwrap(), signer.address.into_string() ); assert_eq!( - get_event_attribute(event, "signature").unwrap(), + event_attribute(event, "signature").unwrap(), signer.signature.to_hex() ); } @@ -700,7 +698,7 @@ mod tests { let event = res.events.get(1).unwrap(); assert_eq!(event.ty, "signing_completed".to_string()); assert_eq!( - get_event_attribute(event, "session_id").unwrap(), + event_attribute(event, "session_id").unwrap(), session_id.to_string() ); } @@ -846,7 +844,7 @@ mod tests { let expected_completed_at = env.block.height; do_sign(deps.as_mut(), env, session_id, signers.get(1).unwrap()).unwrap(); - let msg = QueryMsg::GetMultisig { session_id }; + let msg = QueryMsg::Multisig { session_id }; let res = query(deps.as_ref(), mock_env(), msg); assert!(res.is_ok()); diff --git a/contracts/multisig/src/contract/execute.rs b/contracts/multisig/src/contract/execute.rs index 81cea039c..00c0c302f 100644 --- a/contracts/multisig/src/contract/execute.rs +++ b/contracts/multisig/src/contract/execute.rs @@ -26,7 +26,7 @@ pub fn start_signing_session( let config = CONFIG.load(deps.storage)?; - let verifier_set = get_verifier_set(deps.storage, &verifier_set_id)?; + let verifier_set = verifier_set(deps.storage, &verifier_set_id)?; let session_id = SIGNING_SESSION_COUNTER.update( deps.storage, @@ -64,7 +64,7 @@ pub fn start_signing_session( let event = Event::SigningStarted { session_id, verifier_set_id, - pub_keys: verifier_set.get_pub_keys(), + pub_keys: verifier_set.pub_keys(), msg, chain_name, expires_at, diff --git a/contracts/multisig/src/contract/query.rs b/contracts/multisig/src/contract/query.rs index 6d34cc0e6..8279883ee 100644 --- a/contracts/multisig/src/contract/query.rs +++ b/contracts/multisig/src/contract/query.rs @@ -6,7 +6,7 @@ use crate::multisig::Multisig; use crate::state::{load_pub_key, load_session_signatures, AUTHORIZED_CALLERS}; use crate::verifier_set::VerifierSet; -pub fn get_multisig(deps: Deps, session_id: Uint64) -> StdResult { +pub fn multisig(deps: Deps, session_id: Uint64) -> StdResult { let session = SIGNING_SESSIONS.load(deps.storage, session_id.into())?; let verifier_set = VERIFIER_SETS.load(deps.storage, &session.verifier_set_id)?; @@ -19,11 +19,11 @@ pub fn get_multisig(deps: Deps, session_id: Uint64) -> StdResult { }) } -pub fn get_verifier_set(deps: Deps, verifier_set_id: String) -> StdResult { +pub fn verifier_set(deps: Deps, verifier_set_id: String) -> StdResult { VERIFIER_SETS.load(deps.storage, &verifier_set_id) } -pub fn get_public_key(deps: Deps, verifier: Addr, key_type: KeyType) -> StdResult { +pub fn public_key(deps: Deps, verifier: Addr, key_type: KeyType) -> StdResult { let raw = load_pub_key(deps.storage, verifier, key_type)?; Ok(PublicKey::try_from((key_type, raw)).expect("could not decode pub key")) } diff --git a/contracts/multisig/src/msg.rs b/contracts/multisig/src/msg.rs index 6a88d696c..213d76c81 100644 --- a/contracts/multisig/src/msg.rs +++ b/contracts/multisig/src/msg.rs @@ -82,13 +82,13 @@ pub enum ExecuteMsg { #[derive(QueryResponses)] pub enum QueryMsg { #[returns(Multisig)] - GetMultisig { session_id: Uint64 }, + Multisig { session_id: Uint64 }, #[returns(VerifierSet)] - GetVerifierSet { verifier_set_id: String }, + VerifierSet { verifier_set_id: String }, #[returns(PublicKey)] - GetPublicKey { + PublicKey { verifier_address: String, key_type: KeyType, }, diff --git a/contracts/multisig/src/state.rs b/contracts/multisig/src/state.rs index 0ead03953..43979c058 100644 --- a/contracts/multisig/src/state.rs +++ b/contracts/multisig/src/state.rs @@ -57,7 +57,7 @@ pub fn save_signature( type VerifierSetId = str; pub const VERIFIER_SETS: Map<&VerifierSetId, VerifierSet> = Map::new("verifier_sets"); -pub fn get_verifier_set( +pub fn verifier_set( store: &dyn Storage, verifier_set_id: &str, ) -> Result { diff --git a/contracts/multisig/src/verifier_set.rs b/contracts/multisig/src/verifier_set.rs index 634a63dde..637859165 100644 --- a/contracts/multisig/src/verifier_set.rs +++ b/contracts/multisig/src/verifier_set.rs @@ -65,7 +65,7 @@ impl VerifierSet { HexBinary::from(self.hash()).to_hex() } - pub fn get_pub_keys(&self) -> HashMap { + pub fn pub_keys(&self) -> HashMap { self.signers .iter() .map(|(address, signer)| (address.clone(), signer.pub_key.clone())) diff --git a/contracts/router/src/contract.rs b/contracts/router/src/contract.rs index 205bcee8e..2180858c3 100644 --- a/contracts/router/src/contract.rs +++ b/contracts/router/src/contract.rs @@ -128,9 +128,7 @@ pub fn query( msg: QueryMsg, ) -> Result { match msg { - QueryMsg::GetChainInfo(chain) => { - to_json_binary(&query::get_chain_info(deps.storage, chain)?) - } + QueryMsg::ChainInfo(chain) => to_json_binary(&query::chain_info(deps.storage, chain)?), QueryMsg::Chains { start_after, limit } => { to_json_binary(&query::chains(deps, start_after, limit)?) } diff --git a/contracts/router/src/contract/query.rs b/contracts/router/src/contract/query.rs index 8c2833d45..a33f9b7f3 100644 --- a/contracts/router/src/contract/query.rs +++ b/contracts/router/src/contract/query.rs @@ -9,7 +9,7 @@ use crate::state::chain_endpoints; // Pagination limits const DEFAULT_LIMIT: u32 = u32::MAX; -pub fn get_chain_info(storage: &dyn Storage, chain: ChainName) -> Result { +pub fn chain_info(storage: &dyn Storage, chain: ChainName) -> Result { chain_endpoints() .may_load(storage, chain) .change_context(Error::StoreFailure)? @@ -42,14 +42,14 @@ mod test { use router_api::error::Error; use router_api::{ChainEndpoint, ChainName, Gateway, GatewayDirection}; - use super::get_chain_info; + use super::chain_info; use crate::state::chain_endpoints; #[test] fn should_get_chain_info() { let mut deps = mock_dependencies(); let chain_name: ChainName = "Ethereum".to_string().try_into().unwrap(); - let chain_info = ChainEndpoint { + let endpoint = ChainEndpoint { name: chain_name.clone(), gateway: Gateway { address: Addr::unchecked("some gateway"), @@ -59,18 +59,18 @@ mod test { }; assert!(chain_endpoints() - .save(deps.as_mut().storage, chain_name.clone(), &chain_info) + .save(deps.as_mut().storage, chain_name.clone(), &endpoint) .is_ok()); - let result = get_chain_info(deps.as_ref().storage, chain_name); + let result = chain_info(deps.as_ref().storage, chain_name); assert!(result.is_ok()); - assert_eq!(result.unwrap(), chain_info); + assert_eq!(result.unwrap(), endpoint); } #[test] fn get_non_existent_chain_info() { let deps = mock_dependencies(); let chain_name: ChainName = "Ethereum".to_string().try_into().unwrap(); - let result = get_chain_info(deps.as_ref().storage, chain_name); + let result = chain_info(deps.as_ref().storage, chain_name); assert!(result.is_err()); assert_eq!(result.unwrap_err().current_context(), &Error::ChainNotFound); } diff --git a/contracts/service-registry/src/contract.rs b/contracts/service-registry/src/contract.rs index dd02fc8c1..f7ef6edab 100644 --- a/contracts/service-registry/src/contract.rs +++ b/contracts/service-registry/src/contract.rs @@ -138,22 +138,18 @@ pub fn execute( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result { match msg { - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name, chain_name, - } => to_json_binary(&query::get_active_verifiers( - deps, - service_name, - chain_name, - )?) - .map_err(|err| err.into()), - QueryMsg::GetVerifier { + } => to_json_binary(&query::active_verifiers(deps, service_name, chain_name)?) + .map_err(|err| err.into()), + QueryMsg::Verifier { service_name, verifier, - } => to_json_binary(&query::get_verifier(deps, service_name, verifier)?) + } => to_json_binary(&query::verifier(deps, service_name, verifier)?) .map_err(|err| err.into()), - QueryMsg::GetService { service_name } => { - to_json_binary(&query::get_service(deps, service_name)?).map_err(|err| err.into()) + QueryMsg::Service { service_name } => { + to_json_binary(&query::service(deps, service_name)?).map_err(|err| err.into()) } } } @@ -415,7 +411,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -442,7 +438,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: ChainName::from_str("random chain").unwrap(), }, @@ -530,7 +526,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -622,7 +618,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: chain, }, @@ -718,7 +714,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: deregistered_chain, }, @@ -734,7 +730,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: chain.clone(), }, @@ -837,7 +833,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -949,7 +945,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1038,7 +1034,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1112,7 +1108,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1166,7 +1162,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1272,7 +1268,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1374,7 +1370,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1448,7 +1444,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1522,7 +1518,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1629,7 +1625,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name, }, @@ -1775,7 +1771,7 @@ mod test { #[test] #[allow(clippy::cast_possible_truncation)] - fn get_active_verifiers_should_not_return_less_than_min() { + fn active_verifiers_should_not_return_less_than_min() { let mut deps = setup(); let verifiers = vec![Addr::unchecked("verifier1"), Addr::unchecked("verifier2")]; @@ -1818,7 +1814,7 @@ mod test { let res = query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: chain_name.clone(), }, @@ -1855,7 +1851,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: chain_name.clone(), }, @@ -1878,7 +1874,7 @@ mod test { let res = query( deps.as_ref(), mock_env(), - QueryMsg::GetActiveVerifiers { + QueryMsg::ActiveVerifiers { service_name: service_name.into(), chain_name: chain_name.clone(), }, @@ -1984,7 +1980,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifier { + QueryMsg::Verifier { service_name: service_name.into(), verifier: verifier2.to_string(), }, diff --git a/contracts/service-registry/src/contract/query.rs b/contracts/service-registry/src/contract/query.rs index 7748cb027..241bfce10 100644 --- a/contracts/service-registry/src/contract/query.rs +++ b/contracts/service-registry/src/contract/query.rs @@ -3,7 +3,7 @@ use router_api::ChainName; use super::*; use crate::state::{WeightedVerifier, VERIFIERS, VERIFIERS_PER_CHAIN, VERIFIER_WEIGHT}; -pub fn get_active_verifiers( +pub fn active_verifiers( deps: Deps, service_name: String, chain_name: ChainName, @@ -36,7 +36,7 @@ pub fn get_active_verifiers( } } -pub fn get_verifier( +pub fn verifier( deps: Deps, service_name: String, verifier: String, @@ -49,7 +49,7 @@ pub fn get_verifier( .ok_or(ContractError::VerifierNotFound) } -pub fn get_service(deps: Deps, service_name: String) -> Result { +pub fn service(deps: Deps, service_name: String) -> Result { SERVICES .may_load(deps.storage, &service_name)? .ok_or(ContractError::ServiceNotFound) diff --git a/contracts/service-registry/src/msg.rs b/contracts/service-registry/src/msg.rs index 34b3718bd..137db1476 100644 --- a/contracts/service-registry/src/msg.rs +++ b/contracts/service-registry/src/msg.rs @@ -65,16 +65,16 @@ pub enum ExecuteMsg { #[derive(QueryResponses)] pub enum QueryMsg { #[returns(Vec)] - GetActiveVerifiers { + ActiveVerifiers { service_name: String, chain_name: ChainName, }, #[returns(crate::state::Service)] - GetService { service_name: String }, + Service { service_name: String }, #[returns(crate::state::Verifier)] - GetVerifier { + Verifier { service_name: String, verifier: String, }, diff --git a/contracts/voting-verifier/src/client.rs b/contracts/voting-verifier/src/client.rs index a36b3cc67..3b8bf12e7 100644 --- a/contracts/voting-verifier/src/client.rs +++ b/contracts/voting-verifier/src/client.rs @@ -60,7 +60,7 @@ impl<'a> Client<'a> { pub fn poll(&self, poll_id: PollId) -> Result { self.client - .query(&QueryMsg::GetPoll { poll_id }) + .query(&QueryMsg::Poll { poll_id }) .change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone())) } @@ -69,20 +69,20 @@ impl<'a> Client<'a> { [] => Ok(vec![]), _ => self .client - .query(&QueryMsg::GetMessagesStatus { messages }) + .query(&QueryMsg::MessagesStatus { messages }) .change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone())), } } pub fn verifier_set_status(&self, new_verifier_set: VerifierSet) -> Result { self.client - .query(&QueryMsg::GetVerifierSetStatus { new_verifier_set }) + .query(&QueryMsg::VerifierSetStatus { new_verifier_set }) .change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone())) } pub fn current_threshold(&self) -> Result { self.client - .query(&QueryMsg::GetCurrentThreshold) + .query(&QueryMsg::CurrentThreshold) .change_context_lazy(|| Error::QueryVotingVerifier(self.client.address.clone())) } } diff --git a/contracts/voting-verifier/src/contract.rs b/contracts/voting-verifier/src/contract.rs index 19450d871..88aae467e 100644 --- a/contracts/voting-verifier/src/contract.rs +++ b/contracts/voting-verifier/src/contract.rs @@ -68,17 +68,17 @@ pub fn execute( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetPoll { poll_id } => { + QueryMsg::Poll { poll_id } => { to_json_binary(&query::poll_response(deps, env.block.height, poll_id)?) } - QueryMsg::GetMessagesStatus { messages } => { + QueryMsg::MessagesStatus { messages } => { to_json_binary(&query::messages_status(deps, &messages, env.block.height)?) } - QueryMsg::GetVerifierSetStatus { new_verifier_set } => to_json_binary( + QueryMsg::VerifierSetStatus { new_verifier_set } => to_json_binary( &query::verifier_set_status(deps, &new_verifier_set, env.block.height)?, ), - QueryMsg::GetCurrentThreshold => to_json_binary(&query::voting_threshold(deps)?), + QueryMsg::CurrentThreshold => to_json_binary(&query::voting_threshold(deps)?), } } @@ -441,7 +441,7 @@ mod test { query( deps.as_ref(), mock_env_expired(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -562,7 +562,7 @@ mod test { query( deps.as_ref(), mock_env_expired(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -600,7 +600,7 @@ mod test { query( deps.as_ref(), mock_env_expired(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -633,7 +633,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -669,7 +669,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -705,7 +705,7 @@ mod test { query( deps.as_ref(), mock_env_expired(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -785,7 +785,7 @@ mod test { &query( deps.as_ref(), mock_env(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -814,7 +814,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifierSetStatus { + QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }, ) @@ -866,7 +866,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifierSetStatus { + QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }, ) @@ -921,7 +921,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifierSetStatus { + QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }, ) @@ -976,7 +976,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifierSetStatus { + QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }, ) @@ -1023,7 +1023,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetVerifierSetStatus { + QueryMsg::VerifierSetStatus { new_verifier_set: verifier_set.clone(), }, ) @@ -1111,7 +1111,7 @@ mod test { ) .unwrap(); - let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCurrentThreshold).unwrap(); + let res = query(deps.as_ref(), mock_env(), QueryMsg::CurrentThreshold).unwrap(); let threshold: MajorityThreshold = from_json(res).unwrap(); assert_eq!(threshold, new_voting_threshold); @@ -1190,7 +1190,7 @@ mod test { query( deps.as_ref(), mock_env(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) @@ -1281,7 +1281,7 @@ mod test { query( deps.as_ref(), mock_env_expired(), - QueryMsg::GetMessagesStatus { + QueryMsg::MessagesStatus { messages: messages.clone(), }, ) diff --git a/contracts/voting-verifier/src/execute.rs b/contracts/voting-verifier/src/execute.rs index a8d50ce33..d57f9d50c 100644 --- a/contracts/voting-verifier/src/execute.rs +++ b/contracts/voting-verifier/src/execute.rs @@ -56,7 +56,7 @@ pub fn verify_verifier_set( let config = CONFIG.load(deps.storage)?; let snapshot = take_snapshot(deps.as_ref(), &config.source_chain)?; - let participants = snapshot.get_participants(); + let participants = snapshot.participants(); let expires_at = calculate_expiration(env.block.height, config.block_expiry)?; let poll_id = create_verifier_set_poll(deps.storage, expires_at, snapshot)?; @@ -132,7 +132,7 @@ pub fn verify_messages( } let snapshot = take_snapshot(deps.as_ref(), &source_chain)?; - let participants = snapshot.get_participants(); + let participants = snapshot.participants(); let expires_at = calculate_expiration(env.block.height, config.block_expiry)?; let id = create_messages_poll(deps.storage, expires_at, snapshot, msgs_to_verify.len())?; @@ -166,7 +166,7 @@ pub fn verify_messages( )) } -fn get_poll_results(poll: &Poll) -> PollResults { +fn poll_results(poll: &Poll) -> PollResults { match poll { Poll::Messages(weighted_poll) => weighted_poll.results(), Poll::ConfirmVerifierSet(weighted_poll) => weighted_poll.results(), @@ -231,7 +231,7 @@ pub fn vote( .may_load(deps.storage, poll_id)? .ok_or(ContractError::PollNotFound)?; - let results_before_voting = get_poll_results(&poll); + let results_before_voting = poll_results(&poll); let poll = poll.try_map(|poll| { poll.cast_vote(env.block.height, &info.sender, votes.clone()) @@ -239,7 +239,7 @@ pub fn vote( })?; POLLS.save(deps.storage, poll_id, &poll)?; - let results_after_voting = get_poll_results(&poll); + let results_after_voting = poll_results(&poll); let quorum_events = results_after_voting .difference(results_before_voting) @@ -321,7 +321,7 @@ fn take_snapshot(deps: Deps, chain: &ChainName) -> Result)] - GetMessagesStatus { messages: Vec }, + MessagesStatus { messages: Vec }, #[returns(VerificationStatus)] - GetVerifierSetStatus { new_verifier_set: VerifierSet }, + VerifierSetStatus { new_verifier_set: VerifierSet }, #[returns(MajorityThreshold)] - GetCurrentThreshold, + CurrentThreshold, } #[cw_serde] diff --git a/integration-tests/tests/chain_freeze_unfreeze.rs b/integration-tests/tests/chain_freeze_unfreeze.rs index 91fb5cc77..1886c5f9f 100644 --- a/integration-tests/tests/chain_freeze_unfreeze.rs +++ b/integration-tests/tests/chain_freeze_unfreeze.rs @@ -88,7 +88,7 @@ fn chain_can_be_freezed_unfreezed() { // routed message should have been preserved let found_msgs = - test_utils::get_messages_from_gateway(&mut protocol.app, &chain2.gateway, &msg_ids); + test_utils::messages_from_gateway(&mut protocol.app, &chain2.gateway, &msg_ids); assert_eq!(found_msgs, msgs); // can route again diff --git a/integration-tests/tests/message_routing.rs b/integration-tests/tests/message_routing.rs index 98447c62c..1c41efbc6 100644 --- a/integration-tests/tests/message_routing.rs +++ b/integration-tests/tests/message_routing.rs @@ -64,7 +64,7 @@ fn single_message_can_be_verified_and_routed_and_proven_and_rewards_are_distribu // check that the message can be found at the outgoing gateway let found_msgs = - test_utils::get_messages_from_gateway(&mut protocol.app, &chain2.gateway, &msg_ids); + test_utils::messages_from_gateway(&mut protocol.app, &chain2.gateway, &msg_ids); assert_eq!(found_msgs, msgs); // trigger signing and submit all necessary signatures @@ -75,7 +75,7 @@ fn single_message_can_be_verified_and_routed_and_proven_and_rewards_are_distribu &verifiers, ); - let proof = test_utils::get_proof(&mut protocol.app, &chain2.multisig_prover, &session_id); + let proof = test_utils::proof(&mut protocol.app, &chain2.multisig_prover, &session_id); // proof should be complete by now assert!(matches!( diff --git a/integration-tests/tests/test_utils/mod.rs b/integration-tests/tests/test_utils/mod.rs index c8c1729fe..b0bfdbb55 100644 --- a/integration-tests/tests/test_utils/mod.rs +++ b/integration-tests/tests/test_utils/mod.rs @@ -32,7 +32,7 @@ pub const AXL_DENOMINATION: &str = "uaxl"; pub const SIGNATURE_BLOCK_EXPIRY: u64 = 100; -fn get_event_attribute<'a>( +fn find_event_attribute<'a>( events: &'a [Event], event_type: &str, attribute_name: &str, @@ -61,10 +61,10 @@ pub fn verify_messages( let response = response.unwrap(); - let poll_id = get_event_attribute(&response.events, "wasm-messages_poll_started", "poll_id") + let poll_id = find_event_attribute(&response.events, "wasm-messages_poll_started", "poll_id") .map(|attr| serde_json::from_str(&attr.value).unwrap()) .expect("couldn't get poll_id"); - let expiry = get_event_attribute(&response.events, "wasm-messages_poll_started", "expires_at") + let expiry = find_event_attribute(&response.events, "wasm-messages_poll_started", "expires_at") .map(|attr| attr.value.as_str().parse().unwrap()) .expect("couldn't get poll expiry"); (poll_id, expiry) @@ -206,8 +206,8 @@ pub fn construct_proof_and_sign( sign_proof(protocol, verifiers, response.unwrap()) } -pub fn get_multisig_session_id(response: AppResponse) -> Uint64 { - get_event_attribute(&response.events, "wasm-signing_started", "session_id") +pub fn multisig_session_id(response: AppResponse) -> Uint64 { + find_event_attribute(&response.events, "wasm-signing_started", "session_id") .map(|attr| attr.value.as_str().try_into().unwrap()) .expect("couldn't get session_id") } @@ -217,10 +217,10 @@ pub fn sign_proof( verifiers: &Vec, response: AppResponse, ) -> Uint64 { - let msg_to_sign = get_event_attribute(&response.events, "wasm-signing_started", "msg") + let msg_to_sign = find_event_attribute(&response.events, "wasm-signing_started", "msg") .map(|attr| attr.value.clone()) .expect("couldn't find message to sign"); - let session_id = get_multisig_session_id(response); + let session_id = multisig_session_id(response); for verifier in verifiers { let signature = tofn::ecdsa::sign( @@ -271,14 +271,14 @@ pub fn register_service( assert!(response.is_ok()); } -pub fn get_messages_from_gateway( +pub fn messages_from_gateway( app: &mut App, gateway: &GatewayContract, message_ids: &[CrossChainId], ) -> Vec { let query_response: Result, StdError> = gateway.query( app, - &gateway_api::msg::QueryMsg::GetOutgoingMessages { + &gateway_api::msg::QueryMsg::OutgoingMessages { message_ids: message_ids.to_owned(), }, ); @@ -287,15 +287,15 @@ pub fn get_messages_from_gateway( query_response.unwrap() } -pub fn get_proof( +pub fn proof( app: &mut App, multisig_prover: &MultisigProverContract, multisig_session_id: &Uint64, -) -> multisig_prover::msg::GetProofResponse { - let query_response: Result = multisig_prover +) -> multisig_prover::msg::ProofResponse { + let query_response: Result = multisig_prover .query( app, - &multisig_prover::msg::QueryMsg::GetProof { + &multisig_prover::msg::QueryMsg::Proof { multisig_session_id: *multisig_session_id, }, ); @@ -304,7 +304,7 @@ pub fn get_proof( query_response.unwrap() } -pub fn get_verifier_set_from_prover( +pub fn verifier_set_from_prover( app: &mut App, multisig_prover_contract: &MultisigProverContract, ) -> VerifierSet { @@ -493,15 +493,15 @@ pub fn confirm_verifier_set( assert!(response.is_ok()); } -fn get_verifier_set_poll_id_and_expiry(response: AppResponse) -> (PollId, PollExpiryBlock) { - let poll_id = get_event_attribute( +fn verifier_set_poll_id_and_expiry(response: AppResponse) -> (PollId, PollExpiryBlock) { + let poll_id = find_event_attribute( &response.events, "wasm-verifier_set_poll_started", "poll_id", ) .map(|attr| serde_json::from_str(&attr.value).unwrap()) .expect("couldn't get poll_id"); - let expiry = get_event_attribute( + let expiry = find_event_attribute( &response.events, "wasm-verifier_set_poll_started", "expires_at", @@ -533,7 +533,7 @@ pub fn create_verifier_set_poll( ); assert!(response.is_ok()); - get_verifier_set_poll_id_and_expiry(response.unwrap()) + verifier_set_poll_id_and_expiry(response.unwrap()) } pub fn verifiers_to_verifier_set( @@ -784,7 +784,7 @@ pub fn rotate_active_verifier_set( let session_id = sign_proof(protocol, previous_verifiers, response.unwrap()); - let proof = get_proof(&mut protocol.app, &chain.multisig_prover, &session_id); + let proof = proof(&mut protocol.app, &chain.multisig_prover, &session_id); assert!(matches!( proof.status, multisig_prover::msg::ProofStatus::Completed { .. } diff --git a/integration-tests/tests/update_worker_set.rs b/integration-tests/tests/update_worker_set.rs index 7746d571a..15fd1c72e 100644 --- a/integration-tests/tests/update_worker_set.rs +++ b/integration-tests/tests/update_worker_set.rs @@ -5,7 +5,7 @@ use multisig_prover::msg::ExecuteMsg; use service_registry::msg::QueryMsg as ServiceRegistryQueryMsg; use service_registry::state::WeightedVerifier; use test_utils::{ - create_new_verifiers_vec, get_multisig_session_id, register_in_service_registry, + create_new_verifiers_vec, multisig_session_id, register_in_service_registry, register_verifiers, rotate_active_verifier_set, Verifier, }; @@ -30,7 +30,7 @@ fn verifier_set_can_be_initialized_and_then_manually_updated() { test_utils::verifiers_to_verifier_set(&mut protocol, &initial_verifiers); let verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(verifier_set, simulated_verifier_set); @@ -70,7 +70,7 @@ fn verifier_set_can_be_initialized_and_then_manually_updated() { // sign with old verifiers let session_id = test_utils::sign_proof(&mut protocol, &initial_verifiers, response); - let proof = test_utils::get_proof(&mut protocol.app, ðereum.multisig_prover, &session_id); + let proof = test_utils::proof(&mut protocol.app, ðereum.multisig_prover, &session_id); assert!(matches!( proof.status, multisig_prover::msg::ProofStatus::Completed { .. } @@ -104,7 +104,7 @@ fn verifier_set_can_be_initialized_and_then_manually_updated() { ); let new_verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(new_verifier_set, expected_new_verifier_set); } @@ -126,7 +126,7 @@ fn verifier_set_cannot_be_updated_again_while_pending_verifier_is_not_yet_confir test_utils::verifiers_to_verifier_set(&mut protocol, &initial_verifiers); let verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(verifier_set, simulated_verifier_set); @@ -160,7 +160,7 @@ fn verifier_set_cannot_be_updated_again_while_pending_verifier_is_not_yet_confir let session_id = test_utils::sign_proof(&mut protocol, &initial_verifiers, response); - let proof = test_utils::get_proof(&mut protocol.app, ðereum.multisig_prover, &session_id); + let proof = test_utils::proof(&mut protocol.app, ðereum.multisig_prover, &session_id); // proof must be completed assert!(matches!( @@ -206,7 +206,7 @@ fn verifier_set_cannot_be_updated_again_while_pending_verifier_is_not_yet_confir ); let new_verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(new_verifier_set, expected_new_verifier_set); @@ -246,7 +246,7 @@ fn verifier_set_update_can_be_resigned() { test_utils::verifiers_to_verifier_set(&mut protocol, &initial_verifiers); let verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(verifier_set, simulated_verifier_set); @@ -275,7 +275,7 @@ fn verifier_set_update_can_be_resigned() { ) .unwrap(); - let first_session_id = get_multisig_session_id(response.clone()); + let first_session_id = multisig_session_id(response.clone()); // signing didn't occur, trigger signing again let response = protocol @@ -288,7 +288,7 @@ fn verifier_set_update_can_be_resigned() { ) .unwrap(); - let second_session_id = get_multisig_session_id(response.clone()); + let second_session_id = multisig_session_id(response.clone()); assert_ne!(first_session_id, second_session_id); test_utils::sign_proof(&mut protocol, &initial_verifiers, response); @@ -304,13 +304,13 @@ fn verifier_set_update_can_be_resigned() { ) .unwrap(); - let third_session_id = get_multisig_session_id(response.clone()); + let third_session_id = multisig_session_id(response.clone()); assert_ne!(first_session_id, second_session_id); assert_ne!(second_session_id, third_session_id); test_utils::sign_proof(&mut protocol, &initial_verifiers, response); - let proof = test_utils::get_proof( + let proof = test_utils::proof( &mut protocol.app, ðereum.multisig_prover, &second_session_id, @@ -367,7 +367,7 @@ fn governance_should_confirm_new_verifier_set_without_verification() { ); let new_verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, ðereum.multisig_prover); assert_eq!(new_verifier_set, expected_new_verifier_set); } @@ -415,7 +415,7 @@ fn rotate_signers_should_filter_out_signers_without_pubkey() { .service_registry .query( &protocol.app, - &ServiceRegistryQueryMsg::GetActiveVerifiers { + &ServiceRegistryQueryMsg::ActiveVerifiers { service_name: protocol.service_name.to_string(), chain_name: chains[0].clone(), }, @@ -436,7 +436,7 @@ fn rotate_signers_should_filter_out_signers_without_pubkey() { ); let verifier_set = - test_utils::get_verifier_set_from_prover(&mut protocol.app, &chain1.multisig_prover); + test_utils::verifier_set_from_prover(&mut protocol.app, &chain1.multisig_prover); assert_eq!(verifier_set, expected_verifier_set); } diff --git a/packages/axelar-wasm-std/src/counter.rs b/packages/axelar-wasm-std/src/counter.rs index 05a709663..90ff709e8 100644 --- a/packages/axelar-wasm-std/src/counter.rs +++ b/packages/axelar-wasm-std/src/counter.rs @@ -38,7 +38,7 @@ mod tests { use super::*; #[test] - fn test_get_and_incr() { + fn test_cur_and_incr() { let mut store = MockStorage::new(); let counter: Counter = Counter::new("counter"); diff --git a/packages/axelar-wasm-std/src/snapshot.rs b/packages/axelar-wasm-std/src/snapshot.rs index 1487a42d6..165966f6b 100644 --- a/packages/axelar-wasm-std/src/snapshot.rs +++ b/packages/axelar-wasm-std/src/snapshot.rs @@ -45,7 +45,7 @@ impl Snapshot { } } - pub fn get_participants(&self) -> Vec { + pub fn participants(&self) -> Vec { self.participants .keys() .cloned() @@ -53,7 +53,7 @@ impl Snapshot { .collect() } - pub fn get_participant(&self, participant: &Addr) -> Option<&Participant> { + pub fn find(&self, participant: &Addr) -> Option<&Participant> { self.participants.get(&participant.to_string()) } } diff --git a/packages/gateway-api/src/msg.rs b/packages/gateway-api/src/msg.rs index 2911c2e3d..51c3dd850 100644 --- a/packages/gateway-api/src/msg.rs +++ b/packages/gateway-api/src/msg.rs @@ -21,5 +21,5 @@ pub enum ExecuteMsg { pub enum QueryMsg { // messages that can be relayed to the chain corresponding to this gateway #[returns(Vec)] - GetOutgoingMessages { message_ids: Vec }, + OutgoingMessages { message_ids: Vec }, } diff --git a/packages/router-api/src/msg.rs b/packages/router-api/src/msg.rs index 57c43f7af..05cbe8bce 100644 --- a/packages/router-api/src/msg.rs +++ b/packages/router-api/src/msg.rs @@ -51,7 +51,7 @@ pub enum ExecuteMsg { #[derive(QueryResponses)] pub enum QueryMsg { #[returns(ChainEndpoint)] - GetChainInfo(ChainName), + ChainInfo(ChainName), // Returns a list of chains registered with the router // The list is paginated by: