You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB
Solidity

2 years ago
//SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Git3NameService {
mapping(string => address) public nameHub;
2 years ago
mapping(address => string) public hubName;
2 years ago
mapping(string => address) public nameOwner;
string[] public nameList;
mapping(address => mapping(string => string)) public HubRecords;
constructor() {}
modifier onlyHubOwner(string memory name) {
require(nameOwner[name] == msg.sender, "Only name owner can do this");
_;
}
function registerHub(string memory name, address hub) public {
require(nameHub[name] == address(0), "Name already registered");
nameHub[name] = hub;
2 years ago
hubName[hub] = name;
2 years ago
nameOwner[name] = msg.sender;
nameList.push(name);
}
function nameListLength() public view returns (uint256) {
return nameList.length;
}
function rebindHubAddress(
string memory name,
address hub
) public onlyHubOwner(name) {
nameHub[name] = hub;
2 years ago
hubName[hub] = name;
2 years ago
}
function transferNameOwner(
string memory name,
address newOwner
) public onlyHubOwner(name) {
nameOwner[name] = newOwner;
}
}