async ContentLibraryGroupPermissions({libraryId, permissions=[]}) {
    let libraryPermissions = {};

    if(!permissions || permissions.length === 0) {
      permissions = ["accessor", "contributor", "reviewer"];
    } else {
      // Format and validate specified permissions
      permissions = permissions.map(permission => {
        permission = permission.toLowerCase();

        if(!["accessor", "contributor", "reviewer"].includes(permission)) {
          throw Error(`Invalid permission: ${permission}`);
        }

        return permission;
      });
    }

    await Promise.all(
      permissions.map(async type => {
        // Get library access groups of the specified type
        let numGroups = await this.CallContractMethod({
          contractAddress: this.utils.HashToAddress(libraryId),
          abi: LibraryContract.abi,
          methodName: type + "GroupsLength"
        });

        numGroups = parseInt(numGroups._hex, 16);

        const accessGroupAddresses = await [...Array(numGroups).keys()].limitedMap(
          3,
          async i => {
            try {
              return this.utils.FormatAddress(
                await this.CallContractMethod({
                  contractAddress: this.utils.HashToAddress(libraryId),
                  abi: LibraryContract.abi,
                  methodName: type + "Groups",
                  methodArgs: [i]
                })
              );
            } catch(error) {
              // eslint-disable-next-line no-console
              console.error(error);
            }
          }
        );

        accessGroupAddresses.forEach(address =>
          libraryPermissions[address] = [...(libraryPermissions[address] || []), type].sort());
      })
    );

    return libraryPermissions;
  }
/**
   * List all of the groups with permissions on the specified library.
   *
   * @methodGroup Access Groups
   * @namedParams
   * @param {string} libraryId - The ID of the library* @param {string} libraryId - The ID of the library
   * @param {(Array<string>)=} permissions - Limit permission types. If not specified, all permissions will be included
   *
   * @return {Promise<Object>} - Object mapping group addresses to permissions, as an array
   * - Example: { "0x0": ["accessor", "contributor"], ...}
   */
List all of the groups with permissions on the specified library.


List all of the groups with permissions on the specified library .
async ContentLibraryGroupPermissions({libraryId, permissions=[]}) {
    let libraryPermissions = {};
    if(!permissions || permissions.length === 0) {
      permissions = ["accessor", "contributor", "reviewer"];
    } else {
      permissions = permissions.map(permission => {
        permission = permission.toLowerCase();
        if(!["accessor", "contributor", "reviewer"].includes(permission)) {
          throw Error(`Invalid permission: ${permission}`);
        }
        return permission;
      });
    }
    await Promise.all(
      permissions.map(async type => {
        let numGroups = await this.CallContractMethod({
          contractAddress: this.utils.HashToAddress(libraryId),
          abi: LibraryContract.abi,
          methodName: type + "GroupsLength"
        });
        numGroups = parseInt(numGroups._hex, 16);
        const accessGroupAddresses = await [...Array(numGroups).keys()].limitedMap(
          3,
          async i => {
            try {
              return this.utils.FormatAddress(
                await this.CallContractMethod({
                  contractAddress: this.utils.HashToAddress(libraryId),
                  abi: LibraryContract.abi,
                  methodName: type + "Groups",
                  methodArgs: [i]
                })
              );
            } catch(error) {
              console.error(error);
            }
          }
        );
        accessGroupAddresses.forEach(address =>
          libraryPermissions[address] = [...(libraryPermissions[address] || []), type].sort());
      })
    );
    return libraryPermissions;
  }
async ContentLibraryGroupPermissions ( { libraryId , permissions = [ ] } ) { let libraryPermissions = { } ; if ( ! permissions || permissions . length === 0 ) { permissions = [ "accessor" , "contributor" , "reviewer" ] ; } else { permissions = permissions . map ( permission => { permission = permission . toLowerCase ( ) ; if ( ! [ "accessor" , "contributor" , "reviewer" ] . includes ( permission ) ) { throw Error ( ` ${ permission } ` ) ; } return permission ; } ) ; } await Promise . all ( permissions . map ( async type => { let numGroups = await this . CallContractMethod ( { contractAddress : this . utils . HashToAddress ( libraryId ) , abi : LibraryContract . abi , methodName : type + "GroupsLength" } ) ; numGroups = parseInt ( numGroups . _hex , 16 ) ; const accessGroupAddresses = await [ ... Array ( numGroups ) . keys ( ) ] . limitedMap ( 3 , async i => { try { return this . utils . FormatAddress ( await this . CallContractMethod ( { contractAddress : this . utils . HashToAddress ( libraryId ) , abi : LibraryContract . abi , methodName : type + "Groups" , methodArgs : [ i ] } ) ) ; } catch ( error ) { console . error ( error ) ; } } ) ; accessGroupAddresses . forEach ( address => libraryPermissions [ address ] = [ ... ( libraryPermissions [ address ] || [ ] ) , type ] . sort ( ) ) ; } ) ) ; return libraryPermissions ; }
List all of the groups with permissions on the specified library.
List all of the groups with permissions on the specified library .
// Format and validate specified permissions // Get library access groups of the specified type // eslint-disable-next-line no-console