mirror of
https://github.com/pezkuwichain/pezframe-metadata.git
synced 2026-04-22 04:17:58 +00:00
Change StorageEntryType keys/values to types instead of strings (#8)
* Change StorageEntryType keys/values to types instead of strings * Change storage to a single object not a Vec * Fix IntoPortable impl
This commit is contained in:
+14
-16
@@ -131,7 +131,7 @@ impl IntoPortable for SignedExtensionMetadata {
|
||||
)]
|
||||
pub struct ModuleMetadata<T: Form = MetaForm> {
|
||||
pub name: T::String,
|
||||
pub storage: Option<Vec<StorageMetadata<T>>>,
|
||||
pub storage: Option<StorageMetadata<T>>,
|
||||
pub calls: Option<Vec<FunctionMetadata<T>>>,
|
||||
pub event: Option<Vec<EventMetadata<T>>>,
|
||||
pub constants: Option<Vec<ModuleConstantMetadata<T>>>,
|
||||
@@ -147,9 +147,7 @@ impl IntoPortable for ModuleMetadata {
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
ModuleMetadata {
|
||||
name: self.name.into_portable(registry),
|
||||
storage: self
|
||||
.storage
|
||||
.map(|storage| registry.map_into_portable(storage)),
|
||||
storage: self.storage.map(|storage| storage.into_portable(registry)),
|
||||
calls: self.calls.map(|calls| registry.map_into_portable(calls)),
|
||||
event: self.event.map(|event| registry.map_into_portable(event)),
|
||||
constants: self
|
||||
@@ -243,19 +241,19 @@ pub enum StorageHasher {
|
||||
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
|
||||
)]
|
||||
pub enum StorageEntryType<T: Form = MetaForm> {
|
||||
Plain(T::String),
|
||||
Plain(T::Type),
|
||||
Map {
|
||||
hasher: StorageHasher,
|
||||
key: T::String,
|
||||
value: T::String,
|
||||
key: T::Type,
|
||||
value: T::Type,
|
||||
// is_linked flag previously, unused now to keep backwards compat
|
||||
unused: bool,
|
||||
},
|
||||
DoubleMap {
|
||||
hasher: StorageHasher,
|
||||
key1: T::String,
|
||||
key2: T::String,
|
||||
value: T::String,
|
||||
key1: T::Type,
|
||||
key2: T::Type,
|
||||
value: T::Type,
|
||||
key2_hasher: StorageHasher,
|
||||
},
|
||||
}
|
||||
@@ -265,7 +263,7 @@ impl IntoPortable for StorageEntryType {
|
||||
|
||||
fn into_portable(self, registry: &mut Registry) -> Self::Output {
|
||||
match self {
|
||||
Self::Plain(plain) => StorageEntryType::Plain(plain.into_portable(registry)),
|
||||
Self::Plain(plain) => StorageEntryType::Plain(registry.register_type(&plain)),
|
||||
Self::Map {
|
||||
hasher,
|
||||
key,
|
||||
@@ -273,8 +271,8 @@ impl IntoPortable for StorageEntryType {
|
||||
unused,
|
||||
} => StorageEntryType::Map {
|
||||
hasher,
|
||||
key: key.into_portable(registry),
|
||||
value: value.into_portable(registry),
|
||||
key: registry.register_type(&key),
|
||||
value: registry.register_type(&value),
|
||||
unused,
|
||||
},
|
||||
Self::DoubleMap {
|
||||
@@ -285,9 +283,9 @@ impl IntoPortable for StorageEntryType {
|
||||
key2_hasher,
|
||||
} => StorageEntryType::DoubleMap {
|
||||
hasher,
|
||||
key1: key1.into_portable(registry),
|
||||
key2: key2.into_portable(registry),
|
||||
value: value.into_portable(registry),
|
||||
key1: registry.register_type(&key1),
|
||||
key2: registry.register_type(&key2),
|
||||
value: registry.register_type(&value),
|
||||
key2_hasher,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user