Skip to content

Props Diamond SDKDocs


Manages diamond contracts, including deployment, upgrades, and facet management.

DiamondManager

Classdesc

The DiamondManager class is responsible for handling all aspects of diamond contract management in the Props ecosystem. It provides functionality for deploying new diamond contracts, upgrading existing ones, and managing facets. This includes adding, removing, or replacing facets, which allows for modular and upgradeable smart contract systems. The class interacts with the Ethereum network using ethers.js, and works in conjunction with the PlatformManager to ensure proper integration with the wider Props platform. It handles complex operations such as diamond cuts, which modify the structure of diamond contracts, and manages the configuration and state of diamonds. The DiamondManager is a crucial component for developers working with upgradeable and modular smart contract systems in the Props framework.

Constructors

new DiamondManager()

new DiamondManager(getSigner?, getNetworkConfiguration?, getDiamondConfiguration?, getPlatformManager?, setDiamondConfiguration?): DiamondManager

Creates a new DiamondManager instance.

Parameters

getSigner?

Function to get the signer.

getNetworkConfiguration?

Function to get the network configuration.

getDiamondConfiguration?

Function to get the diamond configuration.

getPlatformManager?

Function to get the platform manager.

setDiamondConfiguration?

Function to set the diamond configuration.

Returns

DiamondManager

Properties

HookMiner

HookMiner: HookMiner

Methods

assertFacetSelectorsInstalledToDiamond()

assertFacetSelectorsInstalledToDiamond(cuts, includeSelectors?, excludeSelectors?): Promise<boolean>

Asserts that the specified facet selectors are installed on the diamond.

Parameters

cuts: DiamondCut[]

The cuts to check.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

Returns

Promise<boolean>

True if all selectors are installed, false otherwise.

Method

assertFacetSelectorsInstalledToDiamond

Example

typescript
const cuts = await diamondManager.createDiamondCuts(FacetCutAction.Add, facets, [], []);
const isInstalled = await diamondManager.assertFacetSelectorsInstalledToDiamond(
  cuts,
  ["0x01ffc9a7"], // includeSelectors: supportsInterface
  ["0x0e89341c"]  // excludeSelectors: uri
);
console.log("Are selectors installed?", isInstalled);

assertFacetsInstalledToDiamond()

assertFacetsInstalledToDiamond(facets, includeSelectors?, excludeSelectors?): Promise<boolean>

Asserts that the specified facets are installed on the diamond.

Parameters

facets: PropsFacet[]

The facets to check.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

Returns

Promise<boolean>

True if all facets are installed, false otherwise.

Method

assertFacetsInstalledToDiamond

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["DiamondLoupeFacet", "PropsERC1155"]
);

const isInstalled = await diamondManager.assertFacetsInstalledToDiamond(
  facets,
  ["0x01ffc9a7"], // includeSelectors: supportsInterface
  ["0x0e89341c"]  // excludeSelectors: uri
);
console.log("Are facets installed?", isInstalled);

createDiamondCuts()

createDiamondCuts(mode, facets, includeSelectors?, excludeSelectors?, priorities?): Promise<DiamondCut[]>

Creates diamond cuts for the specified facets.

Parameters

mode: number

The cut mode (Add, Remove, Replace).

facets: PropsFacet[]

The facets to create cuts for.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

priorities?: any

Priorities for the cuts.

Returns

Promise<DiamondCut[]>

The created diamond cuts.

Method

createDiamondCuts

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Replace,
  facets,
  ["mint(address,uint256,uint256)", "mintBatch(address,uint256[],uint256[])"],
  []
);

createFacetFunctionCall()

createFacetFunctionCall(facetName, functionName, functionArgs): Promise<string>

Creates an encoded function call for a facet.

Parameters

facetName: string

The name of the facet.

functionName: string

The name of the function to call.

functionArgs: any[]

The arguments for the function call.

Returns

Promise<string>

The encoded function call.

Method

createFacetFunctionCall

Example

typescript
const encodedCall = await diamondManager.createFacetFunctionCall(
  "PropsERC1155",
  "mint",
  [recipientAddress, tokenId, amount, "0x"]
);
console.log("Encoded function call:", encodedCall);

createFacetInit()

createFacetInit(facetName, functionName, functionArgs): Promise<PropsInitCall>

Creates an initialization call for a facet.

Parameters

facetName: string

The name of the facet.

functionName: string

The name of the initialization function.

functionArgs: any[]

The arguments for the initialization function.

Returns

Promise<PropsInitCall>

The initialization call object.

Method

createFacetInit

Example

