Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into coda/stitching
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Dec 20, 2024
2 parents a287b35 + 6a0c745 commit e70abb2
Show file tree
Hide file tree
Showing 26 changed files with 467 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-validation-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
needs: push_to_registry
strategy:
matrix:
environment: [ dev, production, testnet ]
environment: [ dev, production, testnet-staging ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
72 changes: 65 additions & 7 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ thiserror = "2.0"
tls_codec = "0.4.1"
tokio = { version = "1.35.1", default-features = false }
uuid = "1.10"
vergen-git2 = "1.0.2"
wasm-timer = "0.2"
web-time = "1.1"
# Changing this version and rustls may potentially break the android build. Use Caution.
Expand Down
37 changes: 19 additions & 18 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,24 +534,6 @@ impl FfiXmtpClient {
scw_verifier: self.inner_client.scw_verifier().clone().clone(),
}))
}

pub fn get_hmac_keys(&self) -> Result<Vec<FfiHmacKey>, GenericError> {
let inner = self.inner_client.as_ref();
let conversations = inner.find_groups(GroupQueryArgs::default())?;

let mut keys = vec![];
for conversation in conversations {
let mut k = conversation
.hmac_keys(-1..=1)?
.into_iter()
.map(Into::into)
.collect::<Vec<_>>();

keys.append(&mut k);
}

Ok(keys)
}
}

impl From<HmacKey> for FfiHmacKey {
Expand Down Expand Up @@ -1110,6 +1092,25 @@ impl FfiConversations {

FfiStreamCloser::new(handle)
}

pub fn get_hmac_keys(&self) -> Result<HashMap<Vec<u8>, Vec<FfiHmacKey>>, GenericError> {
let inner = self.inner_client.as_ref();
let conversations = inner.find_groups(GroupQueryArgs::default())?;

let mut hmac_map = HashMap::new();
for conversation in conversations {
let id = conversation.group_id.clone();
let keys = conversation
.hmac_keys(-1..=1)?
.into_iter()
.map(Into::into)
.collect::<Vec<_>>();

hmac_map.insert(id, keys);
}

Ok(hmac_map)
}
}

