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

proto: clean up tx format with breaking changes #3539

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions crates/proto/src/gen/penumbra.core.component.dex.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct SwapClaimBody {
pub nullifier: ::core::option::Option<super::super::sct::v1alpha1::Nullifier>,
/// The fee allows `SwapClaim` without an additional `Spend`.
#[prost(message, optional, tag = "2")]
pub fee: ::core::option::Option<super::super::fee::v1alpha1::Fee>,
pub fee: ::core::option::Option<super::super::super::asset::v1alpha1::Value>,
/// Note output for asset 1.
#[prost(message, optional, tag = "3")]
pub output_1_commitment: ::core::option::Option<
Expand Down Expand Up @@ -162,7 +162,7 @@ pub struct SwapPlaintext {
pub delta_2_i: ::core::option::Option<super::super::super::num::v1alpha1::Amount>,
/// Pre-paid fee to claim the swap
#[prost(message, optional, tag = "4")]
pub claim_fee: ::core::option::Option<super::super::fee::v1alpha1::Fee>,
pub claim_fee: ::core::option::Option<super::super::super::asset::v1alpha1::Value>,
/// Address that will claim the swap outputs via SwapClaim.
#[prost(message, optional, tag = "5")]
pub claim_address: ::core::option::Option<
Expand Down
19 changes: 0 additions & 19 deletions crates/proto/src/gen/penumbra.core.component.fee.v1alpha1.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/// Specifies fees paid by a transaction.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Fee {
/// The amount of the token used to pay fees.
#[prost(message, optional, tag = "1")]
pub amount: ::core::option::Option<super::super::super::num::v1alpha1::Amount>,
/// If present, the asset ID of the token used to pay fees.
/// If absent, specifies the staking token implicitly.
#[prost(message, optional, tag = "2")]
pub asset_id: ::core::option::Option<super::super::super::asset::v1alpha1::AssetId>,
}
impl ::prost::Name for Fee {
const NAME: &'static str = "Fee";
const PACKAGE: &'static str = "penumbra.core.component.fee.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("penumbra.core.component.fee.v1alpha1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GasPrices {
Expand Down
109 changes: 0 additions & 109 deletions crates/proto/src/gen/penumbra.core.component.fee.v1alpha1.serde.rs
Original file line number Diff line number Diff line change
@@ -1,112 +1,3 @@
impl serde::Serialize for Fee {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.amount.is_some() {
len += 1;
}
if self.asset_id.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.fee.v1alpha1.Fee", len)?;
if let Some(v) = self.amount.as_ref() {
struct_ser.serialize_field("amount", v)?;
}
if let Some(v) = self.asset_id.as_ref() {
struct_ser.serialize_field("assetId", v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for Fee {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"amount",
"asset_id",
"assetId",
];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Amount,
AssetId,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;

impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}

#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"amount" => Ok(GeneratedField::Amount),
"assetId" | "asset_id" => Ok(GeneratedField::AssetId),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = Fee;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct penumbra.core.component.fee.v1alpha1.Fee")
}

fn visit_map<V>(self, mut map_: V) -> std::result::Result<Fee, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut amount__ = None;
let mut asset_id__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Amount => {
if amount__.is_some() {
return Err(serde::de::Error::duplicate_field("amount"));
}
amount__ = map_.next_value()?;
}
GeneratedField::AssetId => {
if asset_id__.is_some() {
return Err(serde::de::Error::duplicate_field("assetId"));
}
asset_id__ = map_.next_value()?;
}
}
}
Ok(Fee {
amount: amount__,
asset_id: asset_id__,
})
}
}
deserializer.deserialize_struct("penumbra.core.component.fee.v1alpha1.Fee", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for FeeParameters {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ pub struct DelegatorVoteBody {
super::super::super::num::v1alpha1::Amount,
>,
/// The nullifier of the input note.
#[prost(bytes = "vec", tag = "6")]
pub nullifier: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "6")]
pub nullifier: ::core::option::Option<super::super::sct::v1alpha1::Nullifier>,
/// The randomized validating key for the spend authorization signature.
#[prost(bytes = "vec", tag = "7")]
pub rk: ::prost::alloc::vec::Vec<u8>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ impl serde::Serialize for DelegatorVoteBody {
if self.unbonded_amount.is_some() {
len += 1;
}
if !self.nullifier.is_empty() {
if self.nullifier.is_some() {
len += 1;
}
if !self.rk.is_empty() {
Expand All @@ -991,9 +991,8 @@ impl serde::Serialize for DelegatorVoteBody {
if let Some(v) = self.unbonded_amount.as_ref() {
struct_ser.serialize_field("unbondedAmount", v)?;
}
if !self.nullifier.is_empty() {
#[allow(clippy::needless_borrow)]
struct_ser.serialize_field("nullifier", pbjson::private::base64::encode(&self.nullifier).as_str())?;
if let Some(v) = self.nullifier.as_ref() {
struct_ser.serialize_field("nullifier", v)?;
}
if !self.rk.is_empty() {
#[allow(clippy::needless_borrow)]
Expand Down Expand Up @@ -1123,9 +1122,7 @@ impl<'de> serde::Deserialize<'de> for DelegatorVoteBody {
if nullifier__.is_some() {
return Err(serde::de::Error::duplicate_field("nullifier"));
}
nullifier__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
nullifier__ = map_.next_value()?;
}
GeneratedField::Rk => {
if rk__.is_some() {
Expand All @@ -1143,7 +1140,7 @@ impl<'de> serde::Deserialize<'de> for DelegatorVoteBody {
vote: vote__,
value: value__,
unbonded_amount: unbonded_amount__,
nullifier: nullifier__.unwrap_or_default(),
nullifier: nullifier__,
rk: rk__.unwrap_or_default(),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ pub struct SpendBody {
super::super::super::asset::v1alpha1::BalanceCommitment,
>,
/// The nullifier of the input note.
#[prost(bytes = "vec", tag = "3")]
pub nullifier: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "3")]
pub nullifier: ::core::option::Option<super::super::sct::v1alpha1::Nullifier>,
/// The randomized validating key for the spend authorization signature.
#[prost(bytes = "vec", tag = "4")]
pub rk: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "4")]
pub rk: ::core::option::Option<
super::super::super::super::crypto::decaf377_rdsa::v1alpha1::SpendVerificationKey,
>,
}
impl ::prost::Name for SpendBody {
const NAME: &'static str = "SpendBody";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1995,23 +1995,21 @@ impl serde::Serialize for SpendBody {
if self.balance_commitment.is_some() {
len += 1;
}
if !self.nullifier.is_empty() {
if self.nullifier.is_some() {
len += 1;
}
if !self.rk.is_empty() {
if self.rk.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.component.shielded_pool.v1alpha1.SpendBody", len)?;
if let Some(v) = self.balance_commitment.as_ref() {
struct_ser.serialize_field("balanceCommitment", v)?;
}
if !self.nullifier.is_empty() {
#[allow(clippy::needless_borrow)]
struct_ser.serialize_field("nullifier", pbjson::private::base64::encode(&self.nullifier).as_str())?;
if let Some(v) = self.nullifier.as_ref() {
struct_ser.serialize_field("nullifier", v)?;
}
if !self.rk.is_empty() {
#[allow(clippy::needless_borrow)]
struct_ser.serialize_field("rk", pbjson::private::base64::encode(&self.rk).as_str())?;
if let Some(v) = self.rk.as_ref() {
struct_ser.serialize_field("rk", v)?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -2092,24 +2090,20 @@ impl<'de> serde::Deserialize<'de> for SpendBody {
if nullifier__.is_some() {
return Err(serde::de::Error::duplicate_field("nullifier"));
}
nullifier__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
nullifier__ = map_.next_value()?;
}
GeneratedField::Rk => {
if rk__.is_some() {
return Err(serde::de::Error::duplicate_field("rk"));
}
rk__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
rk__ = map_.next_value()?;
}
}
}
Ok(SpendBody {
balance_commitment: balance_commitment__,
nullifier: nullifier__.unwrap_or_default(),
rk: rk__.unwrap_or_default(),
nullifier: nullifier__,
rk: rk__,
})
}
}
Expand Down
13 changes: 0 additions & 13 deletions crates/proto/src/gen/penumbra.core.keys.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,6 @@ impl ::prost::Name for SpendKey {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SpendVerificationKey {
#[prost(bytes = "vec", tag = "1")]
pub inner: ::prost::alloc::vec::Vec<u8>,
}
impl ::prost::Name for SpendVerificationKey {
const NAME: &'static str = "SpendVerificationKey";
const PACKAGE: &'static str = "penumbra.core.keys.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("penumbra.core.keys.v1alpha1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FullViewingKey {
#[prost(bytes = "vec", tag = "1")]
pub inner: ::prost::alloc::vec::Vec<u8>,
Expand Down
Loading
Loading