git.delta.rocks / unique-network / refs/commits / 2b03ee1d72b2

difftreelog

feat access control manipulation from evm

Yaroslav Bolyukin2021-04-30parent: #aa96639.patch.diff
in: master

1 file changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
176 pub mint_mode: bool,176 pub mint_mode: bool,
177 pub offchain_schema: Vec<u8>,177 pub offchain_schema: Vec<u8>,
178 pub schema_version: SchemaVersion,178 pub schema_version: SchemaVersion,
179 pub sponsorship: SponsorshipState<T::CrossAccountId>,179 pub sponsorship: SponsorshipState<T::AccountId>,
180 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions 180 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions
181 pub variable_on_chain_schema: Vec<u8>, //181 pub variable_on_chain_schema: Vec<u8>, //
182 pub const_on_chain_schema: Vec<u8>, //182 pub const_on_chain_schema: Vec<u8>, //
845 /// * address.845 /// * address.
846 #[weight = <T as Config>::WeightInfo::add_to_white_list()]846 #[weight = <T as Config>::WeightInfo::add_to_white_list()]
847 #[transactional]847 #[transactional]
848 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{848 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
849849
850 let sender = ensure_signed(origin)?;850 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
851 let collection = Self::get_collection(collection_id)?;851 let collection = Self::get_collection(collection_id)?;
852 Self::check_owner_or_admin_permissions(&collection, sender)?;852 Self::check_owner_or_admin_permissions(&collection, sender)?;
853853
854 <WhiteList<T>>::insert(collection_id, address, true);854 <WhiteList<T>>::insert(collection_id, address.as_sub(), true);
855 855
856 Ok(())856 Ok(())
857 }857 }
870 /// * address.870 /// * address.
871 #[weight = <T as Config>::WeightInfo::remove_from_white_list()]871 #[weight = <T as Config>::WeightInfo::remove_from_white_list()]
872 #[transactional]872 #[transactional]
873 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{873 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
874874
875 let sender = ensure_signed(origin)?;875 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
876 let collection = Self::get_collection(collection_id)?;876 let collection = Self::get_collection(collection_id)?;
877 Self::check_owner_or_admin_permissions(&collection, sender)?;877 Self::check_owner_or_admin_permissions(&collection, sender)?;
878878
879 <WhiteList<T>>::remove(collection_id, address);879 <WhiteList<T>>::remove(collection_id, address.as_sub());
880880
881 Ok(())881 Ok(())
882 }882 }
896 #[transactional]896 #[transactional]
897 pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult897 pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult
898 {898 {
899 let sender = ensure_signed(origin)?;899 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
900900
901 let mut target_collection = Self::get_collection(collection_id)?;901 let mut target_collection = Self::get_collection(collection_id)?;
902 Self::check_owner_permissions(&target_collection, sender)?;902 Self::check_owner_permissions(&target_collection, sender)?;
923 #[transactional]923 #[transactional]
924 pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult924 pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult
925 {925 {
926 let sender = ensure_signed(origin)?;926 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
927927
928 let mut target_collection = Self::get_collection(collection_id)?;928 let mut target_collection = Self::get_collection(collection_id)?;
929 Self::check_owner_permissions(&target_collection, sender)?;929 Self::check_owner_permissions(&target_collection, sender)?;
946 /// * new_owner.946 /// * new_owner.
947 #[weight = <T as Config>::WeightInfo::change_collection_owner()]947 #[weight = <T as Config>::WeightInfo::change_collection_owner()]
948 #[transactional]948 #[transactional]
949 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {949 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::CrossAccountId) -> DispatchResult {
950950
951 let sender = ensure_signed(origin)?;951 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
952 let mut target_collection = Self::get_collection(collection_id)?;952 let mut target_collection = Self::get_collection(collection_id)?;
953 Self::check_owner_permissions(&target_collection, sender)?;953 Self::check_owner_permissions(&target_collection, sender)?;
954 target_collection.owner = new_owner;954 target_collection.owner = new_owner;
972 /// * new_admin_id: Address of new admin to add.972 /// * new_admin_id: Address of new admin to add.
973 #[weight = <T as Config>::WeightInfo::add_collection_admin()]973 #[weight = <T as Config>::WeightInfo::add_collection_admin()]
974 #[transactional]974 #[transactional]
975 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::AccountId) -> DispatchResult {975 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {
976976
977 let sender = ensure_signed(origin)?;977 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
978 let collection = Self::get_collection(collection_id)?;978 let collection = Self::get_collection(collection_id)?;
979 Self::check_owner_or_admin_permissions(&collection, sender)?;979 Self::check_owner_or_admin_permissions(&collection, sender)?;
980 let mut admin_arr = <AdminList<T>>::get(collection_id);980 let mut admin_arr = <AdminList<T>>::get(collection_id);
1005 /// * account_id: Address of admin to remove.1005 /// * account_id: Address of admin to remove.
1006 #[weight = <T as Config>::WeightInfo::remove_collection_admin()]1006 #[weight = <T as Config>::WeightInfo::remove_collection_admin()]
1007 #[transactional]1007 #[transactional]
1008 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::AccountId) -> DispatchResult {1008 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {
10091009
1010 let sender = ensure_signed(origin)?;1010 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1011 let collection = Self::get_collection(collection_id)?;1011 let collection = Self::get_collection(collection_id)?;
1012 Self::check_owner_or_admin_permissions(&collection, sender)?;1012 Self::check_owner_or_admin_permissions(&collection, sender)?;
1013 let mut admin_arr = <AdminList<T>>::get(collection_id);1013 let mut admin_arr = <AdminList<T>>::get(collection_id);
1035 #[transactional]1035 #[transactional]
1036 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {1036 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {
1037
1038 let sender = ensure_signed(origin)?;1037 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1039 let mut target_collection = Self::get_collection(collection_id)?;1038 let mut target_collection = Self::get_collection(collection_id)?;
1040 Self::check_owner_permissions(&target_collection, sender)?;1039 Self::check_owner_permissions(&target_collection, &sender)?;
10411040
1042 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor);1041 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor);
1043 Self::save_collection(target_collection);1042 Self::save_collection(target_collection);
1739 collection_id: u32,1736 collection_id: u32,
1740 new_limits: CollectionLimits<T::BlockNumber>,1737 new_limits: CollectionLimits<T::BlockNumber>,
1741 ) -> DispatchResult {1738 ) -> DispatchResult {
1742 let sender = ensure_signed(origin)?;1739 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1743 let mut target_collection = Self::get_collection(collection_id)?;1740 let mut target_collection = Self::get_collection(collection_id)?;
1744 Self::check_owner_permissions(&target_collection, sender.clone())?;1741 Self::check_owner_permissions(&target_collection, sender.clone())?;
1745 let old_limits = &target_collection.limits;1742 let old_limits = &target_collection.limits;