Skip to main content

DiamondBase

Asset Tokenization Studio Team

DiamondBase

Abstract base for the Diamond facet that combines DiamondCut + DiamondLoupe with initialisation support via initializeDiamondCut.

Inherits from existing DiamondCut and DiamondLoupe abstracts and adds the initialiser function that registers the facet with the centralised InitializerStorageWrapper.

Methods​

getConfigInfo​

function getConfigInfo() external view returns (address resolver_, bytes8 proxyVersion_, bytes32 configurationId_, uint256 configurationVersion_, bool replacementEnabled_)

Returns the active resolver address, configuration identifier, and version.

Returns​

NameTypeDescription
resolver_addressAddress of the current Business Logic Resolver.
proxyVersion_bytes8proxy version.
configurationId_bytes32Identifier of the active configuration.
configurationVersion_uint256Version number of the active configuration.
replacementEnabled_boolWhether replacement is enabled.

getFacet​

function getFacet(bytes32 _facetId) external view returns (struct IDiamondLoupe.Facet facet_)

Get the information associated with an specific facet

If facet is not found return empty Facet struct

Parameters​

NameTypeDescription
_facetIdbytes32The facet key for the resolver

Returns​

NameTypeDescription
facet_IDiamondLoupe.FacetFacet data

getFacetAddress​

function getFacetAddress(bytes4 _selector) external view returns (address facetAddress_)

Gets the facet that supports the given selector

If facet is not found return address(0)

Parameters​

NameTypeDescription
_selectorbytes4The function selector

Returns​

NameTypeDescription
facetAddress_addressThe facet address

getFacetAddresses​

function getFacetAddresses() external view returns (address[] facetAddresses_)

Get all the facet addresses used by a resolverProxy

Returns​

NameTypeDescription
facetAddresses_address[]facetAddresses_

getFacetAddressesByPage​

function getFacetAddressesByPage(uint256 _pageIndex, uint256 _pageLength) external view returns (address[] facetAddresses_)

Get all the facet addresses used by a resolverProxy

Parameters​

NameTypeDescription
_pageIndexuint256members to skip : _pageIndex * _pageLength
_pageLengthuint256number of members to return

Returns​

NameTypeDescription
facetAddresses_address[]facetAddresses_

getFacetIdBySelector​

function getFacetIdBySelector(bytes4 _selector) external view returns (bytes32 facetId_)

Returns the facet identifier registered for a function selector.

Reads resolver-proxy selector metadata and returns zero when the selector is absent.

Parameters​

NameTypeDescription
_selectorbytes4Function selector to resolve.

Returns​

NameTypeDescription
facetId_bytes32Facet identifier associated with the selector.

getFacetIds​

function getFacetIds() external view returns (bytes32[] facetIds_)

Get all the facet addresses used by a resolverProxy

Returns​

NameTypeDescription
facetIds_bytes32[]facetIds_

getFacetIdsByPage​

function getFacetIdsByPage(uint256 _pageIndex, uint256 _pageLength) external view returns (bytes32[] facetIds_)

Get all the facet addresses used by a resolverProxy

Parameters​

NameTypeDescription
_pageIndexuint256members to skip : _pageIndex * _pageLength
_pageLengthuint256number of members to return

Returns​

NameTypeDescription
facetIds_bytes32[]facetIds_

getFacetSelectors​

function getFacetSelectors(bytes32 _facetId) external view returns (bytes4[] facetSelectors_)

Gets all the function selectors supported by a specific facet.

Parameters​

NameTypeDescription
_facetIdbytes32The facet key for the resolver.

Returns​

NameTypeDescription
facetSelectors_bytes4[]facetSelectors_

getFacetSelectorsByPage​

function getFacetSelectorsByPage(bytes32 _facetId, uint256 _pageIndex, uint256 _pageLength) external view returns (bytes4[] facetSelectors_)

Gets all the function selectors supported by a specific facet.

Parameters​

NameTypeDescription
_facetIdbytes32The facet key for the resolver.
_pageIndexuint256members to skip : _pageIndex * _pageLength
_pageLengthuint256number of members to return

Returns​

NameTypeDescription
facetSelectors_bytes4[]facetSelectors_

getFacetSelectorsLength​

function getFacetSelectorsLength(bytes32 _facetId) external view returns (uint256 facetSelectorsLength_)

