Skip to content

Commit cb6ed50

Browse files
Thomas Scholtesascjones
Thomas Scholtes
authored andcommitted
Event arguments are Vec not HashSet (paritytech#27)
Event arguments in the metadata are treated as `Vec` instead of `HashSet`. This fixes an issue with event arguments of the same name. For example the `Balances::Transfer` event has four arguments: `AccountId` (from), `AccountId` (to), `Balance` (value), `Balance` (fee). Before this change the code would only try to parse the two distinct arguments `AccountId` and `Balance` and decoding would fail.
1 parent 29f8bad commit cb6ed50

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/metadata.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ use runtime_metadata::{
1313
META_RESERVED,
1414
};
1515
use std::{
16-
collections::{
17-
HashMap,
18-
HashSet,
19-
},
16+
collections::HashMap,
2017
convert::TryFrom,
2118
marker::PhantomData,
2219
str::FromStr,
@@ -197,7 +194,7 @@ impl<K: Encode, V: Decode + Clone> StorageMap<K, V> {
197194
#[derive(Clone, Debug)]
198195
pub struct ModuleEventMetadata {
199196
pub name: String,
200-
arguments: HashSet<EventArg>,
197+
arguments: Vec<EventArg>,
201198
}
202199

203200
impl ModuleEventMetadata {
@@ -355,10 +352,10 @@ fn convert_event(
355352
event: runtime_metadata::EventMetadata,
356353
) -> Result<ModuleEventMetadata, Error> {
357354
let name = convert(event.name)?;
358-
let mut arguments = HashSet::new();
355+
let mut arguments = Vec::new();
359356
for arg in convert(event.arguments)? {
360357
let arg = arg.parse::<EventArg>()?;
361-
arguments.insert(arg);
358+
arguments.push(arg);
362359
}
363360
Ok(ModuleEventMetadata { name, arguments })
364361
}

0 commit comments

Comments
 (0)