diff --git a/pallets/communities-manager/src/benchmarking.rs b/pallets/communities-manager/src/benchmarking.rs index a0388afc..02f060ee 100644 --- a/pallets/communities-manager/src/benchmarking.rs +++ b/pallets/communities-manager/src/benchmarking.rs @@ -40,15 +40,14 @@ mod benchmarks { setup_account::(&first_member)?; let community_id: CommunityIdOf = 1.into(); - let admin_origin: RuntimeOriginFor = frame_system::Origin::::Signed(first_member.clone()).into(); - let admin_origin_caller: PalletsOriginOf = admin_origin.into_caller(); + let first_admin = T::Lookup::unlookup(first_member.clone()); #[extrinsic_call] _( RawOrigin::Root, community_id, BoundedVec::truncate_from(b"Test Community".into()), - Some(admin_origin_caller.clone()), + first_admin, None, None, ); diff --git a/pallets/communities-manager/src/lib.rs b/pallets/communities-manager/src/lib.rs index 77134226..69b59a46 100644 --- a/pallets/communities-manager/src/lib.rs +++ b/pallets/communities-manager/src/lib.rs @@ -30,7 +30,10 @@ use pallet_communities::{ use pallet_nfts::{CollectionConfig, ItemConfig}; use pallet_referenda::{TrackInfo, TracksInfo}; use parity_scale_codec::Decode; -use sp_runtime::{str_array, traits::Get}; +use sp_runtime::{ + str_array, + traits::{Get, StaticLookup}, +}; type TrackInfoOf = TrackInfo, BlockNumberFor>; @@ -135,7 +138,7 @@ pub mod pallet { origin: OriginFor, community_id: CommunityIdOf, name: CommunityName, - maybe_admin_origin: Option>, + first_admin: pallet_communities::AccountIdLookupOf, maybe_decision_method: Option>, maybe_track_info: Option>, // _maybe_first_member: Option>, @@ -143,14 +146,16 @@ pub mod pallet { let maybe_deposit = T::RegisterOrigin::ensure_origin(origin)?; let community_name = core::str::from_utf8(&name).map_err(|_| Error::::InvalidCommunityName)?; - let community_origin: RuntimeOriginFor = CommunityOrigin::::new(community_id).into(); - let admin_origin = maybe_admin_origin.unwrap_or(community_origin.clone().into_caller()); + + let first_admin_account_id = T::Lookup::lookup(first_admin)?; + let admin_origin = frame_system::Origin::::Signed(first_admin_account_id); + // Register first to check if community exists - pallet_communities::Pallet::::register(&admin_origin, &community_id, maybe_deposit)?; + pallet_communities::Pallet::::register(&admin_origin.clone().into(), &community_id, maybe_deposit)?; if let Some(decision_method) = maybe_decision_method { pallet_communities::Pallet::::set_decision_method( - admin_origin.clone().into(), + admin_origin.into(), community_id, decision_method, )?; @@ -171,6 +176,7 @@ pub mod pallet { )?; // Create governance track for community + let community_origin: RuntimeOriginFor = CommunityOrigin::::new(community_id).into(); T::Tracks::insert( community_id, maybe_track_info.unwrap_or_else(|| Self::default_tack(community_name)),