fn remove_contract_user_group(
        &mut self,
        package_key: ContractPackageHash,
        label: Group,
    ) -> Result<Result<(), ApiError>, Error> {
        let mut package: ContractPackage =
            self.context.get_validated_contract_package(package_key)?;

        let group_to_remove = Group::new(label);
        let groups = package.groups_mut();

        // Ensure group exists in groups
        if groups.get(&group_to_remove).is_none() {
            return Ok(Err(contracts::Error::GroupDoesNotExist.into()));
        }

        // Remove group if it is not referenced by at least one entry_point in active versions.
        let versions = package.versions();
        for contract_hash in versions.values() {
            let entry_points = {
                let contract: Contract = self.context.read_gs_typed(&Key::from(*contract_hash))?;
                contract.entry_points().clone().take_entry_points()
            };
            for entry_point in entry_points {
                match entry_point.access() {
                    EntryPointAccess::Public => {
                        continue;
                    }
                    EntryPointAccess::Groups(groups) => {
                        if groups.contains(&group_to_remove) {
                            return Ok(Err(contracts::Error::GroupInUse.into()));
                        }
                    }
                }
            }
        }

        if !package.remove_group(&group_to_remove) {
            return Ok(Err(contracts::Error::GroupInUse.into()));
        }

        // Write updated package to the global state
        self.context.metered_write_gs_unsafe(package_key, package)?;
        Ok(Ok(()))
    }
/// Remove a user group from access to a contract
Remove a user group from access to a contract
Remove a user group from access to a contract
fn remove_contract_user_group(
        &mut self,
        package_key: ContractPackageHash,
        label: Group,
    ) -> Result<Result<(), ApiError>, Error> {
        let mut package: ContractPackage =
            self.context.get_validated_contract_package(package_key)?;
        let group_to_remove = Group::new(label);
        let groups = package.groups_mut();
        // Ensure group exists in groups
        if groups.get(&group_to_remove).is_none() {
            return Ok(Err(contracts::Error::GroupDoesNotExist.into()));
        }
        // Remove group if it is not referenced by at least one entry_point in active versions.
        let versions = package.versions();
        for contract_hash in versions.values() {
            let entry_points = {
                let contract: Contract = self.context.read_gs_typed(&Key::from(*contract_hash))?;
                contract.entry_points().clone().take_entry_points()
            };
            for entry_point in entry_points {
                match entry_point.access() {
                    EntryPointAccess::Public => {
                        continue;
                    }
                    EntryPointAccess::Groups(groups) => {
                        if groups.contains(&group_to_remove) {
                            return Ok(Err(contracts::Error::GroupInUse.into()));
                        }
                    }
                }
            }
        }
        if !package.remove_group(&group_to_remove) {
            return Ok(Err(contracts::Error::GroupInUse.into()));
        }
        // Write updated package to the global state
        self.context.metered_write_gs_unsafe(package_key, package)?;
        Ok(Ok(()))
    }
fn remove_contract_user_group ( & mut self , package_key : ContractPackageHash , label : Group , ) -> Result < Result < ( ) , ApiError > , Error > { let mut package : ContractPackage = self . context . get_validated_contract_package ( package_key ) ? ; let group_to_remove = Group :: new ( label ) ; let groups = package . groups_mut ( ) ; // Ensure group exists in groups if groups . get ( & group_to_remove ) . is_none ( ) { return Ok ( Err ( contracts :: Error :: GroupDoesNotExist . into ( ) ) ) ; } // Remove group if it is not referenced by at least one entry_point in active versions. let versions = package . versions ( ) ; for contract_hash in versions . values ( ) { let entry_points = { let contract : Contract = self . context . read_gs_typed ( & Key :: from ( * contract_hash ) ) ? ; contract . entry_points ( ) . clone ( ) . take_entry_points ( ) } ; for entry_point in entry_points { match entry_point . access ( ) { EntryPointAccess :: Public => { continue ; } EntryPointAccess :: Groups ( groups ) => { if groups . contains ( & group_to_remove ) { return Ok ( Err ( contracts :: Error :: GroupInUse . into ( ) ) ) ; } } } } } if ! package . remove_group ( & group_to_remove ) { return Ok ( Err ( contracts :: Error :: GroupInUse . into ( ) ) ) ; } // Write updated package to the global state self . context . metered_write_gs_unsafe ( package_key , package ) ? ; Ok ( Ok ( ( ) ) ) }
Remove a user group from access to a contract
Remove a user group from access to a contract
&mut self
package_key
ContractPackageHash
label
Group
&mut self
package_key
ContractPackageHash
label
Group