Skip to content

Commit

Permalink
refactor(connection-router-api): replace dependencies of connection-r…
Browse files Browse the repository at this point in the history
…outer with connection-router-api (#273)

* refactor(connection-router-api): replace dependencies of connection-router with connection-router-api

* fix linting
  • Loading branch information
fish-sammy authored Feb 21, 2024
1 parent 6e5157f commit 70f6283
Show file tree
Hide file tree
Showing 86 changed files with 326 additions and 779 deletions.
20 changes: 11 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ base64 = "0.21.2"
bcs = "0.1.5"
clap = { version = "4.2.7", features = ["derive", "cargo"] }
config = "0.13.2"
connection-router = { workspace = true }
connection-router-api = { workspace = true }
cosmos-sdk-proto = "0.16.0"
cosmrs = { version = "0.14.0", features = ["cosmwasm"] }
cosmwasm-std = { version = "1.2.1", features = ["stargate"] }
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/commands/deregister_chain_support.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;

use axelar_wasm_std::nonempty;
use connection_router::state::ChainName;
use connection_router_api::ChainName;
use cosmrs::cosmwasm::MsgExecuteContract;
use cosmrs::tx::Msg;
use error_stack::Result;
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/commands/register_chain_support.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;

use axelar_wasm_std::nonempty;
use connection_router::state::ChainName;
use connection_router_api::ChainName;
use cosmrs::cosmwasm::MsgExecuteContract;
use cosmrs::tx::Msg;
use error_stack::Result;
Expand Down
10 changes: 6 additions & 4 deletions ampd/src/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ pub enum ChainName {
Other(String),
}

impl PartialEq<connection_router::state::ChainName> for ChainName {
fn eq(&self, other: &connection_router::state::ChainName) -> bool {
impl PartialEq<connection_router_api::ChainName> for ChainName {
fn eq(&self, other: &connection_router_api::ChainName) -> bool {
self.to_string().eq_ignore_ascii_case(other.as_ref())
}
}

#[cfg(test)]
mod tests {
use crate::evm;
use connection_router::state::ChainName;
use std::str::FromStr;

use connection_router_api::ChainName;

use crate::evm;

#[test]
fn chain_name_partial_eq() {
let chain_name = evm::ChainName::Ethereum;
Expand Down
6 changes: 3 additions & 3 deletions ampd/src/handlers/evm_verify_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::{info, info_span};
use valuable::Valuable;

use axelar_wasm_std::voting::{PollId, Vote};
use connection_router::state::ID_SEPARATOR;
use connection_router_api::ID_SEPARATOR;
use events::Error::EventTypeMismatch;
use events_derive::try_from;
use voting_verifier::msg::ExecuteMsg;
Expand All @@ -33,7 +33,7 @@ pub struct Message {
pub tx_id: Hash,
pub event_index: u64,
pub destination_address: String,
pub destination_chain: connection_router::state::ChainName,
pub destination_chain: connection_router_api::ChainName,
pub source_address: EVMAddress,
pub payload_hash: Hash,
}
Expand All @@ -42,7 +42,7 @@ pub struct Message {
#[try_from("wasm-messages_poll_started")]
struct PollStartedEvent {
poll_id: PollId,
source_chain: connection_router::state::ChainName,
source_chain: connection_router_api::ChainName,
source_gateway_address: EVMAddress,
confirmation_height: u64,
expires_at: u64,
Expand Down
4 changes: 2 additions & 2 deletions ampd/src/handlers/evm_verify_worker_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use events::Error::EventTypeMismatch;
use events_derive::try_from;

use axelar_wasm_std::voting::{PollId, Vote};
use connection_router::state::ID_SEPARATOR;
use connection_router_api::ID_SEPARATOR;
use voting_verifier::msg::ExecuteMsg;

use crate::event_processor::EventHandler;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub struct WorkerSetConfirmation {
struct PollStartedEvent {
worker_set: WorkerSetConfirmation,
poll_id: PollId,
source_chain: connection_router::state::ChainName,
source_chain: connection_router_api::ChainName,
source_gateway_address: EVMAddress,
expires_at: u64,
confirmation_height: u64,
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/handlers/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mod test {

use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use connection_router::state::ChainName;
use connection_router_api::ChainName;
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::{AccountId, Gas};
use cosmwasm_std::{HexBinary, Uint64};
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/handlers/sui_verify_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Message {
pub tx_id: TransactionDigest,
pub event_index: u64,
pub destination_address: String,
pub destination_chain: connection_router::state::ChainName,
pub destination_chain: connection_router_api::ChainName,
pub source_address: SuiAddress,
pub payload_hash: Hash,
}
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/handlers/sui_verify_worker_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::sync::watch::Receiver;
use tracing::{info, info_span};

use axelar_wasm_std::voting::{PollId, Vote};
use connection_router::state::ID_SEPARATOR;
use connection_router_api::ID_SEPARATOR;
use cosmwasm_std::HexBinary;
use cosmwasm_std::Uint128;
use events::{Error::EventTypeMismatch, Event};
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/sui/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn verify_worker_set(
#[cfg(test)]
mod tests {
use axelar_wasm_std::voting::Vote;
use connection_router::state::ChainName;
use connection_router_api::ChainName;
use cosmwasm_std::HexBinary;
use ethers::abi::AbiEncode;
use move_core_types::language_storage::StructTag;
Expand Down
2 changes: 1 addition & 1 deletion contracts/aggregate-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \
[dependencies]
axelar-wasm-std = { workspace = true }
axelar-wasm-std-derive = { workspace = true }
connection-router = { workspace = true, features = ["library"] }
connection-router-api = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
Expand Down
5 changes: 2 additions & 3 deletions contracts/aggregate-verifier/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use axelar_wasm_std::utils::TryMapExt;
use axelar_wasm_std::{FnExt, VerificationStatus};
use connection_router::state::CrossChainId;
use connection_router::Message;
use connection_router_api::{CrossChainId, Message};
use cosmwasm_std::{to_binary, Addr, QuerierWrapper, QueryRequest, WasmMsg, WasmQuery};
use error_stack::{Result, ResultExt};
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -91,7 +90,7 @@ pub enum Error {
#[cfg(test)]
mod tests {
use axelar_wasm_std::VerificationStatus;
use connection_router::state::CrossChainId;
use connection_router_api::CrossChainId;
use cosmwasm_std::testing::MockQuerier;
use std::str::FromStr;

Expand Down
4 changes: 2 additions & 2 deletions contracts/aggregate-verifier/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axelar_wasm_std::VerificationStatus;
use connection_router::state::CrossChainId;
use connection_router_api::CrossChainId;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn execute(
pub mod execute {
use cosmwasm_std::{to_binary, SubMsg, WasmMsg};

use connection_router::state::Message;
use connection_router_api::Message;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion contracts/aggregate-verifier/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub enum ContractError {
Std(#[from] StdError),

#[error(transparent)]
RouterError(#[from] connection_router::ContractError),
RouterError(#[from] connection_router_api::error::Error),

#[error("received invalid verifier reply: {0}")]
InvalidVerifierReply(String),
Expand Down
4 changes: 2 additions & 2 deletions contracts/aggregate-verifier/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axelar_wasm_std::VerificationStatus;
use connection_router::state::Message;
use connection_router_api::Message;
use cosmwasm_schema::{cw_serde, QueryResponses};

#[cw_serde]
Expand All @@ -16,6 +16,6 @@ pub enum ExecuteMsg {
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(Vec<(connection_router::state::CrossChainId, VerificationStatus)>)]
#[returns(Vec<(connection_router_api::CrossChainId, VerificationStatus)>)]
GetMessagesStatus { messages: Vec<Message> },
}
2 changes: 1 addition & 1 deletion contracts/aggregate-verifier/tests/mock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use aggregate_verifier::error::ContractError;
use axelar_wasm_std::VerificationStatus;
use connection_router::state::{CrossChainId, Message};
use connection_router_api::{CrossChainId, Message};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{to_binary, Addr, DepsMut, Env, MessageInfo, Response};
use cw_multi_test::{App, ContractWrapper, Executor};
Expand Down
2 changes: 1 addition & 1 deletion contracts/aggregate-verifier/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use aggregate_verifier::msg::ExecuteMsg;
use axelar_wasm_std::VerificationStatus;
use connection_router::state::{CrossChainId, Message, ID_SEPARATOR};
use connection_router_api::{CrossChainId, Message, ID_SEPARATOR};
use cosmwasm_std::from_binary;
use cosmwasm_std::Addr;
use cw_multi_test::{App, Executor};

Check warning on line 6 in contracts/aggregate-verifier/tests/test.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `Executor`
Expand Down
1 change: 1 addition & 0 deletions contracts/connection-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \
[dependencies]
axelar-wasm-std = { workspace = true }
axelar-wasm-std-derive = { workspace = true }
connection-router-api = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion contracts/connection-router/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use connection_router_api::msg::{ExecuteMsg, QueryMsg};
use cosmwasm_schema::write_api;

use connection_router::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use connection_router::msg::InstantiateMsg;

fn main() {
write_api! {
Expand Down
3 changes: 2 additions & 1 deletion contracts/connection-router/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use connection_router_api::msg::{ExecuteMsg, QueryMsg};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};

use crate::events::RouterInstantiated;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::msg::InstantiateMsg;
use crate::state::{Config, RouterStore, Store};

mod execute;
Expand Down
Loading

0 comments on commit 70f6283

Please sign in to comment.