typescript
const initCall = await diamondManager.createFacetInit(
  "PropsERC1155",
  "init",
  ["My Token", "MTK", "A test token", "https://baseuri.com/", "https://contracturi.com"]
);
console.log("Initialization call:", initCall);

cutFacetsToDiamond()

cutFacetsToDiamond(facets, includeSelectors?, excludeSelectors?, priorities?, inits?, waitForEvent?, waitForEventTypes?): Promise<undefined | PropsDiamond>

Adds facets to the diamond.

Parameters

facets: PropsFacet[]

The facets to add.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

priorities?: any

Priorities for the cuts.

inits?: PropsInitCall[]

Initialization calls to make after the cut.

waitForEvent?: string

Event to wait for after the cut.

waitForEventTypes?: string[]

Types of the event to wait for.

Returns

Promise<undefined | PropsDiamond>

The updated diamond or undefined.

Method

cutFacetsToDiamond

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Add,
  facets,
  [],
  []
);

const initCalls = [
  await diamondManager.createFacetInit(
    "PropsERC1155CreatorSplits",
    "init",
    ["NAME", "SYMBOL", "DESCRIPTION", "ipfs://baseuricid/", "ipfs://contracturicid"]
  )
];

const updatedDiamond = await diamondManager.cutFacetsToDiamond(
  facets,
  [],
  [],
  undefined,
  initCalls
);

deployDiamondClone()

deployDiamondClone(salt, initialFacets?, priorities?, inits?): Promise<undefined | PropsDiamond>

Deploys a new diamond clone with specified facets and initializations.

Parameters

salt: bigint

initialFacets?: PropsFacet[]

Initial facets to add to the diamond.

priorities?: any

Priorities for the facets.

inits?: PropsInitCall[]

Initialization calls to make after deployment.

Returns

Promise<undefined | PropsDiamond>

The deployed diamond or undefined.

Method

deployDiamondClone

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["DiamondLoupeFacet", "PropsMulticall", "PropsERC1155"]
);

const initFacet = facets.find(facet => facet.facetName === "PropsERC1155")?.data?.contract;
const functionCall = await propsDiamondSDKClient.diamondManager.createFacetFunctionCall(
  "PropsERC1155",
  "init",
  ["NAME", "SYM", "DESC", "BASEURI/", "CONTRACTURI"]
);

const deployedDiamond = await propsDiamondSDKClient.diamondManager.deployDiamondClone(
  facets,
  { "supportsInterface(bytes4)": "DiamondLoupeFacet" },
  [{ _init: initFacet?.target, _calldata: functionCall }]
);

deployDiamondCloneWithCuts()

deployDiamondCloneWithCuts(salt, cuts, inits?, preApprovalCalls?): Promise<undefined | PropsDiamond>

Deploys a new diamond clone with specified cuts and initializations.

Parameters

salt: bigint

cuts: DiamondCut[]

The diamond cuts to apply.

inits?: PropsInitCall[]

Initialization calls to make after deployment.

preApprovalCalls?: PropsPreApprovalCall[]

Returns

Promise<undefined | PropsDiamond>

The deployed diamond or undefined.

Method

deployDiamondCloneWithCuts

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["DiamondLoupeFacet", "PropsERC1155"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Add,
  facets,
  [],
  []
);

const initCalls = [
  await diamondManager.createFacetInit(
    "PropsERC1155",
    "init",
    ["NAME", "SYMBOL", "DESCRIPTION", "ipfs://baseuricid/", "ipfs://contracturicid"]
  )
];

const deployedDiamond = await diamondManager.deployDiamondCloneWithCuts(
  diamondCuts,
  initCalls
);

executeDiamondCuts()

executeDiamondCuts(cuts, inits?, waitForEvent?, waitForEventTypes?): Promise<any>

Executes diamond cuts on the diamond.

Parameters

cuts: DiamondCut[]

The cuts to execute.

inits?: PropsInitCall[]

Initialization calls to make after the cuts.

waitForEvent?: string

Event to wait for after the cuts.

waitForEventTypes?: string[]

Types of the event to wait for.

Returns

Promise<any>

The transaction result.

Method

executeDiamondCuts

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Add,
  facets,
  [],
  []
);

const initCalls = [
  await diamondManager.createFacetInit(
    "PropsERC1155CreatorSplits",
    "init",
    ["NAME", "SYMBOL", "DESCRIPTION", "ipfs://baseuricid/", "ipfs://contracturicid"]
  )
];

const txResult = await diamondManager.executeDiamondCuts(
  diamondCuts,
  initCalls
);
console.log("Transaction result:", txResult);

executeMulticallDiamondCuts()

executeMulticallDiamondCuts(cuts, inits?, waitForEvent?, waitForEventTypes?): Promise<any>

