Skip to content

Commit

Permalink
Remove references to gateway in-code (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx authored Feb 12, 2024
1 parent d2393a7 commit 18f851d
Show file tree
Hide file tree
Showing 22 changed files with 237 additions and 191 deletions.
333 changes: 183 additions & 150 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[workspace]

members = ["xps-gateway", "messaging", "inbox", "registry", "gateway-types"]
members = [
"xps",
"lib-xps",
"messaging",
"inbox",
"registry",
"xps-types",
]

exclude = []

Expand All @@ -22,6 +28,6 @@ thiserror = "1.0"
ethers = { version = "2.0.11", features = ["abigen"] }
ctor = "0.2"
lib-didethresolver = { git = "https://github.com/xmtp/didethresolver", branch = "main" }
gateway-types = { path = "./gateway-types" }
xps-types = { path = "./xps-types" }
rustc-hex = "2.1"
hex = "0.4"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN sudo apt update && sudo apt install -y pkg-config openssl libssl-dev

COPY --from=ghcr.io/xmtp/foundry:latest /usr/local/bin/anvil /usr/local/bin/anvil

ARG PROJECT=xps-gateway
ARG PROJECT=xps
WORKDIR /workspaces/${PROJECT}
COPY --chown=xmtp:xmtp . .

Expand All @@ -22,8 +22,8 @@ RUN cargo check
RUN cargo fmt --check
RUN cargo clippy --all-features --no-deps -- -D warnings
RUN cargo test --workspace --all-features
RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path xps-gateway --bin=xps_gateway --root=~${USER}/.cargo/
RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/xps_gateway --help
RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path xps --bin=xps --root=~${USER}/.cargo/
RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/xps --help

CMD RUST_LOG=info cargo run -- --host 0.0.0.0 --port 8080

Expand Down
5 changes: 2 additions & 3 deletions xps-gateway/Cargo.toml → lib-xps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "xps_gateway"
name = "lib-xps"
version = "0.1.0"
edition = "2021"
resolver = "2"
Expand All @@ -19,9 +19,8 @@ thiserror.workspace = true
ethers = { workspace = true, features = ["ws"] }
ctor.workspace = true
lib-didethresolver.workspace = true
gateway-types.workspace = true
xps-types.workspace = true
hex.workspace = true
clap = { version = "4.4.18", features = ["derive"] }
rand = "0.8.5"
tokio-stream = { version = "0.1", features = ["net"] }
registry = { path = "../registry" }
Expand Down
4 changes: 2 additions & 2 deletions xps-gateway/src/lib.rs → lib-xps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use ethers::{
abi::Address,
providers::{Provider, Ws},
};
use gateway_types::{CONVERSATION, DID_ETH_REGISTRY};
use jsonrpsee::server::Server;
use std::str::FromStr;
use xps_types::{CONVERSATION, DID_ETH_REGISTRY};

pub use crate::rpc::{XpsMethods, XpsServer};
pub use crate::rpc::{XpsClient, XpsMethods, XpsServer};
use crate::types::GatewayContext;

/// Entrypoint for the xps Gateway
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions xps-gateway/src/rpc/api.rs → lib-xps/src/rpc/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use ethers::core::types::Signature;
use ethers::prelude::*;
use jsonrpsee::{proc_macros::rpc, types::ErrorObjectOwned};

use gateway_types::{GrantInstallationResult, KeyPackageResult, WalletBalance};
use gateway_types::{Message, SendMessageResult};
use lib_didethresolver::types::XmtpAttribute;
use xps_types::{
GrantInstallationResult, KeyPackageResult, Message, SendMessageResult, WalletBalance,
};

/// XPS JSON-RPC Interface Methods
#[rpc(server, client, namespace = "xps")]
Expand Down
7 changes: 3 additions & 4 deletions xps-gateway/src/rpc/methods.rs → lib-xps/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ use ethers::{
core::types::Signature,
providers::{Middleware, ProviderError},
};
use gateway_types::{
GrantInstallationResult, KeyPackageResult, SendMessageResult, Unit, WalletBalance,
};
use jsonrpsee::types::ErrorObjectOwned;
use lib_didethresolver::types::XmtpAttribute;
use messaging::MessagingOperations;
use rand::{rngs::StdRng, SeedableRng};
use std::sync::Arc;
use thiserror::Error;
use xps_types::{
GrantInstallationResult, KeyPackageResult, Message, SendMessageResult, Unit, WalletBalance,
};

use gateway_types::Message;
use messaging::error::MessagingOperationError;
use registry::{error::ContactOperationError, ContactOperations};

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use ethers::providers::Middleware;
use ethers::types::{Address, Bytes, TransactionRequest, U256};
use ethers::utils::keccak256;
use ethers::{signers::LocalWallet, signers::Signer};
use gateway_types::{Message, Status, Unit};
use integration_util::*;
use jsonrpsee::core::ClientError;
use lib_didethresolver::{
did_registry::RegistrySignerExt,
types::{DidUrl, KeyEncoding, XmtpAttribute, XmtpKeyPurpose, NULL_ADDRESS},
};
use lib_xps::rpc::{XpsClient, DEFAULT_ATTRIBUTE_VALIDITY};
use messaging::ConversationSignerExt;
use xps_gateway::rpc::{XpsClient, DEFAULT_ATTRIBUTE_VALIDITY};
use xps_types::{Message, Status, Unit};

#[tokio::test]
async fn test_say_hello() -> Result<(), Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::{
use tokio::time::timeout as timeout_tokio;
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};

use xps_gateway::{
use lib_xps::{
types::{GatewayContext, GatewaySigner},
XpsMethods, XpsServer,
};
Expand Down
2 changes: 1 addition & 1 deletion messaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ async-trait.workspace = true
ethers = { workspace = true, features = ["ws"] }
serde.workspace = true
thiserror.workspace = true
gateway-types.workspace = true
xps-types.workspace = true
2 changes: 1 addition & 1 deletion messaging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ethers::{
types::H256,
utils::keccak256,
};
use gateway_types::{error::ExtSignerError, Message, SendMessageResult, Status};
use xps_types::{error::ExtSignerError, Message, SendMessageResult, Status};

abigen!(
Conversation,
Expand Down
10 changes: 5 additions & 5 deletions prod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ RUN cargo clippy --all-features --no-deps -- -D warnings
RUN cargo test --lib
RUN cargo test --doc
RUN cargo build --release
RUN CARGO_TARGET_DIR=/build/target cargo install --root /xmtp --path xps-gateway --bin=xps_gateway
RUN strip /xmtp/bin/xps_gateway
RUN CARGO_TARGET_DIR=/build/target cargo install --root /xmtp --path xps --bin=xps
RUN strip /xmtp/bin/xps
RUN cp CHANGELOG.md /xmtp/
RUN cp LICENSE /xmtp/

Expand All @@ -44,11 +44,11 @@ EXPOSE 8080
ENV USER=none
USER none

CMD ["/xmtp/bin/xps_gateway", "--host", "0.0.0.0", "--port", "8080"]
CMD ["/xmtp/bin/xps", "--host", "0.0.0.0", "--port", "8080"]

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="xps-gateway" \
org.label-schema.description="xps-gateway" \
org.label-schema.name="xps" \
org.label-schema.description="xps" \
org.label-schema.url="https://github.com/xmtp/xps-gateway" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="[email protected]:xmtp/xps-gateway.git" \
Expand Down
2 changes: 1 addition & 1 deletion registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tracing.workspace = true
tokio.workspace = true
async-trait.workspace = true
ethers = { workspace = true, features = ["ws"] }
gateway-types.workspace = true
xps-types.workspace = true
lib-didethresolver.workspace = true
rustc-hex.workspace = true
thiserror.workspace = true
2 changes: 1 addition & 1 deletion registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::str::FromStr;
use error::ContactOperationError;
use ethers::types::{H160, U256};
use ethers::{core::types::Signature, providers::Middleware, types::Address};
use gateway_types::{GrantInstallationResult, KeyPackageResult, Status};
use lib_didethresolver::types::VerificationMethodProperties;
use lib_didethresolver::Resolver;
use lib_didethresolver::{did_registry::DIDRegistry, types::XmtpAttribute};
use xps_types::{GrantInstallationResult, KeyPackageResult, Status};

pub struct ContactOperations<Middleware> {
registry: DIDRegistry<Middleware>,
Expand Down
2 changes: 1 addition & 1 deletion gateway-types/Cargo.toml → xps-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "gateway-types"
name = "xps-types"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions xps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "xps"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow.workspace = true
tokio.workspace = true
lib-xps = { path = "../lib-xps" }
clap = { version = "4.4.18", features = ["derive"] }
18 changes: 7 additions & 11 deletions xps-gateway/src/main.rs → xps/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use anyhow::Result;
use clap::Parser;
use xps_gateway::run;
use lib_xps::run;

#[derive(Parser, Debug)]
#[command(
name = "xps-gateway",
version = "0.1.0",
about = "XMTP Postal Service Gateway"
)]
#[command(name = "xps", version = "0.1.0", about = "XMTP Postal Service")]
struct Args {
#[arg(short = 'p', long = "port", default_value_t = 0)]
port: u16,
Expand All @@ -28,39 +24,39 @@ mod tests {

#[test]
fn test_port_0() -> Result<()> {
let arg_list = vec!["xps-gateway", "-p", "0"];
let arg_list = vec!["xps", "-p", "0"];
let args = Args::parse_from(arg_list);
assert_eq!(args.port, 0);
Ok(())
}

#[test]
fn test_port_25() -> Result<()> {
let arg_list = vec!["xps-gateway", "--port", "25"];
let arg_list = vec!["xps", "--port", "25"];
let args = Args::parse_from(arg_list);
assert_eq!(args.port, 25);
Ok(())
}

#[test]
fn test_host_test_net() -> Result<()> {
let arg_list = vec!["xps-gateway", "-s", "test.net"];
let arg_list = vec!["xps", "-s", "test.net"];
let args = Args::parse_from(arg_list);
assert_eq!(args.host, "test.net");
Ok(())
}

#[test]
fn test_host_test_0000() -> Result<()> {
let arg_list = vec!["xps-gateway", "--host", "0.0.0.0"];
let arg_list = vec!["xps", "--host", "0.0.0.0"];
let args = Args::parse_from(arg_list);
assert_eq!(args.host, "0.0.0.0");
Ok(())
}

#[test]
fn test_default() -> Result<()> {
let arg_list = vec!["xps-gateway"];
let arg_list = vec!["xps"];
let args = Args::parse_from(arg_list);
assert_eq!(args.port, 0);
assert_eq!(args.host, "127.0.0.1");
Expand Down

0 comments on commit 18f851d

Please sign in to comment.