Skip to content

Commit

Permalink
protos(view): add subaccount index to OwnedPositionIds rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor authored and conorsch committed Jan 17, 2025
1 parent a454870 commit 480ffac
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/proto/src/gen/penumbra.view.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,9 @@ pub struct OwnedPositionIdsRequest {
pub trading_pair: ::core::option::Option<
super::super::core::component::dex::v1::TradingPair,
>,
/// If present, return only positions for this subaccount index.
#[prost(message, optional, tag = "3")]
pub subaccount: ::core::option::Option<super::super::core::keys::v1::AddressIndex>,
}
impl ::prost::Name for OwnedPositionIdsRequest {
const NAME: &'static str = "OwnedPositionIdsRequest";
Expand All @@ -1558,6 +1561,9 @@ pub struct OwnedPositionIdsResponse {
pub position_id: ::core::option::Option<
super::super::core::component::dex::v1::PositionId,
>,
/// The subaccount this position belongs to.
#[prost(message, optional, tag = "2")]
pub subaccount: ::core::option::Option<super::super::core::keys::v1::AddressIndex>,
}
impl ::prost::Name for OwnedPositionIdsResponse {
const NAME: &'static str = "OwnedPositionIdsResponse";
Expand Down
34 changes: 34 additions & 0 deletions crates/proto/src/gen/penumbra.view.v1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4196,13 +4196,19 @@ impl serde::Serialize for OwnedPositionIdsRequest {
if self.trading_pair.is_some() {
len += 1;
}
if self.subaccount.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.view.v1.OwnedPositionIdsRequest", len)?;
if let Some(v) = self.position_state.as_ref() {
struct_ser.serialize_field("positionState", v)?;
}
if let Some(v) = self.trading_pair.as_ref() {
struct_ser.serialize_field("tradingPair", v)?;
}
if let Some(v) = self.subaccount.as_ref() {
struct_ser.serialize_field("subaccount", v)?;
}
struct_ser.end()
}
}
Expand All @@ -4217,12 +4223,14 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsRequest {
"positionState",
"trading_pair",
"tradingPair",
"subaccount",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
PositionState,
TradingPair,
Subaccount,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand All @@ -4247,6 +4255,7 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsRequest {
match value {
"positionState" | "position_state" => Ok(GeneratedField::PositionState),
"tradingPair" | "trading_pair" => Ok(GeneratedField::TradingPair),
"subaccount" => Ok(GeneratedField::Subaccount),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand All @@ -4268,6 +4277,7 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsRequest {
{
let mut position_state__ = None;
let mut trading_pair__ = None;
let mut subaccount__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::PositionState => {
Expand All @@ -4282,6 +4292,12 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsRequest {
}
trading_pair__ = map_.next_value()?;
}
GeneratedField::Subaccount => {
if subaccount__.is_some() {
return Err(serde::de::Error::duplicate_field("subaccount"));
}
subaccount__ = map_.next_value()?;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
Expand All @@ -4290,6 +4306,7 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsRequest {
Ok(OwnedPositionIdsRequest {
position_state: position_state__,
trading_pair: trading_pair__,
subaccount: subaccount__,
})
}
}
Expand All @@ -4307,10 +4324,16 @@ impl serde::Serialize for OwnedPositionIdsResponse {
if self.position_id.is_some() {
len += 1;
}
if self.subaccount.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.view.v1.OwnedPositionIdsResponse", len)?;
if let Some(v) = self.position_id.as_ref() {
struct_ser.serialize_field("positionId", v)?;
}
if let Some(v) = self.subaccount.as_ref() {
struct_ser.serialize_field("subaccount", v)?;
}
struct_ser.end()
}
}
Expand All @@ -4323,11 +4346,13 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsResponse {
const FIELDS: &[&str] = &[
"position_id",
"positionId",
"subaccount",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
PositionId,
Subaccount,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand All @@ -4351,6 +4376,7 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsResponse {
{
match value {
"positionId" | "position_id" => Ok(GeneratedField::PositionId),
"subaccount" => Ok(GeneratedField::Subaccount),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand All @@ -4371,6 +4397,7 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsResponse {
V: serde::de::MapAccess<'de>,
{
let mut position_id__ = None;
let mut subaccount__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::PositionId => {
Expand All @@ -4379,13 +4406,20 @@ impl<'de> serde::Deserialize<'de> for OwnedPositionIdsResponse {
}
position_id__ = map_.next_value()?;
}
GeneratedField::Subaccount => {
if subaccount__.is_some() {
return Err(serde::de::Error::duplicate_field("subaccount"));
}
subaccount__ = map_.next_value()?;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
}
}
Ok(OwnedPositionIdsResponse {
position_id: position_id__,
subaccount: subaccount__,
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
9 changes: 6 additions & 3 deletions proto/penumbra/penumbra/view/v1/view.proto
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ service ViewService {

// There's only one transparent address per wallet, so this request has no parameters;
// the message exists to satisfy forward-compatibility properties.
message TransparentAddressRequest {
}
message TransparentAddressRequest {}

message TransparentAddressResponse {
// The raw (binary) transparent address
Expand Down Expand Up @@ -700,10 +699,14 @@ message OwnedPositionIdsRequest {
core.component.dex.v1.PositionState position_state = 1;
// If present, return only positions for this trading pair.
core.component.dex.v1.TradingPair trading_pair = 2;
// If present, return only positions for this subaccount index.
core.keys.v1.AddressIndex subaccount = 3;
}

message OwnedPositionIdsResponse {
core.component.dex.v1.PositionId position_id = 1;
// The subaccount this position belongs to.
core.keys.v1.AddressIndex subaccount = 2;
}

// Requests information on an asset by asset id
Expand Down Expand Up @@ -786,4 +789,4 @@ message UnbondingTokensByAddressIndexResponse {
// `true` if the `unbonding_delay` (from `StakeParameters`) has passed or the
// validator has unbonded.
bool claimable = 2;
}
}

0 comments on commit 480ffac

Please sign in to comment.