Skip to content

Commit

Permalink
fix serialization/deserialization of some enum types (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro authored Feb 18, 2024
1 parent 24f8e1e commit 1fe20e2
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 @@ -84,7 +84,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 @@ -147,7 +151,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 @@ -219,7 +227,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 1fe20e2

Please sign in to comment.