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

dex: augment liquidity_positions_by_price stream with position ids #4234

Merged
merged 3 commits into from
Apr 30, 2024
Merged
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
8 changes: 6 additions & 2 deletions crates/core/component/dex/src/component/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,12 @@ impl QueryService for Server {
anyhow::Ok(position)
}
})
.map_ok(|position| LiquidityPositionsByPriceResponse {
data: Some(position.into()),
.map_ok(|position| {
let id = position.id();
LiquidityPositionsByPriceResponse {
data: Some(position.into()),
id: Some(id.into()),
}
})
.map_err(|e: anyhow::Error| {
tonic::Status::internal(format!("error retrieving positions: {:#}", e))
Expand Down
2 changes: 2 additions & 0 deletions crates/proto/src/gen/penumbra.core.component.dex.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ impl ::prost::Name for LiquidityPositionsByPriceRequest {
pub struct LiquidityPositionsByPriceResponse {
#[prost(message, optional, tag = "1")]
pub data: ::core::option::Option<Position>,
#[prost(message, optional, tag = "2")]
pub id: ::core::option::Option<PositionId>,
}
impl ::prost::Name for LiquidityPositionsByPriceResponse {
const NAME: &'static str = "LiquidityPositionsByPriceResponse";
Expand Down
17 changes: 17 additions & 0 deletions crates/proto/src/gen/penumbra.core.component.dex.v1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3473,10 +3473,16 @@ impl serde::Serialize for LiquidityPositionsByPriceResponse {
if self.data.is_some() {
len += 1;
}
if self.id.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.dex.v1.LiquidityPositionsByPriceResponse", len)?;
if let Some(v) = self.data.as_ref() {
struct_ser.serialize_field("data", v)?;
}
if let Some(v) = self.id.as_ref() {
struct_ser.serialize_field("id", v)?;
}
struct_ser.end()
}
}
Expand All @@ -3488,11 +3494,13 @@ impl<'de> serde::Deserialize<'de> for LiquidityPositionsByPriceResponse {
{
const FIELDS: &[&str] = &[
"data",
"id",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Data,
Id,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand All @@ -3516,6 +3524,7 @@ impl<'de> serde::Deserialize<'de> for LiquidityPositionsByPriceResponse {
{
match value {
"data" => Ok(GeneratedField::Data),
"id" => Ok(GeneratedField::Id),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand All @@ -3536,6 +3545,7 @@ impl<'de> serde::Deserialize<'de> for LiquidityPositionsByPriceResponse {
V: serde::de::MapAccess<'de>,
{
let mut data__ = None;
let mut id__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Data => {
Expand All @@ -3544,13 +3554,20 @@ impl<'de> serde::Deserialize<'de> for LiquidityPositionsByPriceResponse {
}
data__ = map_.next_value()?;
}
GeneratedField::Id => {
if id__.is_some() {
return Err(serde::de::Error::duplicate_field("id"));
}
id__ = map_.next_value()?;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
}
}
Ok(LiquidityPositionsByPriceResponse {
data: data__,
id: id__,
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
1 change: 1 addition & 0 deletions proto/penumbra/penumbra/core/component/dex/v1/dex.proto
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ message LiquidityPositionsByPriceRequest {

message LiquidityPositionsByPriceResponse {
core.component.dex.v1.Position data = 1;
core.component.dex.v1.PositionId id = 2;
}

message SpreadRequest {
Expand Down
Loading