DocumentTemplateFacet
Handles template management and instance creation
Template facet for DocumentRegistry diamond
Functions
registerTemplate
Register a new template and approve it
function registerTemplate(bytes32 hash, string calldata uri) external returns (bytes32 templateHash);
Parameters
hash
bytes32
The hash of the template
uri
string
The URI pointing to the template location
Returns
templateHash
bytes32
The hash of the registered template
createInstance
Create an instance from a template
function createInstance(bytes32 templateHash, string calldata uri) external returns (bytes32 instanceHash);
Parameters
templateHash
bytes32
The hash of the template to use
uri
string
The URI for the instance document
Returns
instanceHash
bytes32
The hash of the created instance
registerInstanceAndSign
Register instance and sign it in one transaction
function registerInstanceAndSign(bytes32 templateHash, string calldata uri) external returns (bytes32 instanceHash);
Parameters
templateHash
bytes32
The hash of the template to use
uri
string
The URI for the instance document
Returns
instanceHash
bytes32
The hash of the created and signed instance
getAllTemplates
Get all approved templates
function getAllTemplates() external view returns (bytes32[] memory);
Returns
<none>
bytes32[]
Array of template hashes
isTemplateApproved
Check if a template is approved
function isTemplateApproved(bytes32 templateHash) external view returns (bool approved);
Parameters
templateHash
bytes32
The template hash to check
Returns
approved
bool
Whether the template is approved
getTemplateOwner
Get template owner
function getTemplateOwner(bytes32 templateHash) external view returns (address owner);
Parameters
templateHash
bytes32
The template hash
Returns
owner
address
The template owner address
getTemplateInstances
Get all instances created from a template
function getTemplateInstances(bytes32 templateHash) external view returns (bytes32[] memory instances);
Parameters
templateHash
bytes32
The template hash
Returns
instances
bytes32[]
Array of instance hashes
revokeTemplate
Revoke a template (only template owner)
function revokeTemplate(bytes32 templateHash) external;
Parameters
templateHash
bytes32
The template hash to revoke
Events
TemplateApproved
event TemplateApproved(bytes32 indexed templateHash, address indexed owner);
TemplateRevoked
event TemplateRevoked(bytes32 indexed templateHash, address indexed owner);
InstanceCreated
event InstanceCreated(bytes32 indexed instanceHash, bytes32 indexed templateHash, address indexed owner);
InstanceSignedAndRegistered
event InstanceSignedAndRegistered(bytes32 indexed instanceHash, bytes32 indexed templateHash, address indexed signer);
Last updated
Was this helpful?