Skip to content

Props Diamond SDKDocs


CatalogManager

Classdesc

Manages the underlying facet catalog available on the platform. This class provides methods to interact with and manipulate the facet catalog, including retrieving, setting, and updating facets.

Constructors

new CatalogManager()

new CatalogManager(getFacetCatalog, getInstalledFacets, setFacetCatalog?, setInstalledFacets?): CatalogManager

Parameters

getFacetCatalog

Function to retrieve the facet catalog

getInstalledFacets

Function to retrieve installed facets

setFacetCatalog?

Optional function to set the facet catalog

setInstalledFacets?

Optional function to set installed facets

Returns

CatalogManager

Methods

appendNewFacetsToFacetCatalog()

appendNewFacetsToFacetCatalog(newFacets): Promise<void>

Appends new facets to the existing facet catalog.

Parameters

newFacets: PropsFacet[]

Array of new facets to append

Returns

Promise<void>

Example

typescript
const newFacets: PropsFacet[] = [
  { facetName: "NewFeatureFacet", facetAddress: "0x...", data: { ... } }
];
await catalogManager.appendNewFacetsToFacetCatalog(newFacets);

getFacetCatalog()

getFacetCatalog(): Promise<undefined | PropsFacetCatalog>

Retrieves the current facet catalog.

Returns

Promise<undefined | PropsFacetCatalog>

The facet catalog or undefined if not available

Example

typescript
const catalog = await catalogManager.getFacetCatalog();
if (catalog) {
  console.log("Number of facets in catalog:", catalog.facets.length);
}

getFacetCatalogFacetByName()

getFacetCatalogFacetByName(name): Promise<undefined | PropsFacet>

Retrieves a facet from the catalog by its name.

Parameters

name: string

The name of the facet to retrieve

Returns

Promise<undefined | PropsFacet>

The found facet or undefined if not found

Example

typescript
const facet = await catalogManager.getFacetCatalogFacetByName("PropsERC1155");
if (facet) {
  console.log("PropsERC1155 facet address:", facet.facetAddress);
}

getFacetCatalogFacetsByNames()

getFacetCatalogFacetsByNames(names): Promise<PropsFacet[]>

Retrieves multiple facets from the catalog by their names.

Parameters

names: string[]

Array of facet names to retrieve

Returns

Promise<PropsFacet[]>

Array of found facets

Example

typescript
const facets = await catalogManager.getFacetCatalogFacetsByNames(["DiamondLoupeFacet", "PropsERC1155"]);
console.log("Retrieved facets:", facets.map(f => f.facetName));

getFacetCatalogFacetsExceptForFacetNames()

getFacetCatalogFacetsExceptForFacetNames(names): Promise<PropsFacet[]>

Retrieves all facets from the catalog except those with specified names.

Parameters

names: string[]

Array of facet names to exclude

Returns

Promise<PropsFacet[]>

Array of facets not in the exclusion list

Example

typescript
const facets = await catalogManager.getFacetCatalogFacetsExceptForFacetNames(["DiamondLoupeFacet"]);
console.log("Facets excluding DiamondLoupeFacet:", facets.map(f => f.facetName));

getInstalledFacetByName()

getInstalledFacetByName(name): Promise<undefined | PropsFacet>

Retrieves an installed facet by its name.

Parameters

name: string

The name of the installed facet to retrieve

Returns

Promise<undefined | PropsFacet>

The found installed facet or undefined if not found

Example

typescript
const installedFacet = await catalogManager.getInstalledFacetByName("PropsERC1155");
if (installedFacet) {
  console.log("Installed PropsERC1155 facet address:", installedFacet.facetAddress);
}

getInstalledFacetBySelector()

getInstalledFacetBySelector(selector): Promise<undefined | PropsFacet>

Retrieves an installed facet by its selector.

Parameters

selector: string

The selector of the installed facet to retrieve

Returns

Promise<undefined | PropsFacet>

