@@ -5,7 +5,7 @@ use polkadot_sdk::frame_support::{
55
66use crate :: { Config , Pallet } ;
77
8- pub mod v3 {
8+ pub mod v5 {
99 use pallet_permission0_api:: { CuratorPermissions , Permission0CuratorApi , PermissionDuration } ;
1010 use polkadot_sdk:: {
1111 frame_system:: RawOrigin ,
@@ -159,175 +159,3 @@ pub mod v3 {
159159 }
160160 }
161161}
162-
163- pub mod v4 {
164- use pallet_permission0_api:: { CuratorPermissions , Permission0CuratorApi , PermissionDuration } ;
165- use polkadot_sdk:: {
166- frame_system:: RawOrigin ,
167- sp_tracing:: { info, warn} ,
168- } ;
169-
170- use super :: * ;
171-
172- pub type Migration < T , W > = VersionedMigration < 3 , 4 , MigrateToV4 < T > , Pallet < T > , W > ;
173- pub struct MigrateToV4 < T > ( core:: marker:: PhantomData < T > ) ;
174-
175- mod old_storage {
176- use polkadot_sdk:: frame_support:: { storage_alias, Identity } ;
177-
178- use crate :: AccountIdOf ;
179-
180- #[ storage_alias]
181- pub type Curators < T : crate :: Config > =
182- StorageMap < crate :: Pallet < T > , Identity , AccountIdOf < T > , ( ) > ;
183- }
184-
185- impl < T : Config > UncheckedOnRuntimeUpgrade for MigrateToV4 < T > {
186- fn on_runtime_upgrade ( ) -> Weight {
187- for ( curator, _) in old_storage:: Curators :: < T > :: iter ( ) {
188- let res = <<T as Config >:: Permission0 >:: grant_curator_permission (
189- RawOrigin :: Root . into ( ) ,
190- curator. clone ( ) ,
191- CuratorPermissions :: all ( ) ,
192- None ,
193- PermissionDuration :: Indefinite ,
194- pallet_permission0_api:: RevocationTerms :: RevocableByGrantor ,
195- ) ;
196-
197- match res {
198- Ok ( perm_id) => info ! ( "migrated curator {curator:?} to permission0: {perm_id}" ) ,
199- Err ( err) => {
200- warn ! ( "Could not migrate curator {curator:?} to permission0: {err:?}" ) ;
201- }
202- }
203- }
204-
205- Weight :: zero ( )
206- }
207- }
208- }
209-
210- pub mod v5 {
211- use crate :: proposal:: { GlobalParamsData , ProposalData } ;
212-
213- use super :: * ;
214-
215- pub type Migration < T , W > = VersionedMigration < 4 , 5 , MigrateToV5 < T > , Pallet < T > , W > ;
216- pub struct MigrateToV5 < T > ( core:: marker:: PhantomData < T > ) ;
217-
218- mod old_storage {
219- use codec:: { Decode , Encode , MaxEncodedLen } ;
220- use polkadot_sdk:: {
221- frame_support:: { storage_alias, DebugNoBound , Identity } ,
222- polkadot_sdk_frame:: prelude:: BlockNumberFor ,
223- sp_core:: ConstU32 ,
224- sp_runtime:: { BoundedVec , Percent } ,
225- } ;
226- use scale_info:: TypeInfo ;
227-
228- use crate :: {
229- proposal:: { ProposalId , ProposalStatus } ,
230- AccountIdOf , BalanceOf ,
231- } ;
232-
233- #[ derive( Clone , DebugNoBound , TypeInfo , Decode , Encode , MaxEncodedLen ) ]
234- #[ scale_info( skip_type_params( T ) ) ]
235- pub struct Proposal < T : crate :: Config > {
236- pub id : ProposalId ,
237- pub proposer : AccountIdOf < T > ,
238- pub expiration_block : BlockNumberFor < T > ,
239- pub data : ProposalData < T > ,
240- pub status : ProposalStatus < T > ,
241- pub metadata : BoundedVec < u8 , ConstU32 < 256 > > ,
242- pub proposal_cost : BalanceOf < T > ,
243- pub creation_block : BlockNumberFor < T > ,
244- }
245-
246- #[ derive( Clone , DebugNoBound , TypeInfo , Decode , Encode , MaxEncodedLen , PartialEq , Eq ) ]
247- #[ scale_info( skip_type_params( T ) ) ]
248- pub enum ProposalData < T : crate :: Config > {
249- GlobalParams ( GlobalParamsData < T > ) ,
250- GlobalCustom ,
251- Emission {
252- recycling_percentage : Percent ,
253- treasury_percentage : Percent ,
254- incentives_ratio : Percent ,
255- } ,
256- TransferDaoTreasury {
257- account : AccountIdOf < T > ,
258- amount : BalanceOf < T > ,
259- } ,
260- }
261-
262- #[ derive( Clone , DebugNoBound , TypeInfo , Decode , Encode , MaxEncodedLen , PartialEq , Eq ) ]
263- #[ scale_info( skip_type_params( T ) ) ]
264- pub struct GlobalParamsData < T : crate :: Config > {
265- pub min_name_length : u16 ,
266- pub max_name_length : u16 ,
267- pub max_allowed_agents : u16 ,
268- pub min_weight_control_fee : u8 ,
269- pub min_staking_fee : u8 ,
270- pub dividends_participation_weight : Percent ,
271- pub proposal_cost : BalanceOf < T > ,
272- }
273-
274- #[ storage_alias]
275- pub type Proposals < T : crate :: Config > =
276- StorageMap < crate :: Pallet < T > , Identity , ProposalId , Proposal < T > > ;
277- }
278-
279- impl < T : Config > UncheckedOnRuntimeUpgrade for MigrateToV5 < T > {
280- fn on_runtime_upgrade ( ) -> Weight {
281- for ( id, proposal) in old_storage:: Proposals :: iter ( ) {
282- let new_data = match proposal. data {
283- old_storage:: ProposalData :: GlobalParams ( old_storage:: GlobalParamsData {
284- min_name_length,
285- max_name_length,
286- min_weight_control_fee,
287- min_staking_fee,
288- dividends_participation_weight,
289- proposal_cost,
290- ..
291- } ) => ProposalData :: GlobalParams ( GlobalParamsData {
292- min_name_length,
293- max_name_length,
294- min_weight_control_fee,
295- min_staking_fee,
296- dividends_participation_weight,
297- namespace_pricing_config :
298- <T as pallet_torus0:: Config >:: DefaultNamespacePricingConfig :: get ( ) ,
299- proposal_cost,
300- } ) ,
301- old_storage:: ProposalData :: GlobalCustom => ProposalData :: GlobalCustom ,
302- old_storage:: ProposalData :: Emission {
303- recycling_percentage,
304- treasury_percentage,
305- incentives_ratio,
306- } => ProposalData :: Emission {
307- recycling_percentage,
308- treasury_percentage,
309- incentives_ratio,
310- } ,
311- old_storage:: ProposalData :: TransferDaoTreasury { account, amount } => {
312- ProposalData :: TransferDaoTreasury { account, amount }
313- }
314- } ;
315-
316- let new_proposal = crate :: proposal:: Proposal {
317- id : proposal. id ,
318- proposer : proposal. proposer ,
319- expiration_block : proposal. expiration_block ,
320- data : new_data,
321- status : proposal. status ,
322- metadata : proposal. metadata ,
323- proposal_cost : proposal. proposal_cost ,
324- creation_block : proposal. creation_block ,
325- } ;
326-
327- crate :: Proposals :: < T > :: set ( id, Some ( new_proposal) ) ;
328- }
329-
330- Weight :: zero ( )
331- }
332- }
333- }
0 commit comments