Gets the function selectors length.

Parameters​

NameTypeDescription
_facetIdbytes32The facet key for the resolver.

Returns​

NameTypeDescription
facetSelectorsLength_uint256facetSelectorsLength_

getFacets​

function getFacets() external view returns (struct IDiamondLoupe.Facet[] facets_)

Gets all facet addresses and their four byte function selectors.

Returns​

NameTypeDescription
facets_IDiamondLoupe.Facet[]Facet

getFacetsByPage​

function getFacetsByPage(uint256 _pageIndex, uint256 _pageLength) external view returns (struct IDiamondLoupe.Facet[] facets_)

Gets all facet addresses and their four byte function selectors.

Parameters​

NameTypeDescription
_pageIndexuint256members to skip : _pageIndex * _pageLength
_pageLengthuint256number of members to return

Returns​

NameTypeDescription
facets_IDiamondLoupe.Facet[]Facet

getFacetsLength​

function getFacetsLength() external view returns (uint256 facetsLength_)

Gets facet length.

Returns​

NameTypeDescription
facetsLength_uint256Facets length

getStaticFunctionSelectors​

function getStaticFunctionSelectors() external pure returns (bytes4[] staticFunctionSelectors_)

Gets all function selectors of a facet

Returns​

NameTypeDescription
staticFunctionSelectors_bytes4[]Face functions selectors

getStaticInterfaceIds​

function getStaticInterfaceIds() external pure returns (bytes4[] staticInterfaceIds_)

Gets all interfaces ids of a facet.

Returns​

NameTypeDescription
staticInterfaceIds_bytes4[]Face interface ids

getStaticResolverKey​

function getStaticResolverKey() external pure returns (bytes32 staticResolverKey_)

Gets the static resolver key

Returns​

NameTypeDescription
staticResolverKey_bytes32Static resolver key

initializeDiamondCut​

function initializeDiamondCut() external nonpayable

Initialises the diamond facet and registers it in the initialiser registry.

Callable once; subsequent calls revert with FacetAlreadyRegistered. Requires DEFAULT_ADMIN_ROLE. Called by the factory during deployment.

supportsInterface​

function supportsInterface(bytes4 _interfaceId) external view returns (bool)

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

Parameters​

NameTypeDescription
_interfaceIdbytes4undefined

Returns​

NameTypeDescription
_0boolundefined

updateConfig​

function updateConfig(bytes32 _newConfigurationId, uint256 _newVersion) external nonpayable

For the current BLR, update its configuration identifier and version.

Requires DEFAULT_ADMIN_ROLE and validates the configuration before storing the new configuration identifier and pinned version. The admin is responsible for confirming that _newConfigurationId is compatible with the currently active configuration before calling this function; no on-chain compatibility check is performed.

Parameters​

NameTypeDescription
_newConfigurationIdbytes32The new configuration identifier to apply.
_newVersionuint256The version number associated with the new configuration.

updateConfigVersion​

function updateConfigVersion(uint256 _newVersion) external nonpayable

For the current BLR and configuration, update the used version.

Requires DEFAULT_ADMIN_ROLE and preserves the active configuration identifier and resolver while updating only the pinned configuration version.

Parameters​

NameTypeDescription
_newVersionuint256The new version number to set for the current configuration.

updateReplacementEnabled​

function updateReplacementEnabled(bool _newReplacementEnabled) external nonpayable

For the current BLR update its configuration

Parameters​

NameTypeDescription
_newReplacementEnabledboolThe replacement enabled flag to set*

updateResolver​

function updateResolver(contract IBusinessLogicResolver _newResolver, bytes32 _newConfigurationId, uint256 _newVersion, bool _newReplacementEnabled) external nonpayable

Replaces the Business Logic Resolver with a new one, setting configuration and version.

Requires DEFAULT_ADMIN_ROLE, validates _newResolver is a genuine IBusinessLogicResolver, and validates the target configuration against it before replacing the resolver pointer, configuration identifier and version. The admin is responsible for confirming business-key and configuration compatibility across the resolver switch before calling this function; no on-chain compatibility check is performed — _newResolver, _newConfigurationId and _newVersion are trusted as a deliberate, atomic choice by a trusted admin role.

Parameters​

