@@ -26,19 +26,15 @@ use alloc::borrow::Cow;
2626use alloc:: collections:: BTreeMap ;
2727use alloc:: string:: { String , ToString } ;
2828use alloc:: vec:: Vec ;
29- use frame_decode:: constants:: { Constant , ConstantInfo , ConstantInfoError } ;
29+ use frame_decode:: constants:: { ConstantInfo , ConstantInfoError , Entry } ;
3030use frame_decode:: custom_values:: { CustomValue , CustomValueInfo , CustomValueInfoError } ;
3131use frame_decode:: extrinsics:: {
3232 ExtrinsicCallInfo , ExtrinsicExtensionInfo , ExtrinsicInfoArg , ExtrinsicInfoError ,
3333 ExtrinsicSignatureInfo ,
3434} ;
35- use frame_decode:: runtime_apis:: {
36- RuntimeApi , RuntimeApiInfo , RuntimeApiInfoError , RuntimeApiInput ,
37- } ;
38- use frame_decode:: storage:: { StorageEntry , StorageInfo , StorageInfoError , StorageKeyInfo } ;
39- use frame_decode:: view_functions:: {
40- ViewFunction , ViewFunctionInfo , ViewFunctionInfoError , ViewFunctionInput ,
41- } ;
35+ use frame_decode:: runtime_apis:: { RuntimeApiInfo , RuntimeApiInfoError , RuntimeApiInput } ;
36+ use frame_decode:: storage:: { StorageInfo , StorageInfoError , StorageKeyInfo } ;
37+ use frame_decode:: view_functions:: { ViewFunctionInfo , ViewFunctionInfoError , ViewFunctionInput } ;
4238
4339use hashbrown:: HashMap ;
4440use scale_info:: { PortableRegistry , Variant , form:: PortableForm } ;
@@ -184,15 +180,18 @@ impl frame_decode::storage::StorageTypeInfo for Metadata {
184180 Ok ( info)
185181 }
186182
187- fn storage_entries ( & self ) -> impl Iterator < Item = StorageEntry < ' _ > > {
183+ fn storage_entries ( & self ) -> impl Iterator < Item = Entry < ' _ > > {
188184 self . pallets ( ) . flat_map ( |pallet| {
189185 let pallet_name = pallet. name ( ) ;
190- pallet. storage ( ) . into_iter ( ) . flat_map ( |storage| {
191- storage. entries ( ) . iter ( ) . map ( |entry| StorageEntry {
192- pallet_name : Cow :: Borrowed ( pallet_name) ,
193- storage_entry : Cow :: Borrowed ( entry. name ( ) ) ,
194- } )
195- } )
186+ let pallet_iter = core:: iter:: once ( Entry :: In ( pallet_name. into ( ) ) ) ;
187+ let entries_iter = pallet. storage ( ) . into_iter ( ) . flat_map ( |storage| {
188+ storage
189+ . entries ( )
190+ . iter ( )
191+ . map ( |entry| Entry :: Name ( entry. name ( ) . into ( ) ) )
192+ } ) ;
193+
194+ pallet_iter. chain ( entries_iter)
196195 } )
197196 }
198197}
@@ -225,13 +224,15 @@ impl frame_decode::runtime_apis::RuntimeApiTypeInfo for Metadata {
225224 Ok ( info)
226225 }
227226
228- fn runtime_apis ( & self ) -> impl Iterator < Item = RuntimeApi < ' _ > > {
227+ fn runtime_apis ( & self ) -> impl Iterator < Item = Entry < ' _ > > {
229228 self . runtime_api_traits ( ) . flat_map ( |api_trait| {
230229 let trait_name = api_trait. name ( ) ;
231- api_trait. methods ( ) . map ( |method| RuntimeApi {
232- trait_name : Cow :: Borrowed ( trait_name) ,
233- method_name : Cow :: Borrowed ( method. name ( ) ) ,
234- } )
230+ let trait_iter = core:: iter:: once ( Entry :: In ( trait_name. into ( ) ) ) ;
231+ let method_iter = api_trait
232+ . methods ( )
233+ . map ( |method| Entry :: Name ( method. name ( ) . into ( ) ) ) ;
234+
235+ trait_iter. chain ( method_iter)
235236 } )
236237 }
237238}
@@ -264,13 +265,15 @@ impl frame_decode::view_functions::ViewFunctionTypeInfo for Metadata {
264265 Ok ( info)
265266 }
266267
267- fn view_functions ( & self ) -> impl Iterator < Item = ViewFunction < ' _ > > {
268+ fn view_functions ( & self ) -> impl Iterator < Item = Entry < ' _ > > {
268269 self . pallets ( ) . flat_map ( |pallet| {
269270 let pallet_name = pallet. name ( ) ;
270- pallet. view_functions ( ) . map ( |function| ViewFunction {
271- pallet_name : Cow :: Borrowed ( pallet_name) ,
272- function_name : Cow :: Borrowed ( function. name ( ) ) ,
273- } )
271+ let pallet_iter = core:: iter:: once ( Entry :: In ( pallet_name. into ( ) ) ) ;
272+ let fn_iter = pallet
273+ . view_functions ( )
274+ . map ( |function| Entry :: Name ( function. name ( ) . into ( ) ) ) ;
275+
276+ pallet_iter. chain ( fn_iter)
274277 } )
275278 }
276279}
@@ -302,13 +305,15 @@ impl frame_decode::constants::ConstantTypeInfo for Metadata {
302305 Ok ( info)
303306 }
304307
305- fn constants ( & self ) -> impl Iterator < Item = Constant < ' _ > > {
308+ fn constants ( & self ) -> impl Iterator < Item = Entry < ' _ > > {
306309 self . pallets ( ) . flat_map ( |pallet| {
307310 let pallet_name = pallet. name ( ) ;
308- pallet. constants ( ) . map ( |constant| Constant {
309- pallet_name : Cow :: Borrowed ( pallet_name) ,
310- constant_name : Cow :: Borrowed ( constant. name ( ) ) ,
311- } )
311+ let pallet_iter = core:: iter:: once ( Entry :: In ( pallet_name. into ( ) ) ) ;
312+ let constant_iter = pallet
313+ . constants ( )
314+ . map ( |constant| Entry :: Name ( constant. name ( ) . into ( ) ) ) ;
315+
316+ pallet_iter. chain ( constant_iter)
312317 } )
313318 }
314319}
0 commit comments