Skip to content

Commit

Permalink
Add support for fee tiers to TransactionPlannerRequest (#3722)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho authored Feb 2, 2024
1 parent 71f14df commit c1bb046
Show file tree
Hide file tree
Showing 5 changed files with 1,104 additions and 1,016 deletions.
17 changes: 14 additions & 3 deletions crates/proto/src/gen/penumbra.view.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ pub struct TransactionPlannerRequest {
/// The expiry height for the requested TransactionPlan
#[prost(uint64, tag = "1")]
pub expiry_height: u64,
/// The fee for the requested TransactionPlan, if any.
#[prost(message, optional, tag = "2")]
pub fee: ::core::option::Option<super::super::core::component::fee::v1alpha1::Fee>,
/// The memo for the requested TransactionPlan.
/// The memo must be unspecified unless `outputs` is nonempty.
#[prost(message, optional, tag = "3")]
Expand Down Expand Up @@ -209,6 +206,9 @@ pub struct TransactionPlannerRequest {
pub position_withdraws: ::prost::alloc::vec::Vec<
transaction_planner_request::PositionWithdraw,
>,
/// Specifies either that the planner should compute fees automatically or that it should use a fixed fee amount.
#[prost(oneof = "transaction_planner_request::FeeMode", tags = "100, 101")]
pub fee_mode: ::core::option::Option<transaction_planner_request::FeeMode>,
}
/// Nested message and enum types in `TransactionPlannerRequest`.
pub mod transaction_planner_request {
Expand Down Expand Up @@ -398,6 +398,17 @@ pub mod transaction_planner_request {
)
}
}
/// Specifies either that the planner should compute fees automatically or that it should use a fixed fee amount.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum FeeMode {
/// Automatically compute a fee based on gas use.
#[prost(message, tag = "100")]
AutoFee(super::super::super::core::component::fee::v1alpha1::FeeTier),
/// A manually set fee, rather than automatically computing a fee based on gas use.
#[prost(message, tag = "101")]
ManualFee(super::super::super::core::component::fee::v1alpha1::Fee),
}
}
impl ::prost::Name for TransactionPlannerRequest {
const NAME: &'static str = "TransactionPlannerRequest";
Expand Down
54 changes: 37 additions & 17 deletions crates/proto/src/gen/penumbra.view.v1alpha1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5402,9 +5402,6 @@ impl serde::Serialize for TransactionPlannerRequest {
if self.expiry_height != 0 {
len += 1;
}
if self.fee.is_some() {
len += 1;
}
if self.memo.is_some() {
len += 1;
}
Expand Down Expand Up @@ -5441,14 +5438,14 @@ impl serde::Serialize for TransactionPlannerRequest {
if !self.position_withdraws.is_empty() {
len += 1;
}
if self.fee_mode.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.view.v1alpha1.TransactionPlannerRequest", len)?;
if self.expiry_height != 0 {
#[allow(clippy::needless_borrow)]
struct_ser.serialize_field("expiryHeight", ToString::to_string(&self.expiry_height).as_str())?;
}
if let Some(v) = self.fee.as_ref() {
struct_ser.serialize_field("fee", v)?;
}
if let Some(v) = self.memo.as_ref() {
struct_ser.serialize_field("memo", v)?;
}
Expand Down Expand Up @@ -5485,6 +5482,16 @@ impl serde::Serialize for TransactionPlannerRequest {
if !self.position_withdraws.is_empty() {
struct_ser.serialize_field("positionWithdraws", &self.position_withdraws)?;
}
if let Some(v) = self.fee_mode.as_ref() {
match v {
transaction_planner_request::FeeMode::AutoFee(v) => {
struct_ser.serialize_field("autoFee", v)?;
}
transaction_planner_request::FeeMode::ManualFee(v) => {
struct_ser.serialize_field("manualFee", v)?;
}
}
}
struct_ser.end()
}
}
Expand All @@ -5497,7 +5504,6 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
const FIELDS: &[&str] = &[
"expiry_height",
"expiryHeight",
"fee",
"memo",
"source",
"outputs",
Expand All @@ -5516,12 +5522,15 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
"positionCloses",
"position_withdraws",
"positionWithdraws",
"auto_fee",
"autoFee",
"manual_fee",
"manualFee",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
ExpiryHeight,
Fee,
Memo,
Source,
Outputs,
Expand All @@ -5534,6 +5543,8 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
PositionOpens,
PositionCloses,
PositionWithdraws,
AutoFee,
ManualFee,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand All @@ -5557,7 +5568,6 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
{
match value {
"expiryHeight" | "expiry_height" => Ok(GeneratedField::ExpiryHeight),
"fee" => Ok(GeneratedField::Fee),
"memo" => Ok(GeneratedField::Memo),
"source" => Ok(GeneratedField::Source),
"outputs" => Ok(GeneratedField::Outputs),
Expand All @@ -5570,6 +5580,8 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
"positionOpens" | "position_opens" => Ok(GeneratedField::PositionOpens),
"positionCloses" | "position_closes" => Ok(GeneratedField::PositionCloses),
"positionWithdraws" | "position_withdraws" => Ok(GeneratedField::PositionWithdraws),
"autoFee" | "auto_fee" => Ok(GeneratedField::AutoFee),
"manualFee" | "manual_fee" => Ok(GeneratedField::ManualFee),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand All @@ -5590,7 +5602,6 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
V: serde::de::MapAccess<'de>,
{
let mut expiry_height__ = None;
let mut fee__ = None;
let mut memo__ = None;
let mut source__ = None;
let mut outputs__ = None;
Expand All @@ -5603,6 +5614,7 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
let mut position_opens__ = None;
let mut position_closes__ = None;
let mut position_withdraws__ = None;
let mut fee_mode__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::ExpiryHeight => {
Expand All @@ -5613,12 +5625,6 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::Fee => {
if fee__.is_some() {
return Err(serde::de::Error::duplicate_field("fee"));
}
fee__ = map_.next_value()?;
}
GeneratedField::Memo => {
if memo__.is_some() {
return Err(serde::de::Error::duplicate_field("memo"));
Expand Down Expand Up @@ -5691,14 +5697,27 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
}
position_withdraws__ = Some(map_.next_value()?);
}
GeneratedField::AutoFee => {
if fee_mode__.is_some() {
return Err(serde::de::Error::duplicate_field("autoFee"));
}
fee_mode__ = map_.next_value::<::std::option::Option<_>>()?.map(transaction_planner_request::FeeMode::AutoFee)
;
}
GeneratedField::ManualFee => {
if fee_mode__.is_some() {
return Err(serde::de::Error::duplicate_field("manualFee"));
}
fee_mode__ = map_.next_value::<::std::option::Option<_>>()?.map(transaction_planner_request::FeeMode::ManualFee)
;
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
}
}
Ok(TransactionPlannerRequest {
expiry_height: expiry_height__.unwrap_or_default(),
fee: fee__,
memo: memo__,
source: source__,
outputs: outputs__.unwrap_or_default(),
Expand All @@ -5711,6 +5730,7 @@ impl<'de> serde::Deserialize<'de> for TransactionPlannerRequest {
position_opens: position_opens__.unwrap_or_default(),
position_closes: position_closes__.unwrap_or_default(),
position_withdraws: position_withdraws__.unwrap_or_default(),
fee_mode: fee_mode__,
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
Loading

0 comments on commit c1bb046

Please sign in to comment.