Skip to content

Commit

Permalink
refactor(connection-router-api): replace the code with the latest (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy authored Feb 15, 2024
1 parent 4f00800 commit ece3349
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 117 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions packages/connection-router-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ edition = "2021"

[dependencies]
axelar-wasm-std = { workspace = true }
axelar-wasm-std-derive = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
error-stack = { workspace = true }
flagset = { version = "0.4.3", features = ["serde"] }
regex = "1.10.0"
report = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sha3 = { workspace = true }
thiserror = { workspace = true }
valuable = "0.1.0"

[dev-dependencies]
hex = "0.4.3"
rand = "0.8.5"
16 changes: 11 additions & 5 deletions packages/connection-router-api/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
use thiserror::Error;

use axelar_wasm_std_derive::IntoContractError;

/// A chain name must adhere to the following rules:
/// 1. it can optionally start with an uppercase letter, followed by one or more lowercase letters
/// 2. it can have an optional suffix of an optional dash and one or more digits ("1", "03", "-5" are all valid suffixes)
pub const CHAIN_NAME_REGEX: &str = "^[A-Z]?[a-z]+(-?[0-9]+)?$";

#[derive(Error, Debug)]
#[derive(Error, Debug, PartialEq, IntoContractError)]
pub enum Error {
#[error("chain name '{}' must adhere to the pattern '{}'", .0, CHAIN_NAME_REGEX)]
ChainNamePatternMismatch(String),
#[error("address must not be empty")]
EmptyAddress,
#[error("address is invalid")]
InvalidAddress,

#[error("message ID is invalid")]
InvalidMessageId,

#[error("chain name is invalid")]
InvalidChainName,
}
4 changes: 3 additions & 1 deletion packages/connection-router-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod primitives;

pub mod error;
pub mod msg;
pub mod primitives;
pub use primitives::*;
8 changes: 6 additions & 2 deletions packages/connection-router-api/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::primitives::*;
use cosmwasm_schema::{cw_serde, QueryResponses};

use crate::primitives::*;

#[cw_serde]
pub enum ExecuteMsg {
/*
Expand Down Expand Up @@ -44,4 +45,7 @@ pub enum ExecuteMsg {

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {}
pub enum QueryMsg {
#[returns(ChainEndpoint)]
GetChainInfo(ChainName),
}
Loading

0 comments on commit ece3349

Please sign in to comment.