Comment on page
This contract represents the manufacturer of a vehicle or of an aftermarket device. A manufacturer is always a root node (no parent node), from which all other nodes derive directly or indirectly.
Because of the relevance of what a root represents, there are only two possible owner types: an admin of the system or a controller, which is also set by an admin. Although the system allows a controller to own only a single manufacturer node, in the early stages of the DIMO identity, all manufacturer nodes will be minted and owned by an admin. In the future, the ownership of those nodes will be transferred to the right controller.
Since many nodes will be created at once, an admin can invoke the following function to perform a batch mint:
function mintManufacturerBatch(address _owner, string calldata names)
Unless an administrator, controllers can only own a single manufacturer node and, consequently, a single manufacturer ID.
To prevent a controller from possessing more than one node, we keep track of minted nodes by controller and restrict transfers in the
ManufacturerIdcontract. When any transfer function is invoked in the NFT contract, an external call is made to the
Manufacturernode through the function
setManufacturerMintedto verify if the recipient is allowed to possess a manufacturer node and, then, to set the recipient as "already minted".
Besides the NFT ID, the
Manufacturernodes also have a mandatory
nameassociated with them. In order to prevent duplicated nodes, two mappings are employed to verify existing data before minting:
// Manufacturer name => Manufacturer Id
mapping(string => uint256) manufacturerNameToNodeId;
// Manufacturer Id => Manufacturer name
mapping(uint256 => string) nodeIdToManufacturerName;
Whenever a new
Manufacturernode is about to be created, the new manufacturer
nameis verified against the existing ones to ensure the new
nameis not associated with an ID. It also facilitates external interfaces to query the
namesand IDs of the nodes.