Skip to content

Commit

Permalink
refactor(minor-axelarnet-gateway): msg and state separation (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy authored Feb 21, 2025
1 parent 862d2dc commit fed53af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 0 additions & 11 deletions contracts/axelarnet-gateway/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ use cosmwasm_std::HexBinary;
use msgs_derive::EnsurePermissions;
use router_api::{Address, ChainName, CrossChainId, Message};

use crate::state;

impl From<state::ExecutableMessage> for ExecutableMessage {
fn from(value: state::ExecutableMessage) -> Self {
match value {
state::ExecutableMessage::Approved(msg) => ExecutableMessage::Approved(msg),
state::ExecutableMessage::Executed(msg) => ExecutableMessage::Executed(msg),
}
}
}

#[cw_serde]
pub enum ExecutableMessage {
/// A message that has been sent by the router, but not executed yet.
Expand Down
11 changes: 11 additions & 0 deletions contracts/axelarnet-gateway/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use cw_storage_plus::{Item, Map};
use error_stack::report;
use router_api::{ChainName, CrossChainId, Message};

use crate::msg;

const CONFIG: Item<Config> = Item::new("config");
const ROUTABLE_MESSAGES: Map<&CrossChainId, Message> = Map::new("routable_messages");
const EXECUTABLE_MESSAGES: Map<&CrossChainId, ExecutableMessage> = Map::new("executable_messages");
Expand Down Expand Up @@ -52,6 +54,15 @@ impl ExecutableMessage {
}
}

impl From<ExecutableMessage> for msg::ExecutableMessage {
fn from(value: ExecutableMessage) -> Self {
match value {
ExecutableMessage::Approved(msg) => msg::ExecutableMessage::Approved(msg),
ExecutableMessage::Executed(msg) => msg::ExecutableMessage::Executed(msg),
}
}
}

pub fn save_config(storage: &mut dyn Storage, value: &Config) -> Result<(), Error> {
Ok(CONFIG.save(storage, value)?)
}
Expand Down

0 comments on commit fed53af

Please sign in to comment.