Skip to content

Commit

Permalink
chore: add Enum With No Variants card
Browse files Browse the repository at this point in the history
  • Loading branch information
varovainen committed Oct 13, 2023
1 parent 934718d commit 69d5b21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub enum ParsedData {
BlockHash(H256),
Call(Call),
Composite(Vec<FieldData>),
EmptyVariant,
EmptyEnum,
Era(Era),
Event(Event),
GenesisHash(H256),
Expand Down Expand Up @@ -517,7 +517,11 @@ impl ParsedData {
out
}
}
ParsedData::EmptyVariant => Vec::new(),
ParsedData::EmptyEnum => vec![ExtendedCard {
parser_card: ParserCard::EmptyEnum,
indent,
info_flat,
}],
ParsedData::Era(value) => single_card!(Era, value, indent, info_flat),
ParsedData::Event(event) => event.card(indent, short_specs, spec_name),
ParsedData::GenesisHash(_) => Vec::new(),
Expand Down Expand Up @@ -984,6 +988,7 @@ pub enum ParserCard {
BlockHash(H256),
CallName(String),
CompositeAnnounced(usize),
EmptyEnum,
EnumAnnounced,
EnumVariantName(String),
Era(Era),
Expand Down Expand Up @@ -1126,6 +1131,9 @@ impl ExtendedCard {
ParserCard::CompositeAnnounced(a) => {
readable(self.indent, "Struct", &format!("{a} field(s)"))
}
ParserCard::EmptyEnum => {
format!("{}Enum With No Variants", " ".repeat(self.indent as usize))
}
ParserCard::EnumAnnounced => format!("{}Enum", " ".repeat(self.indent as usize)),
ParserCard::EnumVariantName(a) => readable(self.indent, "Enum Variant Name", a),
ParserCard::Era(a) => match a {
Expand Down
2 changes: 1 addition & 1 deletion src/decoding_sci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ where
})
} else {
Ok(ExtendedData {
data: ParsedData::EmptyVariant,
data: ParsedData::EmptyEnum,
info: propagated.info,
})
}
Expand Down
1 change: 1 addition & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,7 @@ Pallet: Referenda
Field Name: proposal_origin
Enum
Enum Variant Name: Void
Enum With No Variants
Field Name: proposal
Enum
Enum Variant Name: Legacy
Expand Down

0 comments on commit 69d5b21

Please sign in to comment.