mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
Move proxies migration (#7205)
* move the time delayed proxies migration into a separate function * add use statement * Update frame/proxy/src/lib.rs * bump proxy cargo version * update Cargo.lock * Update lib.rs * better format Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
@@ -226,22 +226,6 @@ decl_module! {
|
||||
/// `AnnouncementDepositFactor` metadata shadow.
|
||||
const AnnouncementDepositFactor: BalanceOf<T> = T::AnnouncementDepositFactor::get();
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
Proxies::<T>::translate::<(Vec<(T::AccountId, T::ProxyType)>, BalanceOf<T>), _>(
|
||||
|_, (targets, deposit)| Some((
|
||||
targets.into_iter()
|
||||
.map(|(a, t)| ProxyDefinition {
|
||||
delegate: a,
|
||||
proxy_type: t,
|
||||
delay: Zero::zero(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
deposit,
|
||||
))
|
||||
);
|
||||
T::MaximumBlockWeight::get()
|
||||
}
|
||||
|
||||
/// Dispatch the given `call` from an account that the sender is authorised for through
|
||||
/// `add_proxy`.
|
||||
///
|
||||
@@ -675,3 +659,32 @@ impl<T: Trait> Module<T> {
|
||||
Self::deposit_event(RawEvent::ProxyExecuted(e.map(|_| ()).map_err(|e| e.error)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Migration utilities for upgrading the Proxy pallet between its different versions.
|
||||
pub mod migration {
|
||||
use super::*;
|
||||
|
||||
/// Migration code for https://github.com/paritytech/substrate/pull/6770
|
||||
///
|
||||
/// Details: This migration was introduced between Substrate 2.0-RC6 and Substrate 2.0 releases.
|
||||
/// Before this migration, the `Proxies` storage item used a tuple of `AccountId` and
|
||||
/// `ProxyType` to represent the proxy definition. After #6770, we switched to use a struct
|
||||
/// `ProxyDefinition` which additionally included a `BlockNumber` delay value. This function,
|
||||
/// simply takes any existing proxies using the old tuple format, and migrates it to the new
|
||||
/// struct by setting the delay to zero.
|
||||
pub fn migrate_to_time_delayed_proxies<T: Trait>() -> Weight {
|
||||
Proxies::<T>::translate::<(Vec<(T::AccountId, T::ProxyType)>, BalanceOf<T>), _>(
|
||||
|_, (targets, deposit)| Some((
|
||||
targets.into_iter()
|
||||
.map(|(a, t)| ProxyDefinition {
|
||||
delegate: a,
|
||||
proxy_type: t,
|
||||
delay: Zero::zero(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
deposit,
|
||||
))
|
||||
);
|
||||
T::MaximumBlockWeight::get()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user