The found installed facet or undefined if not found

Example

typescript
const selector = "0x01ffc9a7"; // Example selector for supportsInterface
const facet = await catalogManager.getInstalledFacetBySelector(selector);
if (facet) {
  console.log("Facet with selector", selector, "is:", facet.facetName);
}

getInstalledFacets()

getInstalledFacets(): Promise<undefined | PropsFacetCatalog>

Retrieves the currently installed facets.

Returns

Promise<undefined | PropsFacetCatalog>

The installed facets or undefined if not available

Example

typescript
const installedFacets = await catalogManager.getInstalledFacets();
if (installedFacets) {
  console.log("Installed facets:", installedFacets.facets.map(f => f.facetName));
}

getInstalledFacetsByNames()

getInstalledFacetsByNames(names): Promise<PropsFacet[]>

Retrieves multiple installed facets by their names.

Parameters

names: string[]

Array of installed facet names to retrieve

Returns

Promise<PropsFacet[]>

Array of found installed facets or undefined if none found

Example

typescript
const installedFacets = await catalogManager.getInstalledFacetsByNames(["DiamondLoupeFacet", "PropsERC1155"]);
if (installedFacets) {
  console.log("Installed facets:", installedFacets.map(f => f.facetName));
}

getInstalledFacetsExceptForFacetNames()

getInstalledFacetsExceptForFacetNames(names): Promise<PropsFacet[]>

Retrieves all installed facets except those with specified names.

Parameters

names: string[]

Array of facet names to exclude

Returns

Promise<PropsFacet[]>

Array of installed facets not in the exclusion list

Example

typescript
const facets = await catalogManager.getInstalledFacetsExceptForFacetNames(["DiamondLoupeFacet"]);
console.log("Installed facets excluding DiamondLoupeFacet:", facets.map(f => f.facetName));

logInstalledFacets()

logInstalledFacets(): Promise<void>

Logs the installed facets, optionally filtered by name.

Returns

Promise<void>

Example

typescript
await catalogManager.logInstalledFacets();

setFacetCatalog()

setFacetCatalog(facetCatalog): Promise<void>

Sets the facet catalog.

Parameters

facetCatalog: PropsFacetCatalog

The facet catalog to set

Returns

Promise<void>

Example

typescript
const newCatalog: PropsFacetCatalog = {
  facets: [
    { facetName: "DiamondLoupeFacet", facetAddress: "0x...", data: { ... } },
    { facetName: "PropsERC1155", facetAddress: "0x...", data: { ... } }
  ]
};
await catalogManager.setFacetCatalog(newCatalog);

setInstalledFacets()

setInstalledFacets(facetCatalog): Promise<void>

Sets the installed facets.

Parameters

facetCatalog: PropsFacetCatalog

The facet catalog to set as installed

Returns

Promise<void>

Example

typescript
const newInstalledFacets: PropsFacetCatalog = {
  facets: [
    { facetName: "DiamondLoupeFacet", facetAddress: "0x...", data: { ... } },
    { facetName: "PropsERC1155", facetAddress: "0x...", data: { ... } }
  ]
};
await catalogManager.setInstalledFacets(newInstalledFacets);

updateFacetRegistrationOnDiamond()

updateFacetRegistrationOnDiamond(cuts): Promise<PropsFacet[]>

Updates the facet registration on the diamond based on the provided cuts and facets.

Parameters

cuts: DiamondCut[]

Array of diamond cuts to apply

Returns

Promise<PropsFacet[]>

Updated array of installed facets

Example

typescript
const cuts: DiamondCut[] = [
  {
    facetAddress: "0x...",
    action: FacetCutAction.Add,
    functionSelectors: ["0x01ffc9a7"]
  }
];
const updatedFacets = await catalogManager.updateFacetRegistrationOnDiamond(cuts);
console.log("Updated installed facets:", updatedFacets.map(f => f.facetName));