Skip to content

Commit 1fe20e2

Browse files
authored
fix serialization/deserialization of some enum types (#55)
1 parent 24f8e1e commit 1fe20e2

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/receipt.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ impl EnvelopedDecodable for ReceiptV1 {
8484
feature = "with-codec",
8585
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
8686
)]
87-
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
87+
#[cfg_attr(
88+
feature = "with-serde",
89+
derive(serde::Serialize, serde::Deserialize),
90+
serde(untagged)
91+
)]
8892
pub enum ReceiptV2 {
8993
/// Legacy receipt type
9094
Legacy(EIP658ReceiptData),
@@ -147,7 +151,11 @@ impl From<ReceiptV2> for EIP658ReceiptData {
147151
feature = "with-codec",
148152
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
149153
)]
150-
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
154+
#[cfg_attr(
155+
feature = "with-serde",
156+
derive(serde::Serialize, serde::Deserialize),
157+
serde(untagged)
158+
)]
151159
pub enum ReceiptV3 {
152160
/// Legacy receipt type
153161
Legacy(EIP658ReceiptData),
@@ -219,7 +227,11 @@ impl From<ReceiptV3> for EIP658ReceiptData {
219227
feature = "with-codec",
220228
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
221229
)]
222-
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
230+
#[cfg_attr(
231+
feature = "with-serde",
232+
derive(serde::Serialize, serde::Deserialize),
233+
serde(untagged)
234+
)]
223235
pub enum ReceiptAny {
224236
/// Frontier receipt type
225237
Frontier(FrontierReceiptData),

src/transaction/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ impl EnvelopedDecodable for TransactionV0 {
4040
feature = "with-codec",
4141
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
4242
)]
43-
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
43+
#[cfg_attr(
44+
feature = "with-serde",
45+
derive(serde::Serialize, serde::Deserialize),
46+
serde(untagged)
47+
)]
4448
pub enum TransactionV1 {
4549
/// Legacy transaction type
4650
Legacy(LegacyTransaction),
@@ -103,7 +107,11 @@ impl EnvelopedDecodable for TransactionV1 {
103107
feature = "with-codec",
104108
derive(codec::Encode, codec::Decode, scale_info::TypeInfo)
105109
)]
106-
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
110+
#[cfg_attr(
111+
feature = "with-serde",
112+
derive(serde::Serialize, serde::Deserialize),
113+
serde(untagged)
114+
)]
107115
pub enum TransactionV2 {
108116
/// Legacy transaction type
109117
Legacy(LegacyTransaction),

0 commit comments

Comments
 (0)