NameTypeDescription
_newResolvercontract IBusinessLogicResolverThe new BLR contract address to wire into the proxy.
_newConfigurationIdbytes32The configuration identifier to activate on the new resolver.
_newVersionuint256The version number associated with the new configuration.
_newReplacementEnabledboolThe replacement enabled flag to set.

Events​

ConfigUpdated​

event ConfigUpdated(address indexed caller, bytes32 oldConfigurationId, bytes32 newConfigurationId, uint256 oldConfigurationVersion, uint256 newConfigurationVersion)

Emitted when the active configuration identifier is replaced.

updateConfig() combines an id change and a version change in one call; both get a complete old/new pair here.

Parameters​

NameTypeDescription
caller indexedaddressAccount that performed the update.
oldConfigurationIdbytes32Previous configuration identifier.
newConfigurationIdbytes32New configuration identifier.
oldConfigurationVersionuint256Previous configuration version.
newConfigurationVersionuint256Version activated for the new configuration.

ConfigVersionUpdated​

event ConfigVersionUpdated(address indexed caller, uint256 oldConfigurationVersion, uint256 newConfigurationVersion)

Emitted when the pinned version of the active configuration is replaced.

Parameters​

NameTypeDescription
caller indexedaddressAccount that performed the update.
oldConfigurationVersionuint256Previous configuration version.
newConfigurationVersionuint256New configuration version.

DiamondCutInitialized​

event DiamondCutInitialized()

Emitted once when the diamond facet is initialised.

Fires exclusively from initializeDiamondCut.

ReplacementEnabledUpdated​

event ReplacementEnabledUpdated(address indexed caller, bool oldReplacementEnabled, bool newReplacementEnabled)

Emitted when the replacement-enabled flag is replaced.

Parameters​

NameTypeDescription
caller indexedaddressAccount that performed the update.
oldReplacementEnabledboolPrevious replacement-enabled flag.
newReplacementEnabledboolNew replacement-enabled flag.

ResolverUpdated​

event ResolverUpdated(address indexed caller, address oldResolver, address newResolver, bytes32 oldConfigurationId, bytes32 newConfigurationId, uint256 oldConfigurationVersion, uint256 newConfigurationVersion, bool oldReplacementEnabled, bool newReplacementEnabled)

Emitted when the resolver-proxy's Business Logic Resolver is replaced.

updateResolver() combines four changes in one call; every one of them gets a complete old/new pair here rather than only the fields that happen to differ.

Parameters​

NameTypeDescription
caller indexedaddressAccount that performed the update.
oldResolveraddressPrevious Business Logic Resolver address.
newResolveraddressNew Business Logic Resolver address.
oldConfigurationIdbytes32Previous configuration identifier.
newConfigurationIdbytes32Configuration identifier activated on the new resolver.
oldConfigurationVersionuint256Previous configuration version.
newConfigurationVersionuint256Configuration version activated on the new resolver.
oldReplacementEnabledboolPrevious replacement-enabled flag.
newReplacementEnabledboolReplacement-enabled flag activated on the new resolver.

Errors​

AccountHasNoRole​

error AccountHasNoRole(address account, bytes32 role)

Thrown when an account does not hold a required role.

Parameters​

NameTypeDescription
accountaddressThe account that lacks the role.
rolebytes32The role that is not held.

FacetAlreadyRegistered​

error FacetAlreadyRegistered(bytes32 facetId, uint256 lastVersion)

Raised when an initialiser tries to register a facet that already has a non-zero last registered version (i.e. the facet is being re-initialised on a fresh install).

Parameters​

NameTypeDescription
facetIdbytes32Identifier of the offending facet.
lastVersionuint256Last version recorded for that facet at the time of the check.

InvalidBusinessLogicResolver​

error InvalidBusinessLogicResolver(address invalidResolver)

Thrown when a candidate resolver is the zero address or fails the isBusinessLogicResolver() identity check.

Parameters​

NameTypeDescription
invalidResolveraddressThe address that failed validation.

UnrecognizedResolverProxyVersion​

error UnrecognizedResolverProxyVersion(bytes8 _resolverProxyVersion)

Thrown when the provided proxy version does not match any BLR compatible standard.

Parameters​

NameTypeDescription
_resolverProxyVersionbytes8proxy version that is not compatible with the BLR.

WalletRecovered​

error WalletRecovered()

Thrown when attempting to recover a wallet that has already been recovered.