github.com/status-im/status-go@v1.1.0/contracts/registrar/Registrar.sol (about) 1 // This solidity file was added to the project to generate the ABI to consume 2 // the smart contract deployed at 0xDB5ac1a559b02E12F29fC0eC0e37Be8E046DEF49 3 4 pragma solidity ^0.4.24; 5 6 contract Controlled { 7 address public controller; 8 9 /// @notice Changes the controller of the contract 10 /// @param _newController The new controller of the contract 11 function changeController(address _newController) public; 12 } 13 14 contract ApproveAndCallFallBack { 15 function receiveApproval( 16 address from, 17 uint256 _amount, 18 address _token, 19 bytes _data 20 ) public; 21 } 22 23 contract UsernameRegistrar is Controlled, ApproveAndCallFallBack { 24 address public token; 25 address public ensRegistry; 26 address public resolver; 27 address public parentRegistry; 28 29 uint256 public constant releaseDelay = 365 days; 30 mapping(bytes32 => Account) public accounts; 31 mapping(bytes32 => SlashReserve) reservedSlashers; 32 33 //Slashing conditions 34 uint256 public usernameMinLength; 35 bytes32 public reservedUsernamesMerkleRoot; 36 37 event RegistryState(RegistrarState state); 38 event RegistryPrice(uint256 price); 39 event RegistryMoved(address newRegistry); 40 event UsernameOwner(bytes32 indexed nameHash, address owner); 41 42 enum RegistrarState { 43 Inactive, 44 Active, 45 Moved 46 } 47 bytes32 public ensNode; 48 uint256 public price; 49 RegistrarState public state; 50 uint256 public reserveAmount; 51 52 struct Account { 53 uint256 balance; 54 uint256 creationTime; 55 address owner; 56 } 57 58 struct SlashReserve { 59 address reserver; 60 uint256 blockNumber; 61 } 62 63 /** 64 * @notice Registers `_label` username to `ensNode` setting msg.sender as owner. 65 * Terms of name registration: 66 * - SNT is deposited, not spent; the amount is locked up for 1 year. 67 * - After 1 year, the user can release the name and receive their deposit back (at any time). 68 * - User deposits are completely protected. The contract controller cannot access them. 69 * - User's address(es) will be publicly associated with the ENS name. 70 * - User must authorise the contract to transfer `price` `token.name()` on their behalf. 71 * - Usernames registered with less then `usernameMinLength` characters can be slashed. 72 * - Usernames contained in the merkle tree of root `reservedUsernamesMerkleRoot` can be slashed. 73 * - Usernames starting with `0x` and bigger then 12 characters can be slashed. 74 * - If terms of the contract change—e.g. Status makes contract upgrades—the user has the right to release the username and get their deposit back. 75 * @param _label Choosen unowned username hash. 76 * @param _account Optional address to set at public resolver. 77 * @param _pubkeyA Optional pubkey part A to set at public resolver. 78 * @param _pubkeyB Optional pubkey part B to set at public resolver. 79 */ 80 function register( 81 bytes32 _label, 82 address _account, 83 bytes32 _pubkeyA, 84 bytes32 _pubkeyB 85 ) external returns (bytes32 namehash); 86 87 /** 88 * @notice Release username and retrieve locked fee, needs to be called 89 * after `releasePeriod` from creation time by ENS registry owner of domain 90 * or anytime by account owner when domain migrated to a new registry. 91 * @param _label Username hash. 92 */ 93 function release(bytes32 _label) external; 94 95 /** 96 * @notice update account owner, should be called by new ens node owner 97 * to update this contract registry, otherwise former owner can release 98 * if domain is moved to a new registry. 99 * @param _label Username hash. 100 **/ 101 function updateAccountOwner(bytes32 _label) external; 102 103 /** 104 * @notice secretly reserve the slashing reward to `msg.sender` 105 * @param _secret keccak256(abi.encodePacked(namehash, creationTime, reserveSecret)) 106 */ 107 function reserveSlash(bytes32 _secret) external; 108 109 /** 110 * @notice Slash username smaller then `usernameMinLength`. 111 * @param _username Raw value of offending username. 112 */ 113 function slashSmallUsername(string _username, uint256 _reserveSecret) 114 external; 115 116 /** 117 * @notice Slash username starting with "0x" and with length greater than 12. 118 * @param _username Raw value of offending username. 119 */ 120 function slashAddressLikeUsername(string _username, uint256 _reserveSecret) 121 external; 122 123 /** 124 * @notice Slash username that is exactly a reserved name. 125 * @param _username Raw value of offending username. 126 * @param _proof Merkle proof that name is listed on merkle tree. 127 */ 128 function slashReservedUsername( 129 string _username, 130 bytes32[] _proof, 131 uint256 _reserveSecret 132 ) external; 133 134 /** 135 * @notice Slash username that contains a non alphanumeric character. 136 * @param _username Raw value of offending username. 137 * @param _offendingPos Position of non alphanumeric character. 138 */ 139 function slashInvalidUsername( 140 string _username, 141 uint256 _offendingPos, 142 uint256 _reserveSecret 143 ) external; 144 145 /** 146 * @notice Clear resolver and ownership of unowned subdomians. 147 * @param _labels Sequence to erase. 148 */ 149 function eraseNode(bytes32[] _labels) external; 150 151 /** 152 * @notice Migrate account to new registry, opt-in to new contract. 153 * @param _label Username hash. 154 **/ 155 function moveAccount(bytes32 _label, UsernameRegistrar _newRegistry) 156 external; 157 158 /** 159 * @notice Activate registration. 160 * @param _price The price of registration. 161 */ 162 function activate(uint256 _price) external; 163 164 /** 165 * @notice Updates Public Resolver for resolving users. 166 * @param _resolver New PublicResolver. 167 */ 168 function setResolver(address _resolver) external; 169 170 /** 171 * @notice Updates registration price. 172 * @param _price New registration price. 173 */ 174 function updateRegistryPrice(uint256 _price) external; 175 176 /** 177 * @notice Transfer ownership of ensNode to `_newRegistry`. 178 * Usernames registered are not affected, but they would be able to instantly release. 179 * @param _newRegistry New UsernameRegistrar for hodling `ensNode` node. 180 */ 181 function moveRegistry(UsernameRegistrar _newRegistry) external; 182 183 /** 184 * @notice Opt-out migration of username from `parentRegistry()`. 185 * Clear ENS resolver and subnode owner. 186 * @param _label Username hash. 187 */ 188 function dropUsername(bytes32 _label) external; 189 190 /** 191 * @notice Withdraw not reserved tokens 192 * @param _token Address of ERC20 withdrawing excess, or address(0) if want ETH. 193 * @param _beneficiary Address to send the funds. 194 **/ 195 function withdrawExcessBalance(address _token, address _beneficiary) 196 external; 197 198 /** 199 * @notice Withdraw ens nodes not belonging to this contract. 200 * @param _domainHash Ens node namehash. 201 * @param _beneficiary New owner of ens node. 202 **/ 203 function withdrawWrongNode(bytes32 _domainHash, address _beneficiary) 204 external; 205 206 /** 207 * @notice Gets registration price. 208 * @return Registration price. 209 **/ 210 function getPrice() external view returns (uint256 registryPrice); 211 212 /** 213 * @notice reads amount tokens locked in username 214 * @param _label Username hash. 215 * @return Locked username balance. 216 **/ 217 function getAccountBalance(bytes32 _label) 218 external 219 view 220 returns (uint256 accountBalance); 221 222 /** 223 * @notice reads username account owner at this contract, 224 * which can release or migrate in case of upgrade. 225 * @param _label Username hash. 226 * @return Username account owner. 227 **/ 228 function getAccountOwner(bytes32 _label) 229 external 230 view 231 returns (address owner); 232 233 /** 234 * @notice reads when the account was registered 235 * @param _label Username hash. 236 * @return Registration time. 237 **/ 238 function getCreationTime(bytes32 _label) 239 external 240 view 241 returns (uint256 creationTime); 242 243 /** 244 * @notice calculate time where username can be released 245 * @param _label Username hash. 246 * @return Exact time when username can be released. 247 **/ 248 function getExpirationTime(bytes32 _label) 249 external 250 view 251 returns (uint256 releaseTime); 252 253 /** 254 * @notice calculate reward part an account could payout on slash 255 * @param _label Username hash. 256 * @return Part of reward 257 **/ 258 function getSlashRewardPart(bytes32 _label) 259 external 260 view 261 returns (uint256 partReward); 262 263 /** 264 * @notice Support for "approveAndCall". Callable only by `token()`. 265 * @param _from Who approved. 266 * @param _amount Amount being approved, need to be equal `getPrice()`. 267 * @param _token Token being approved, need to be equal `token()`. 268 * @param _data Abi encoded data with selector of `register(bytes32,address,bytes32,bytes32)`. 269 */ 270 function receiveApproval( 271 address _from, 272 uint256 _amount, 273 address _token, 274 bytes _data 275 ) public; 276 277 /** 278 * @notice Continues migration of username to new registry. 279 * @param _label Username hash. 280 * @param _tokenBalance Amount being transfered from `parentRegistry()`. 281 * @param _creationTime Time user registrated in `parentRegistry()` is preserved. 282 * @param _accountOwner Account owner which migrated the account. 283 **/ 284 function migrateUsername( 285 bytes32 _label, 286 uint256 _tokenBalance, 287 uint256 _creationTime, 288 address _accountOwner 289 ) external; 290 291 /** 292 * @dev callable only by parent registry to continue migration 293 * of registry and activate registration. 294 * @param _price The price of registration. 295 **/ 296 function migrateRegistry(uint256 _price) external; 297 }