Skip to content

Commit dac487e

Browse files
authored
[v0.50] update scale-info-legacy and frame-decode to latest (#2119)
* bump scale-info-legacy and frame-decode to latest * Remove something we don't need in this PR * Fully remove unused for now dep
1 parent 481e5a8 commit dac487e

File tree

4 files changed

+64
-47
lines changed

4 files changed

+64
-47
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ darling = "0.20.10"
8181
derive-where = "1.2.7"
8282
either = { version = "1.13.0", default-features = false }
8383
finito = { version = "0.1.0", default-features = false }
84-
frame-decode = { version = "0.11.1", default-features = false }
84+
frame-decode = { version = "0.12.0", default-features = false }
8585
frame-metadata = { version = "23.0.0", default-features = false }
8686
futures = { version = "0.3.31", default-features = false, features = ["std"] }
8787
getrandom = { version = "0.2", default-features = false }
@@ -103,7 +103,7 @@ scale-bits = { version = "0.7.0", default-features = false }
103103
scale-decode = { version = "0.16.0", default-features = false }
104104
scale-encode = { version = "0.10.0", default-features = false }
105105
scale-type-resolver = { version = "0.2.0" }
106-
scale-info-legacy = { version = "0.2.4" }
106+
scale-info-legacy = { version = "0.3.0", default-features = false }
107107
scale-typegen = "0.11.1"
108108
scale-typegen-description = "0.11.0"
109109
serde = { version = "1.0.210", default-features = false, features = ["derive"] }

historic/src/storage.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,32 @@ where
7070
let client = self.client;
7171
let metadata = client.metadata();
7272

73-
frame_decode::helpers::list_storage_entries_any(metadata).map(|entry| StorageEntriesItem {
74-
entry,
75-
client: self.client,
76-
marker: std::marker::PhantomData,
73+
let mut pallet_name = Cow::Borrowed("");
74+
frame_decode::helpers::list_storage_entries_any(metadata).filter_map(move |entry| {
75+
match entry {
76+
frame_decode::storage::Entry::In(name) => {
77+
// Set the pallet name for upcoming entries:
78+
pallet_name = name;
79+
None
80+
}
81+
frame_decode::storage::Entry::Name(entry_name) => {
82+
// Output each entry with the last seen pallet name:
83+
Some(StorageEntriesItem {
84+
pallet_name: pallet_name.clone(),
85+
entry_name,
86+
client: self.client,
87+
marker: std::marker::PhantomData,
88+
})
89+
}
90+
}
7791
})
7892
}
7993
}
8094

8195
/// Working with a specific storage entry.
8296
pub struct StorageEntriesItem<'atblock, Client, T> {
83-
entry: frame_decode::storage::StorageEntry<'atblock>,
97+
pallet_name: Cow<'atblock, str>,
98+
entry_name: Cow<'atblock, str>,
8499
client: &'atblock Client,
85100
marker: std::marker::PhantomData<T>,
86101
}
@@ -92,12 +107,12 @@ where
92107
{
93108
/// The pallet name.
94109
pub fn pallet_name(&self) -> &str {
95-
&self.entry.pallet_name
110+
&self.pallet_name
96111
}
97112

98113
/// The storage entry name.
99114
pub fn entry_name(&self) -> &str {
100-
&self.entry.storage_entry
115+
&self.entry_name
101116
}
102117

103118
/// Extract the relevant storage information so that we can work with this entry.
@@ -106,10 +121,7 @@ where
106121
client: self.client,
107122
marker: std::marker::PhantomData,
108123
}
109-
.entry(
110-
self.entry.pallet_name.clone(),
111-
self.entry.storage_entry.clone(),
112-
)
124+
.entry(&*self.pallet_name, &*self.entry_name)
113125
}
114126
}
115127

metadata/src/lib.rs

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@ use alloc::borrow::Cow;
2626
use alloc::collections::BTreeMap;
2727
use alloc::string::{String, ToString};
2828
use alloc::vec::Vec;
29-
use frame_decode::constants::{Constant, ConstantInfo, ConstantInfoError};
29+
use frame_decode::constants::{ConstantInfo, ConstantInfoError, Entry};
3030
use frame_decode::custom_values::{CustomValue, CustomValueInfo, CustomValueInfoError};
3131
use 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

4339
use hashbrown::HashMap;
4440
use 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

Comments
 (0)