impl From<FfiConversationType> for ConversationType {
Expand Down
4 changes: 2 additions & 2 deletions mls_validation_service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "mls_validation_service"
version = "0.1.0" # Intentionally decoupled from the Workspace versioning
version = "0.1.4"
build = "build.rs"
license.workspace = true

Expand All @@ -10,7 +10,7 @@ name = "mls-validation-service"
path = "src/main.rs"

[build-dependencies]
vergen = { version = "8.3.2", features = ["git", "git2"] }
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
Expand Down
13 changes: 10 additions & 3 deletions mls_validation_service/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use vergen::EmitBuilder;
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() {
EmitBuilder::builder().git_sha(true).emit().unwrap();
fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
6 changes: 6 additions & 0 deletions xmtp_content_types/src/attachment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct AttachmentCodec {}

//. Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-remote-attachment/src/Attachment.ts
impl AttachmentCodec {
pub const TYPE_ID: &'static str = "attachment";
}
2 changes: 1 addition & 1 deletion xmtp_content_types/src/group_updated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct GroupUpdatedCodec {}

impl GroupUpdatedCodec {
const AUTHORITY_ID: &'static str = "xmtp.org";
const TYPE_ID: &'static str = "group_updated";
pub const TYPE_ID: &'static str = "group_updated";
}

impl ContentCodec<GroupUpdated> for GroupUpdatedCodec {
Expand Down
12 changes: 6 additions & 6 deletions xmtp_content_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pub mod attachment;
pub mod group_updated;
pub mod membership_change;
pub mod reaction;
pub mod read_receipt;
pub mod remote_attachment;
pub mod reply;
pub mod text;
pub mod transaction_reference;

use thiserror::Error;
use xmtp_proto::xmtp::mls::message_contents::{ContentTypeId, EncodedContent};

pub enum ContentType {
GroupMembershipChange,
GroupUpdated,
Text,
}

#[derive(Debug, Error)]
pub enum CodecError {
#[error("encode error {0}")]
Expand Down
2 changes: 1 addition & 1 deletion xmtp_content_types/src/membership_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct GroupMembershipChangeCodec {}

impl GroupMembershipChangeCodec {
const AUTHORITY_ID: &'static str = "xmtp.org";
const TYPE_ID: &'static str = "group_membership_change";
pub const TYPE_ID: &'static str = "group_membership_change";
}

impl ContentCodec<GroupMembershipChanges> for GroupMembershipChangeCodec {
Expand Down
6 changes: 6 additions & 0 deletions xmtp_content_types/src/reaction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct ReactionCodec {}

/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-reaction/src/Reaction.ts
impl ReactionCodec {
pub const TYPE_ID: &'static str = "reaction";
}
6 changes: 6 additions & 0 deletions xmtp_content_types/src/read_receipt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct ReadReceiptCodec {}

/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-read-receipt/src/ReadReceipt.ts
impl ReadReceiptCodec {
pub const TYPE_ID: &'static str = "readReceipt";
}
6 changes: 6 additions & 0 deletions xmtp_content_types/src/remote_attachment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct RemoteAttachmentCodec {}

//. Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-remote-attachment/src/RemoteAttachment.ts
impl RemoteAttachmentCodec {
pub const TYPE_ID: &'static str = "remoteStaticAttachment";
}
6 changes: 6 additions & 0 deletions xmtp_content_types/src/reply.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct ReplyCodec {}

/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-reply/src/Reply.ts
impl ReplyCodec {
pub const TYPE_ID: &'static str = "reply";
}
2 changes: 1 addition & 1 deletion xmtp_content_types/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct TextCodec {}

impl TextCodec {
const AUTHORITY_ID: &'static str = "xmtp.org";
const TYPE_ID: &'static str = "text";
pub const TYPE_ID: &'static str = "text";
const ENCODING_KEY: &'static str = "encoding";
const ENCODING_UTF8: &'static str = "UTF-8";
}
Expand Down
6 changes: 6 additions & 0 deletions xmtp_content_types/src/transaction_reference.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct TransactionReferenceCodec {}

/// Legacy content type id at https://github.com/xmtp/xmtp-js/blob/main/content-types/content-type-transaction-reference/src/TransactionReference.ts
impl TransactionReferenceCodec {
pub const TYPE_ID: &'static str = "transactionReference";
}
3 changes: 3 additions & 0 deletions xmtp_debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
version = "0.1.0"
license.workspace = true

[build-dependencies]
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
clap-verbosity-flag = "3.0"
Expand Down
12 changes: 12 additions & 0 deletions xmtp_debug/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
3 changes: 3 additions & 0 deletions xmtp_debug/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub use types::*;
/// Debug & Generate data on the XMTP Network
#[derive(Parser, Debug)]
pub struct AppOpts {
// Print Version
#[arg(long)]
pub version: bool,
#[command(subcommand)]
pub cmd: Option<Commands>,
#[command(flatten)]
Expand Down
9 changes: 9 additions & 0 deletions xmtp_debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ async fn main() -> Result<()> {
let mut logger = logger::Logger::from(&opts.log);
logger.init()?;

if opts.version {
info!("Version: {0}", get_version());
return Ok(());
}

let app = app::App::new(opts)?;
app.run().await?;

Ok(())
}

pub fn get_version() -> String {
format!("{}-{}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALTER TABLE group_messages
DROP COLUMN authority_id;

ALTER TABLE group_messages
DROP COLUMN version_major;

ALTER TABLE group_messages
DROP COLUMN version_minor;

ALTER TABLE group_messages
DROP COLUMN content_type;
11 changes: 11 additions & 0 deletions xmtp_mls/migrations/2024-12-18-175338_messages_content_type/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALTER TABLE group_messages
ADD COLUMN content_type INTEGER NOT NULL DEFAULT 0;

ALTER TABLE group_messages
ADD COLUMN version_minor INTEGER NOT NULL DEFAULT 0;

ALTER TABLE group_messages
ADD COLUMN version_major INTEGER NOT NULL DEFAULT 0;

ALTER TABLE group_messages
ADD COLUMN authority_id TEXT NOT NULL DEFAULT '';
Loading

0 comments on commit e70abb2

Please sign in to comment.