diff --git a/scales/src/lib.rs b/scales/src/lib.rs index 6d09f95..ae3c6c3 100644 --- a/scales/src/lib.rs +++ b/scales/src/lib.rs @@ -176,12 +176,9 @@ impl SpecificType { A: AsRef<[u8]> + PartialEq + core::fmt::Debug, B: AsRef<[u8]> + PartialEq + core::fmt::Debug, { - - match self { SpecificType::Variant(_, _, Some(_)) => Some(self), SpecificType::Variant(_, ref mut variants, idx @ None) => { - let (vf, _) = variants .iter() .map(|v| (v.index, get_field(&v))) diff --git a/scales/src/serializer.rs b/scales/src/serializer.rs index 5d92265..c650f4c 100644 --- a/scales/src/serializer.rs +++ b/scales/src/serializer.rs @@ -6,7 +6,6 @@ use core::fmt::{self, Debug}; use scale_info::{PortableRegistry, TypeInfo}; use serde::{ser, Serialize}; - use crate::{EnumVariant, SpecificType, TupleOrArray}; type TypeId = u32; @@ -441,7 +440,6 @@ where Some(SpecificType::Str) | None => Ok(None), // { "foo": "Bar" } => "Bar" might be an enum variant Some(ref mut var @ SpecificType::Variant(_, _, None)) => { - var.pick_mut(to_vec(val)?, |k| to_vec(k.name()).unwrap()) .ok_or_else(|| Error::BadInput("Invalid ".into()))?; self.out.put_u8(var.variant_id()); @@ -591,12 +589,9 @@ where where T: Serialize, { - - match self { TypedSerializer::Enum(ser) => { if let Some(ref mut var @ SpecificType::Variant(_, _, None)) = ser.ty { - let key_data = to_vec(key)?; // assume the key is the name of the variant @@ -618,26 +613,19 @@ where where T: Serialize, { - // match self { TypedSerializer::Composite(ser, types) => { - - - let mut ty = ser.resolve(types.remove(0)); // serde_json unwraps newtypes if let SpecificType::StructNewType(ty_id) = ty { ty = ser.resolve(ty_id) } - ser.ty = Some(ty); } TypedSerializer::Enum(ser) => { - if let Some(var @ SpecificType::Variant(_, _, Some(_))) = &ser.ty { - if let EnumVariant::NewType(_, _, ty_id) = var.into() { let ty = ser.resolve(ty_id); @@ -1316,11 +1304,8 @@ mod tests { } }); - - let call_data = to_vec_with_info( - &transfer_call, - (®istry, 106u32).into(), - ).expect("call data"); + let call_data = + to_vec_with_info(&transfer_call, (®istry, 106u32).into()).expect("call data"); let encooded = hex::encode(&call_data); @@ -1329,7 +1314,6 @@ mod tests { format!("0x04{}", encooded) ); - Ok(()) } }