Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sendMessage endpoint #53

Merged
merged 6 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

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

10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
[workspace]

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

exclude = [ ]
exclude = []

# Make the feature resolver explicit.
# See https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html#details
3 changes: 3 additions & 0 deletions gateway-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -8,3 +8,6 @@ edition = "2021"
[dependencies]
serde.workspace = true
lib-didethresolver.workspace = true
ethers.workspace = true
thiserror.workspace = true
jsonrpsee.workspace = true
19 changes: 19 additions & 0 deletions gateway-types/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use ethers::{
abi::EncodePackedError,
contract::ContractError,
providers::{Middleware, ProviderError},
signers::WalletError,
};
use thiserror::Error;

#[derive(Error, Debug)]

Check warning on line 9 in gateway-types/src/error.rs

Codecov / codecov/patch

gateway-types/src/error.rs#L9

Added line #L9 was not covered by tests
pub enum ExtSignerError<M: Middleware> {
#[error(transparent)]
Encode(#[from] EncodePackedError),
#[error("{0}")]
ContractError(#[from] ContractError<M>),
#[error(transparent)]
Provider(#[from] ProviderError),
#[error(transparent)]
Wallet(#[from] WalletError),
}
25 changes: 17 additions & 8 deletions gateway-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
//! Shared types between XPS Gateawy and client (libxmtp)
pub mod error;

use ethers::types::{Address, Bytes as EthersBytes, Signature};
use std::fmt;

use serde::{Deserialize, Serialize};

/// Address of the did:ethr Registry on Sepolia
pub const DID_ETH_REGISTRY: &str = "0xd1D374DDE031075157fDb64536eF5cC13Ae75000";
// Address of the Converstion on Sepolia
pub const CONVERSATION: &str = "0x15aE865d0645816d8EEAB0b7496fdd24227d1801";

/// A message sent to a conversation
#[derive(Serialize, Deserialize)]
pub struct Message {
// Unique identifier for a conversation
#[serde(rename = "conversationId")]
pub conversation_id: Vec<u8>,
pub conversation_id: [u8; 32],
/// message content in bytes
pub payload: Vec<u8>,
/// Signature of V
pub v: Vec<u8>,
/// Signature of R
pub r: Vec<u8>,
/// Signature of S
pub s: Vec<u8>,
pub payload: EthersBytes,
// Sender's identity
pub identity: Address,
// Signature by sender
pub signature: Signature,
}

pub type Bytes = Vec<u8>;
@@ -46,6 +48,13 @@ pub struct GrantInstallationResult {
pub transaction: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct SendMessageResult {
pub status: Status,
pub message: String,
pub transaction: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct KeyPackageResult {
/// Status of the operation
8 changes: 8 additions & 0 deletions messaging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,3 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log.workspace = true
tracing.workspace = true
tokio.workspace = true
async-trait.workspace = true
ethers = { workspace = true, features = ["ws"] }
serde.workspace = true
thiserror.workspace = true
gateway-types.workspace = true
Loading
Loading