Executes multiple diamond cuts in a single transaction using multicall.

Parameters

cuts: DiamondCut[][]

The cuts to execute.

inits?: PropsInitCall[][]

Initialization calls to make after the cuts.

waitForEvent?: string

Event to wait for after the cuts.

waitForEventTypes?: string[]

Types of the event to wait for.

Returns

Promise<any>

The transaction result.

Method

executeMulticallDiamondCuts

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Add,
  facets,
  [],
  []
);

const initCalls = [
  await diamondManager.createFacetInit(
    "PropsERC1155CreatorSplits",
    "init",
    ["NAME", "SYMBOL", "DESCRIPTION", "ipfs://baseuricid/", "ipfs://contracturicid"]
  )
];

const txResult = await diamondManager.executeMulticallDiamondCuts(
  [diamondCuts],
  [initCalls]
);
console.log("Transaction result:", txResult);

formatExternalInitCalls()

formatExternalInitCalls(inits?): PropsInitCall[]

Formats the initialization calls.

Parameters

inits?: PropsInitCall[]

The initialization calls to format.

Returns

PropsInitCall[]

The formatted initialization calls.

Method

formatExternalInitCalls

Example

typescript
const externalInitCalls = [
  {
    _init: "0x1234...",
    _calldata: "0xabcd..."
  },
  {
    _init: "0x5678...",
    _calldata: "0xef01..."
  }
];
const formattedExternalInitCalls = diamondManager.formatExternalInitCalls(externalInitCalls);
console.log("Formatted external init calls:", formattedExternalInitCalls);

formatInitCalls()

formatInitCalls(inits?): PropsInitCall[]

Formats the initialization calls.

Parameters

inits?: PropsInitCall[]

The initialization calls to format.

Returns

PropsInitCall[]

The formatted initialization calls.

Method

formatInitCalls

Example

typescript
const initCalls = [
  {
    _init: "0x1234...",
    _calldata: "0xabcd..."
  },
  {
    _init: "0x5678...",
    _calldata: "0xef01..."
  }
];
const formattedInitCalls = diamondManager.formatInitCalls(initCalls);
console.log("Formatted init calls:", formattedInitCalls);

generateDiamondABI()

generateDiamondABI(): Promise<undefined | any[]>

Generates a combined ABI for the entire diamond, including all installed facets.

Returns

Promise<undefined | any[]>

The combined ABI or undefined.

Method

generateDiamondABI

Example

typescript
const diamondABI = await diamondManager.generateDiamondABI();
if (diamondABI) {
  console.log("Combined Diamond ABI:", JSON.stringify(diamondABI, null, 2));
}

getCallableContractByFacetName()

getCallableContractByFacetName(facetName, contractAddress?): Promise<undefined | Contract>

Gets a callable contract instance for a given facet name.

Parameters

facetName: string

The name of the facet.

contractAddress?: string

Optional contract address to use instead of the diamond address.

Returns

Promise<undefined | Contract>

The callable contract or undefined.

Method

getCallableContractByFacetName

Example

typescript
const contract = await diamondManager.getCallableContractByFacetName("PropsERC1155");
if (contract) {
  const symbol = await contract.symbol();
  console.log("ERC1155 token symbol:", symbol);
}

getCallableContractByFacetObj()

getCallableContractByFacetObj(facet): Promise<undefined | Contract>

Gets a callable contract instance for a given facet object.

Parameters

facet: PropsFacet

The facet object.

Returns

Promise<undefined | Contract>

The callable contract or undefined.

Method

getCallableContractByFacetObj

Example

typescript
const facet = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetByName("PropsERC1155");
const contract = await diamondManager.getCallableContractByFacetObj(facet);
if (contract) {
  const name = await contract.name();
  console.log("ERC1155 token name:", name);
}

getCallableContractForDiamond()

getCallableContractForDiamond(): Promise<undefined | Contract>

Gets a callable contract instance for the entire diamond, including all installed facets.

Returns

Promise<undefined | Contract>

The callable contract or undefined.

Method

getCallableContractForDiamond

Example

typescript
const diamondContract = await diamondManager.getCallableContractForDiamond();
if (diamondContract) {
  const owner = await diamondContract.owner();
  console.log("Diamond owner:", owner);
  const tokenURI = await diamondContract.uri(1);
  console.log("Token URI for ID 1:", tokenURI);
}

getDiamond()

getDiamond(): undefined | PropsDiamond

Gets the current diamond from the configuration.

Returns

undefined | PropsDiamond

The current diamond or undefined.

Method

getDiamond

Example

