mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 13:41:08 +00:00
Event arguments are Vec not HashSet (#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.
This commit is contained in:
committed by
Andrew Jones
parent
5c2eeee1d2
commit
b4e8905053
+4
-7
@@ -13,10 +13,7 @@ use runtime_metadata::{
|
|||||||
META_RESERVED,
|
META_RESERVED,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{
|
collections::HashMap,
|
||||||
HashMap,
|
|
||||||
HashSet,
|
|
||||||
},
|
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
@@ -197,7 +194,7 @@ impl<K: Encode, V: Decode + Clone> StorageMap<K, V> {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ModuleEventMetadata {
|
pub struct ModuleEventMetadata {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
arguments: HashSet<EventArg>,
|
arguments: Vec<EventArg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModuleEventMetadata {
|
impl ModuleEventMetadata {
|
||||||
@@ -355,10 +352,10 @@ fn convert_event(
|
|||||||
event: runtime_metadata::EventMetadata,
|
event: runtime_metadata::EventMetadata,
|
||||||
) -> Result<ModuleEventMetadata, Error> {
|
) -> Result<ModuleEventMetadata, Error> {
|
||||||
let name = convert(event.name)?;
|
let name = convert(event.name)?;
|
||||||
let mut arguments = HashSet::new();
|
let mut arguments = Vec::new();
|
||||||
for arg in convert(event.arguments)? {
|
for arg in convert(event.arguments)? {
|
||||||
let arg = arg.parse::<EventArg>()?;
|
let arg = arg.parse::<EventArg>()?;
|
||||||
arguments.insert(arg);
|
arguments.push(arg);
|
||||||
}
|
}
|
||||||
Ok(ModuleEventMetadata { name, arguments })
|
Ok(ModuleEventMetadata { name, arguments })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user