Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 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 crates/xmtp_api_d14n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl-trait-for-tuples = "0.2"
itertools.workspace = true
openmls_rust_crypto = { workspace = true }
parking_lot.workspace = true
pbjson-types.workspace = true
pin-project-lite = { workspace = true }
prost.workspace = true
thiserror.workspace = true
Expand Down
48 changes: 48 additions & 0 deletions crates/xmtp_api_d14n/src/endpoints/d14n/fetch_d14n_cutover.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use prost::Message;
use prost::bytes::Bytes;
use std::borrow::Cow;
use xmtp_proto::api::{BodyError, Endpoint};
use xmtp_proto::xmtp::migration::api::v1::FetchD14nCutoverResponse;

#[derive(Debug, Default)]
pub struct FetchD14nCutover;

impl Endpoint for FetchD14nCutover {
type Output = FetchD14nCutover;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium

d14n/fetch_d14n_cutover.rs:11 Output should be FetchD14nCutoverResponse, not FetchD14nCutover. This will cause deserialization failures when decoding the gRPC response.

Suggested change
type Output = FetchD14nCutover;
type Output = FetchD14nCutoverResponse;

🚀 Want me to fix this? Reply ex: "fix it for me".

fn grpc_endpoint(&self) -> Cow<'static, str> {
xmtp_proto::path_and_query::<FetchD14nCutoverResponse>()
}

fn body(&self) -> Result<Bytes, BodyError> {
Ok(pbjson_types::Empty::default().encode_to_vec().into())
}
}

#[cfg(test)]
mod test {
use super::*;
use xmtp_api_grpc::test::NodeGoClient;
use xmtp_proto::{api, prelude::*};

#[xmtp_common::test]
fn test_grpc_endpoint_returns_correct_path() {
let endpoint = FetchD14nCutover;
assert_eq!(
endpoint.grpc_endpoint(),
"/xmtp.migration.api.v1.D14nMigrationApi/FetchD14nCutover",
"Expected correct grpc method path but got {}",
endpoint.grpc_endpoint()
);
}

// ignored until service implemented
#[ignore]
#[xmtp_common::test]
async fn test_fetch_d14n_cutover() {
let client = NodeGoClient::create();
let client = client.build().unwrap();

let endpoint = FetchD14nCutover;
api::ignore(endpoint).query(&client).await.unwrap();
}
}
3 changes: 3 additions & 0 deletions crates/xmtp_api_d14n/src/endpoints/d14n/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ pub use health_check::*;

mod get_nodes;
pub use get_nodes::*;

mod fetch_d14n_cutover;
pub use fetch_d14n_cutover::*;
8 changes: 8 additions & 0 deletions crates/xmtp_proto/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,12 @@ pub mod xmtp {
include!("xmtp.xmtpv4.payer_api.serde.rs");
}
}
pub mod migration {
pub mod api {
pub mod v1 {
include!("xmtp.migration.api.v1.rs");
include!("xmtp.migration.api.v1.serde.rs");
}
}
}
}
12 changes: 10 additions & 2 deletions crates/xmtp_proto/src/proto_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Cache = HashMap<(Cow<'static, str>, Cow<'static, str>), Cow<'static, str>>;

// lookup a method path&query based on a type name & package
pub static METHOD_LOOKUP: LazyLock<Cache> = LazyLock::new(|| {
use Cow::*;
let pnq = |package: &str,
service: &ServiceDescriptorProto,
method: &MethodDescriptorProto|
Expand All @@ -29,12 +30,19 @@ pub static METHOD_LOOKUP: LazyLock<Cache> = LazyLock::new(|| {
};
for service in fd.service.iter() {
for method in service.method.iter() {
if let Some(output_t) = method.output_type().split('.').next_back() {
map.insert(
(Owned(package.clone()), Owned(output_t.to_string())),
Owned(pnq(package, service, method)),
);
};

let Some(input_t) = method.input_type().split('.').next_back() else {
continue;
};
map.insert(
(Cow::Owned(package.clone()), Cow::Owned(input_t.to_string())),
Cow::Owned(pnq(package, service, method)),
(Owned(package.clone()), Owned(input_t.to_string())),
Owned(pnq(package, service, method)),
);
}
}
Expand Down
Loading