# ProjectRegistry

# Overview

This contract tracks all projects and their deployments. At the beginning of the network, we will start with the restrict mode which only allow permissioned account to create and update project. Indexers are able to start and stop service with a specific deployment from this conttact. Also Indexers can update and report their service status from this contarct.

# STATES

# settings

ISettings contract which stores SubProject network contracts address

contract ISettings settings

# nextProjectId

next project id

uint256 nextProjectId

# creatorRestricted

is the contract run in creator restrict mode. If in creator restrict mode, only permissioned account allowed to create and update project

mapping(enum ProjectType => bool) creatorRestricted

# creatorWhitelist

account address -> is creator

mapping(address => bool) creatorWhitelist

# projectInfos

project ids -> ProjectInfo

mapping(uint256 => struct ProjectInfo) projectInfos

# deploymentInfos

deployment id -> deployment info

mapping(bytes32 => struct DeploymentInfo) deploymentInfos

# deploymentStatusByIndexer

deployment id -> indexer -> ServiceStatus

mapping(bytes32 => mapping(address => enum ServiceStatus)) deploymentStatusByIndexer

# numberOfDeployments

indexer -> deployment numbers

mapping(address => uint256) numberOfDeployments

EVENTS

# ProjectCreated

Emitted when project created.

event ProjectCreated(address creator, uint256 projectId, string projectMetadata, enum ProjectType projectType, bytes32 deploymentId, bytes32 deploymentMetadata)

# ProjectMetadataUpdated

Emitted when the metadata of the project updated.

event ProjectMetadataUpdated(address owner, uint256 projectId, string metadata)

# ProjectDeploymentUpdated

Emitted when the latestDeploymentId of the project updated.

event ProjectDeploymentUpdated(address owner, uint256 projectId, bytes32 deploymentId, bytes32 metadata)

# ProjectLatestDeploymentUpdated

Emitted when project latest deployment updated.

event ProjectLatestDeploymentUpdated(address owner, uint256 projectId, bytes32 deploymentId)

# ServiceStatusChanged

Emitted when service status changed with a specific deploymentId.

event ServiceStatusChanged(address indexer, bytes32 deploymentId, enum ServiceStatus status)

MODIFIER

# onlyIndexer

only indexer can call

modifier onlyIndexer()

# FUNCTIONS

# initialize

Initialize the contract

function initialize(contract ISettings _settings) external
Name Type Description
_settings contract ISettings ISettings contract

# setSettings

function setSettings(contract ISettings _settings) external

# setCreatorRestricted

set the mode to restrict or not restrict mode -- only permissioned accounts allowed to create project

function setCreatorRestricted(enum ProjectType _type, bool _creatorRestricted) external

# addCreator

set account to creator account that allow to create project

function addCreator(address creator) external

# removeCreator

remove creator account

function removeCreator(address creator) external

Base URI for computing {tokenURI}. If set, the resulting URI for each token will be the concatenation of the baseURI and the tokenId. Empty by default, can be overridden in child contracts.

# _baseURI

function _baseURI() internal view virtual returns (string)

# _beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize) internal

# tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

# supportsInterface

function supportsInterface(bytes4 interfaceId) public view returns (bool)

# _burn

function _burn(uint256 tokenId) internal

# createProject

create a project, if in the restrict mode, only creator allowed to call this function

function createProject(string projectMetadataUri, bytes32 deploymentMetdata, bytes32 deploymentId, enum ProjectType projectType) external

# updateProjectMetadata

update the Metadata of a project, if in the restrict mode, only creator allowed call this function

function updateProjectMetadata(uint256 projectId, string metadataUri) external

# _updateProjectLatestDeployment

function _updateProjectLatestDeployment(uint256 projectId, bytes32 deploymentId) internal

# addOrUpdateDeployment

add a deployment to a project.

function addOrUpdateDeployment(uint256 projectId, bytes32 deploymentId, bytes32 metadata, bool updateLatest) external

# setProjectLatestDeployment

function setProjectLatestDeployment(uint256 projectId, bytes32 deploymentId) external

# startService

Indexer update its service status to ready with a specific deploymentId

function startService(bytes32 deploymentId) external

# stopService

Indexer stop service with a specific deploymentId

function stopService(bytes32 deploymentId) external

# isServiceAvailable

is the indexer available to provide service with a specific deploymentId

function isServiceAvailable(bytes32 deploymentId, address indexer) external view returns (bool)