From a0527da2ec656a5eabb705e3d4ac92b518420639 Mon Sep 17 00:00:00 2001 From: haiyizxx Date: Mon, 21 Oct 2024 18:10:08 +0800 Subject: [PATCH] feat(minor-router): route to axelarnet gateway (#657) --- Cargo.lock | 1 + contracts/router/Cargo.toml | 1 + contracts/router/src/contract.rs | 35 +-- contracts/router/src/contract/execute.rs | 36 +-- .../router/src/contract/migrations/mod.rs | 2 +- .../router/src/contract/migrations/v0_3_3.rs | 238 ------------------ .../router/src/contract/migrations/v1_0_1.rs | 94 +++++++ contracts/router/src/events.rs | 2 +- contracts/router/src/msg.rs | 9 +- contracts/router/src/state.rs | 2 +- integration-tests/src/router_contract.rs | 4 +- integration-tests/tests/test_utils/mod.rs | 4 +- 12 files changed, 149 insertions(+), 279 deletions(-) delete mode 100644 contracts/router/src/contract/migrations/v0_3_3.rs create mode 100644 contracts/router/src/contract/migrations/v1_0_1.rs diff --git a/Cargo.lock b/Cargo.lock index b91ed0473..4677d98fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6834,6 +6834,7 @@ dependencies = [ name = "router" version = "1.0.1" dependencies = [ + "assert_ok", "axelar-core-std", "axelar-wasm-std", "client", diff --git a/contracts/router/Cargo.toml b/contracts/router/Cargo.toml index 094ecbc75..d63af4721 100644 --- a/contracts/router/Cargo.toml +++ b/contracts/router/Cargo.toml @@ -51,6 +51,7 @@ serde_json = { workspace = true } thiserror = { workspace = true } [dev-dependencies] +assert_ok = { workspace = true } axelar-core-std = { workspace = true, features = ["test"] } cw-multi-test = "0.15.1" hex = { version = "0.4.3", default-features = false } diff --git a/contracts/router/src/contract.rs b/contracts/router/src/contract.rs index 9b868fab3..98a8a0472 100644 --- a/contracts/router/src/contract.rs +++ b/contracts/router/src/contract.rs @@ -2,13 +2,13 @@ use axelar_wasm_std::{address, killswitch, permission_control, FnExt}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, Storage, + to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, Storage, }; use router_api::error::Error; -use crate::contract::migrations::v0_3_3; +use crate::contract::migrations::v1_0_1; use crate::events::RouterInstantiated; -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use crate::state; use crate::state::{load_chain_by_gateway, load_config, Config}; @@ -18,13 +18,18 @@ mod query; pub const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +const BASE_VERSION: &str = "1.0.1"; + #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate( deps: DepsMut, _env: Env, - _msg: Empty, + msg: MigrateMsg, ) -> Result { - v0_3_3::migrate(deps.storage)?; + cw2::assert_contract_version(deps.storage, CONTRACT_NAME, BASE_VERSION)?; + + let axelarnet_gateway = address::validate_cosmwasm_address(deps.api, &msg.axelarnet_gateway)?; + v1_0_1::migrate(deps.storage, axelarnet_gateway)?; // this needs to be the last thing to do during migration, // because previous migration steps should check the old version @@ -44,13 +49,13 @@ pub fn instantiate( let admin = address::validate_cosmwasm_address(deps.api, &msg.admin_address)?; let governance = address::validate_cosmwasm_address(deps.api, &msg.governance_address)?; - let nexus_gateway = address::validate_cosmwasm_address(deps.api, &msg.nexus_gateway)?; + let axelarnet_gateway = address::validate_cosmwasm_address(deps.api, &msg.axelarnet_gateway)?; permission_control::set_admin(deps.storage, &admin)?; permission_control::set_governance(deps.storage, &governance)?; let config = Config { - nexus_gateway: nexus_gateway.clone(), + axelarnet_gateway: axelarnet_gateway.clone(), }; state::save_config(deps.storage, &config)?; @@ -60,7 +65,7 @@ pub fn instantiate( RouterInstantiated { admin, governance, - nexus_gateway, + axelarnet_gateway, } .into(), )) @@ -114,9 +119,9 @@ fn find_gateway_address( sender: &Addr, ) -> impl FnOnce(&dyn Storage, &ExecuteMsg) -> error_stack::Result + '_ { move |storage, _| { - let nexus_gateway = load_config(storage)?.nexus_gateway; - if nexus_gateway == sender { - Ok(nexus_gateway) + let axelarnet_gateway = load_config(storage)?.axelarnet_gateway; + if axelarnet_gateway == sender { + Ok(axelarnet_gateway) } else { load_chain_by_gateway(storage, sender)? .gateway @@ -166,7 +171,7 @@ mod test { const ADMIN_ADDRESS: &str = "admin"; const GOVERNANCE_ADDRESS: &str = "governance"; - const NEXUS_GATEWAY_ADDRESS: &str = "nexus_gateway"; + const AXELARNET_GATEWAY_ADDRESS: &str = "axelarnet_gateway"; const UNAUTHORIZED_ADDRESS: &str = "unauthorized"; fn setup() -> OwnedDeps { @@ -182,7 +187,7 @@ mod test { InstantiateMsg { admin_address: ADMIN_ADDRESS.to_string(), governance_address: GOVERNANCE_ADDRESS.to_string(), - nexus_gateway: NEXUS_GATEWAY_ADDRESS.to_string(), + axelarnet_gateway: AXELARNET_GATEWAY_ADDRESS.to_string(), }, ) .unwrap(); @@ -368,7 +373,7 @@ mod test { let result = execute( deps.as_mut(), mock_env(), - mock_info(NEXUS_GATEWAY_ADDRESS, &[]), + mock_info(AXELARNET_GATEWAY_ADDRESS, &[]), ExecuteMsg::RouteMessages(messages.clone()), ); assert!(result.is_ok()); @@ -1805,7 +1810,7 @@ mod test { assert!(execute( deps.as_mut(), mock_env(), - mock_info(NEXUS_GATEWAY_ADDRESS, &[]), + mock_info(AXELARNET_GATEWAY_ADDRESS, &[]), ExecuteMsg::RouteMessages(generate_messages(ð, &polygon, &mut 0, 10)), ) .is_ok()); diff --git a/contracts/router/src/contract/execute.rs b/contracts/router/src/contract/execute.rs index 005b44d90..08334bd78 100644 --- a/contracts/router/src/contract/execute.rs +++ b/contracts/router/src/contract/execute.rs @@ -184,7 +184,7 @@ fn validate_msgs( // because the source chain is registered in the core nexus module. // All messages received from the nexus gateway must adhere to the // HexTxHashAndEventIndex message ID format. - if sender == config.nexus_gateway { + if sender == config.axelarnet_gateway { verify_msg_ids(&msgs, &MessageIdFormat::HexTxHashAndEventIndex)?; return Ok(msgs); } @@ -235,9 +235,9 @@ pub fn route_messages( } Some(destination_chain) => destination_chain.gateway.address, // messages with unknown destination chains are routed to - // the nexus gateway if the sender is not the nexus gateway + // the axelarnet gateway if the sender is not the nexus gateway // itself - None if sender != config.nexus_gateway => config.nexus_gateway.clone(), + None if sender != config.axelarnet_gateway => config.axelarnet_gateway.clone(), _ => return Err(report!(Error::ChainNotFound)), }; @@ -278,6 +278,8 @@ mod test { use crate::msg::InstantiateMsg; use crate::state::chain_endpoints; + const AXELARNET_GATEWAY: &str = "axelarnet_gateway"; + fn rand_message(source_chain: ChainName, destination_chain: ChainName) -> Message { let mut bytes = [0; 32]; rand::thread_rng().fill_bytes(&mut bytes); @@ -322,7 +324,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -349,7 +351,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -390,7 +392,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -429,7 +431,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -484,7 +486,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -513,7 +515,7 @@ mod test { #[test] fn route_messages_from_nexus_with_invalid_message_id() { - let sender = Addr::unchecked("nexus_gateway"); + let sender = Addr::unchecked(AXELARNET_GATEWAY); let source_chain: ChainName = "ethereum".parse().unwrap(); let destination_chain: ChainName = "bitcoin".parse().unwrap(); @@ -525,7 +527,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -550,7 +552,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -602,7 +604,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -668,7 +670,7 @@ mod test { #[test] fn route_messages_from_nexus_to_registered_chains() { - let sender = Addr::unchecked("nexus_gateway"); + let sender = Addr::unchecked(AXELARNET_GATEWAY); let source_chain: ChainName = "ethereum".parse().unwrap(); let destination_chain_1: ChainName = "bitcoin".parse().unwrap(); let destination_chain_2: ChainName = "polygon".parse().unwrap(); @@ -681,7 +683,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -732,7 +734,7 @@ mod test { #[test] fn route_messages_from_nexus_to_non_registered_chains() { - let sender = Addr::unchecked("nexus_gateway"); + let sender = Addr::unchecked(AXELARNET_GATEWAY); let source_chain: ChainName = "ethereum".parse().unwrap(); let destination_chain: ChainName = "bitcoin".parse().unwrap(); @@ -744,7 +746,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); @@ -774,7 +776,7 @@ mod test { InstantiateMsg { admin_address: "admin".to_string(), governance_address: "governance".to_string(), - nexus_gateway: "nexus_gateway".to_string(), + axelarnet_gateway: AXELARNET_GATEWAY.to_string(), }, ) .unwrap(); diff --git a/contracts/router/src/contract/migrations/mod.rs b/contracts/router/src/contract/migrations/mod.rs index ebcb4aab1..45f45da41 100644 --- a/contracts/router/src/contract/migrations/mod.rs +++ b/contracts/router/src/contract/migrations/mod.rs @@ -1 +1 @@ -pub mod v0_3_3; +pub mod v1_0_1; diff --git a/contracts/router/src/contract/migrations/v0_3_3.rs b/contracts/router/src/contract/migrations/v0_3_3.rs deleted file mode 100644 index 01196aafd..000000000 --- a/contracts/router/src/contract/migrations/v0_3_3.rs +++ /dev/null @@ -1,238 +0,0 @@ -#![allow(deprecated)] - -use axelar_wasm_std::error::ContractError; -use axelar_wasm_std::{killswitch, permission_control}; -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, StdResult, Storage}; -use cw_storage_plus::Item; -use router_api::error::Error; - -use crate::contract::CONTRACT_NAME; -use crate::state; - -const BASE_VERSION: &str = "0.3.3"; - -pub fn migrate(storage: &mut dyn Storage) -> Result<(), ContractError> { - cw2::assert_contract_version(storage, CONTRACT_NAME, BASE_VERSION)?; - - set_generalized_permission_control(storage)?; - set_router_state(storage)?; - Ok(()) -} - -#[deprecated(since = "0.3.3", note = "only used during migration")] -#[cw_serde] -struct Config { - pub admin: Addr, - pub governance: Addr, - pub nexus_gateway: Addr, -} - -fn set_generalized_permission_control(storage: &mut dyn Storage) -> Result<(), Error> { - let old_config = CONFIG.load(storage)?; - permission_control::set_admin(storage, &old_config.admin) - .and_then(|_| permission_control::set_governance(storage, &old_config.governance)) - .map_err(Error::from)?; - - let new_config = &state::Config { - nexus_gateway: old_config.nexus_gateway, - }; - state::CONFIG.save(storage, new_config)?; - Ok(()) -} - -fn set_router_state(storage: &mut dyn Storage) -> StdResult<()> { - killswitch::init(storage, killswitch::State::Disengaged) -} - -#[deprecated(since = "0.3.3", note = "only used during migration")] -const CONFIG: Item = Item::new("config"); - -#[cfg(test)] -mod test { - use std::collections::HashMap; - - use axelar_core_std::nexus::test_utils::reply_with_is_chain_registered; - use axelar_wasm_std::error::ContractError; - use axelar_wasm_std::killswitch; - use axelar_wasm_std::msg_id::MessageIdFormat; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{DepsMut, Env, MessageInfo, Response}; - use router_api::msg::ExecuteMsg; - - use crate::contract::migrations::v0_3_3; - use crate::contract::migrations::v0_3_3::BASE_VERSION; - use crate::contract::{execute, CONTRACT_NAME}; - use crate::events::RouterInstantiated; - use crate::msg::InstantiateMsg; - use crate::state; - - #[test] - fn migrate_checks_contract_version() { - let mut deps = mock_dependencies(); - let _ = instantiate_0_3_3_contract(deps.as_mut()).unwrap(); - cw2::set_contract_version(deps.as_mut().storage, CONTRACT_NAME, "something wrong").unwrap(); - - assert!(v0_3_3::migrate(deps.as_mut().storage).is_err()); - - cw2::set_contract_version(deps.as_mut().storage, CONTRACT_NAME, BASE_VERSION).unwrap(); - - assert!(v0_3_3::migrate(deps.as_mut().storage).is_ok()); - } - - #[test] - fn config_gets_migrated() { - let mut deps = mock_dependencies(); - let instantiate_msg = instantiate_0_3_3_contract(deps.as_mut()).unwrap(); - - assert!(v0_3_3::CONFIG.load(deps.as_mut().storage).is_ok()); - assert!(state::CONFIG.load(deps.as_mut().storage).is_err()); - - assert!(v0_3_3::migrate(deps.as_mut().storage).is_ok()); - - assert!(v0_3_3::CONFIG.load(deps.as_mut().storage).is_err()); - let config = state::CONFIG.load(deps.as_mut().storage); - assert!(config.is_ok()); - assert!(config.unwrap().nexus_gateway == instantiate_msg.nexus_gateway); - } - - #[test] - fn router_is_enabled() { - let mut deps = mock_dependencies(); - let _ = instantiate_0_3_3_contract(deps.as_mut()).unwrap(); - - assert!(v0_3_3::migrate(deps.as_mut().storage).is_ok()); - - assert!(killswitch::is_contract_active(deps.as_mut().storage)); - } - - #[test] - fn migration() { - let mut deps = mock_dependencies(); - deps.querier = deps - .querier - .with_custom_handler(reply_with_is_chain_registered(false)); - - let instantiate_msg = instantiate_0_3_3_contract(deps.as_mut()).unwrap(); - - let msg = ExecuteMsg::RegisterChain { - chain: "chain".parse().unwrap(), - gateway_address: "gateway".parse().unwrap(), - msg_id_format: MessageIdFormat::HexTxHashAndEventIndex, - }; - - // before migration no address should be able to execute this message - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(&instantiate_msg.admin_address, &[]), - msg.clone(), - ) - .is_err()); - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(&instantiate_msg.governance_address, &[]), - msg.clone(), - ) - .is_err()); - - assert!(v0_3_3::migrate(&mut deps.storage).is_ok()); - - // after migration only governance should be able to register a chain - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(&instantiate_msg.admin_address, &[]), - msg.clone(), - ) - .is_err()); - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(&instantiate_msg.governance_address, &[]), - msg.clone(), - ) - .is_ok()); - - // check that both admin and governance permissions are set correctly - - let msg = ExecuteMsg::UnfreezeChains { - chains: HashMap::new(), - }; - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info("no_privilege", &[]), - msg.clone(), - ) - .is_err()); - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(instantiate_msg.admin_address.as_str(), &[]), - msg.clone(), - ) - .is_ok()); - - assert!(execute( - deps.as_mut(), - mock_env(), - mock_info(instantiate_msg.governance_address.as_str(), &[]), - msg.clone(), - ) - .is_ok()); - } - - fn instantiate_0_3_3_contract(deps: DepsMut) -> Result { - let admin = "admin"; - let governance = "governance"; - let nexus_gateway = "nexus_gateway"; - - let msg = InstantiateMsg { - nexus_gateway: nexus_gateway.to_string(), - admin_address: admin.to_string(), - governance_address: governance.to_string(), - }; - instantiate(deps, mock_env(), mock_info(admin, &[]), msg.clone())?; - Ok(msg) - } - - #[deprecated(since = "0.3.3", note = "only used to test the migration")] - fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - msg: InstantiateMsg, - ) -> Result { - cw2::set_contract_version(deps.storage, CONTRACT_NAME, BASE_VERSION)?; - - let admin = deps.api.addr_validate(&msg.admin_address)?; - let governance = deps.api.addr_validate(&msg.governance_address)?; - let nexus_gateway = deps.api.addr_validate(&msg.nexus_gateway)?; - - let config = v0_3_3::Config { - admin: admin.clone(), - governance: governance.clone(), - nexus_gateway: nexus_gateway.clone(), - }; - - v0_3_3::CONFIG - .save(deps.storage, &config) - .expect("must save the config"); - - Ok(Response::new().add_event( - RouterInstantiated { - admin, - governance, - nexus_gateway, - } - .into(), - )) - } -} diff --git a/contracts/router/src/contract/migrations/v1_0_1.rs b/contracts/router/src/contract/migrations/v1_0_1.rs new file mode 100644 index 000000000..0f06b160a --- /dev/null +++ b/contracts/router/src/contract/migrations/v1_0_1.rs @@ -0,0 +1,94 @@ +use axelar_wasm_std::error::ContractError; +use cosmwasm_std::{Addr, Storage}; + +use crate::state; + +pub fn migrate(storage: &mut dyn Storage, axelarnet_gateway: Addr) -> Result<(), ContractError> { + // migrate config + state::save_config(storage, &state::Config { axelarnet_gateway }).map_err(Into::into) +} +#[cfg(test)] +mod test { + #![allow(deprecated)] + + use assert_ok::assert_ok; + use axelar_wasm_std::error::ContractError; + use cosmwasm_schema::cw_serde; + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + use cosmwasm_std::{Addr, DepsMut, Env, MessageInfo, Response}; + use cw_storage_plus::Item; + + use crate::contract::migrations::v1_0_1; + use crate::state; + + #[deprecated(since = "1.0.1", note = "only used during migration")] + #[cw_serde] + pub struct InstantiateMsg { + // admin controls freezing and unfreezing a chain + pub admin_address: String, + // governance votes on chains being added or upgraded + pub governance_address: String, + // the address of the nexus gateway + pub nexus_gateway: String, + } + + #[deprecated(since = "1.0.1", note = "only used during migration")] + #[cw_serde] + struct Config { + pub nexus_gateway: Addr, + } + + #[deprecated(since = "1.0.1", note = "only used during migration")] + const CONFIG: Item = Item::new("config"); + + #[test] + fn config_gets_migrated() { + let mut deps = mock_dependencies(); + instantiate_1_0_1_contract(deps.as_mut()).unwrap(); + + assert_ok!(CONFIG.load(deps.as_mut().storage)); + assert!(state::load_config(&deps.storage).is_err()); + + let axelarnet_gateway = Addr::unchecked("axelarnet-gateway"); + assert_ok!(v1_0_1::migrate( + deps.as_mut().storage, + axelarnet_gateway.clone() + )); + assert!(CONFIG.load(deps.as_mut().storage).is_err()); + + let config = assert_ok!(state::CONFIG.load(deps.as_mut().storage)); + assert_eq!(config.axelarnet_gateway, axelarnet_gateway); + } + + fn instantiate_1_0_1_contract(deps: DepsMut) -> Result { + let admin = "admin"; + let governance = "governance"; + let nexus_gateway = "nexus_gateway"; + + let msg = InstantiateMsg { + admin_address: admin.to_string(), + governance_address: governance.to_string(), + nexus_gateway: nexus_gateway.to_string(), + }; + + instantiate(deps, mock_env(), mock_info(admin, &[]), msg.clone()) + } + + #[deprecated(since = "1.0.1", note = "only used to test the migration")] + fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: InstantiateMsg, + ) -> Result { + let config = Config { + nexus_gateway: deps.api.addr_validate(&msg.nexus_gateway)?, + }; + + CONFIG + .save(deps.storage, &config) + .expect("must save the config"); + + Ok(Response::new()) + } +} diff --git a/contracts/router/src/events.rs b/contracts/router/src/events.rs index 29c0c85a0..b0097a58a 100644 --- a/contracts/router/src/events.rs +++ b/contracts/router/src/events.rs @@ -4,7 +4,7 @@ use router_api::{ChainName, GatewayDirection, Message}; pub struct RouterInstantiated { pub admin: Addr, pub governance: Addr, - pub nexus_gateway: Addr, + pub axelarnet_gateway: Addr, } pub struct ChainRegistered { diff --git a/contracts/router/src/msg.rs b/contracts/router/src/msg.rs index 4d1ac97fe..6a66c0bfe 100644 --- a/contracts/router/src/msg.rs +++ b/contracts/router/src/msg.rs @@ -6,8 +6,13 @@ pub struct InstantiateMsg { pub admin_address: String, // governance votes on chains being added or upgraded pub governance_address: String, - // the address of the nexus gateway - pub nexus_gateway: String, + // the address of the axelarnet gateway + pub axelarnet_gateway: String, +} + +#[cw_serde] +pub struct MigrateMsg { + pub axelarnet_gateway: String, } // these messages are extracted into a separate package to avoid circular dependencies diff --git a/contracts/router/src/state.rs b/contracts/router/src/state.rs index ca014106c..c22379dd6 100644 --- a/contracts/router/src/state.rs +++ b/contracts/router/src/state.rs @@ -37,7 +37,7 @@ pub fn load_chain_by_gateway( #[cw_serde] pub struct Config { - pub nexus_gateway: Addr, + pub axelarnet_gateway: Addr, } pub const CONFIG: Item = Item::new("config"); diff --git a/integration-tests/src/router_contract.rs b/integration-tests/src/router_contract.rs index 30ec0e671..b8354f718 100644 --- a/integration-tests/src/router_contract.rs +++ b/integration-tests/src/router_contract.rs @@ -15,7 +15,7 @@ impl RouterContract { app: &mut AxelarApp, admin: Addr, governance: Addr, - nexus: Addr, + axelarnet: Addr, ) -> Self { let code = ContractWrapper::new_with_empty(execute, instantiate, query); let code_id = app.store_code(Box::new(code)); @@ -27,7 +27,7 @@ impl RouterContract { &router::msg::InstantiateMsg { admin_address: admin.to_string(), governance_address: governance.to_string(), - nexus_gateway: nexus.to_string(), + axelarnet_gateway: axelarnet.to_string(), }, &[], "router", diff --git a/integration-tests/tests/test_utils/mod.rs b/integration-tests/tests/test_utils/mod.rs index f7a378226..599fc2dd2 100644 --- a/integration-tests/tests/test_utils/mod.rs +++ b/integration-tests/tests/test_utils/mod.rs @@ -405,13 +405,13 @@ pub fn setup_protocol(service_name: nonempty::String) -> Protocol { let admin_address = Addr::unchecked("admin"); let governance_address = Addr::unchecked("governance"); - let nexus_gateway = Addr::unchecked("nexus_gateway"); + let axelarnet_gateway = Addr::unchecked("axelarnet_gateway"); let router = RouterContract::instantiate_contract( &mut app, admin_address.clone(), governance_address.clone(), - nexus_gateway.clone(), + axelarnet_gateway.clone(), ); let rewards_params = rewards::msg::Params {