typescript
const currentDiamond = diamondManager.getDiamond();
if (currentDiamond) {
  console.log("Current diamond address:", currentDiamond.contract?.target);
}

getDiamondOwner()

getDiamondOwner(): Promise<string>

Gets the owner of the diamond.

Returns

Promise<string>

The address of the diamond owner.

Method

getDiamondOwner

Example

typescript
const ownerAddress = await diamondManager.getDiamondOwner();
console.log("Diamond owner:", ownerAddress);

getPlaformManager()

getPlaformManager(): undefined | PlatformManager

Gets the platform manager.

Returns

undefined | PlatformManager

The platform manager or undefined.

Method

getPlaformManager

Example

typescript
const platformManager = diamondManager.getPlaformManager();
if (platformManager) {
  const facetCatalog = await platformManager.getCatalogManager().getFacetCatalog();
}

prepCutsAndInterfaceIdChangeSetFromCuts()

prepCutsAndInterfaceIdChangeSetFromCuts(cuts): Promise<object>

Prepares cuts and interface ID change set from the given cuts.

Parameters

cuts: DiamondCut[]

The cuts to prepare.

Returns

Promise<object>

The prepared cuts and interface changes.

addInterfaces

addInterfaces: string[]

cuts

cuts: DiamondCut[]

removeInterfaces

removeInterfaces: string[]

Method

prepCutsAndInterfaceIdChangeSetFromCuts

Example

typescript
const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Add,
  facets,
  [],
  []
);

const { cuts, addInterfaces, removeInterfaces} = await diamondManager.prepCutsAndInterfaceIdChangeSetFromCuts(diamondCuts);
console.log("Prepared cuts:", cuts);
console.log("addInterfaces ID change set:", addInterfaces);
console.log("removeInterfaces ID change set:", removeInterfaces);

removeFacetsFromDiamond()

removeFacetsFromDiamond(facets, includeSelectors?, excludeSelectors?, priorities?, inits?, waitForEvent?, waitForEventTypes?): Promise<undefined | PropsDiamond>

Removes facets from the diamond.

Parameters

facets: PropsFacet[]

The facets to remove.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

priorities?: any

Priorities for the cuts.

inits?: PropsInitCall[]

Initialization calls to make after the removal.

waitForEvent?: string

Event to wait for after the removal.

waitForEventTypes?: string[]

Types of the event to wait for.

Returns

Promise<undefined | PropsDiamond>

The updated diamond or undefined.

Method

removeFacetsFromDiamond

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Remove,
  facets,
  [],
  []
);

const updatedDiamond = await diamondManager.removeFacetsFromDiamond(
  facets,
  [],
  []
);

replaceFacetsOnDiamond()

replaceFacetsOnDiamond(facets, includeSelectors?, excludeSelectors?, priorities?, inits?, waitForEvent?, waitForEventTypes?): Promise<undefined | PropsDiamond>

Replaces facets on the diamond.

Parameters

facets: PropsFacet[]

The facets to replace.

includeSelectors?: string[] = []

Selectors to include.

excludeSelectors?: string[] = []

Selectors to exclude.

priorities?: any

Priorities for the cuts.

inits?: PropsInitCall[]

Initialization calls to make after the replacement.

waitForEvent?: string

Event to wait for after the replacement.

waitForEventTypes?: string[]

Types of the event to wait for.

Returns

Promise<undefined | PropsDiamond>

The updated diamond or undefined.

Method

replaceFacetsOnDiamond

Example

typescript
const facets = await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
  ["PropsERC1155CreatorSplits"]
);

const diamondCuts = await diamondManager.createDiamondCuts(
  FacetCutAction.Replace,
  facets,
  [],
  []
);

const initCalls = [
  await diamondManager.createFacetInit(
    "PropsERC1155CreatorSplits",
    "init",
    ["NAME", "SYMBOL", "DESCRIPTION", "ipfs://baseuricid/", "ipfs://contracturicid"]
  )
];

const updatedDiamond = await diamondManager.replaceFacetsOnDiamond(
  facets,
  [],
  [],
  undefined,
  initCalls
);

setDiamond()

setDiamond(diamond): void

Sets the current diamond in the configuration.

Parameters

diamond: undefined | PropsDiamond

The diamond to set.

Returns

void

Method

setDiamond

Example

typescript
const diamond = {
  contract: deployedDiamondContract,
  // other diamond properties
};
diamondManager.setDiamond(diamond);

updateFacetRegistrationOnDiamond()

updateFacetRegistrationOnDiamond(cuts): void

Updates the facet registration on the diamond.

Parameters

cuts: DiamondCut[]

The diamond cuts to apply.

Returns

void

Method

updateFacetRegistrationOnDiamond