Skip to content

Commit

Permalink
dex: augment liquidity_positions_by_price stream with position ids (#…
Browse files Browse the repository at this point in the history
…4234)

## Describe your changes

This adds a `PositionId` field to
`penumbra.core.component.dex.v1.LiquidityPositionsByPriceResponse`.

## Checklist before requesting a review

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > RPC change.
  • Loading branch information
erwanor authored Apr 30, 2024
1 parent 323b423 commit 4f99f3a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
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

0 comments on commit 4f99f3a

Please sign in to comment.