Skip to content

Commit

Permalink
fix serialization/deserialization of some enum types
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Feb 17, 2024
1 parent 063d03b commit c176394
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ impl EnvelopedDecodable for ReceiptV1 {
feature = "with-codec",
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "with-serde",
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum ReceiptV2 {
/// Legacy receipt type
Legacy(EIP658ReceiptData),
Expand Down Expand Up @@ -148,7 +152,11 @@ impl From<ReceiptV2> for EIP658ReceiptData {
feature = "with-codec",
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "with-serde",
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum ReceiptV3 {
/// Legacy receipt type
Legacy(EIP658ReceiptData),
Expand Down Expand Up @@ -220,7 +228,11 @@ impl From<ReceiptV3> for EIP658ReceiptData {
feature = "with-codec",
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "with-serde",
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum ReceiptAny {
/// Frontier receipt type
Frontier(FrontierReceiptData),
Expand Down
12 changes: 10 additions & 2 deletions src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ impl EnvelopedDecodable for TransactionV0 {
feature = "with-codec",
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "with-serde",
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum TransactionV1 {
/// Legacy transaction type
Legacy(LegacyTransaction),
Expand Down Expand Up @@ -103,7 +107,11 @@ impl EnvelopedDecodable for TransactionV1 {
feature = "with-codec",
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "with-serde",
derive(serde::Serialize, serde::Deserialize),
serde(untagged)
)]
pub enum TransactionV2 {
/// Legacy transaction type
Legacy(LegacyTransaction),
Expand Down

0 comments on commit c176394

Please sign in to comment.