github.com/status-im/status-go@v1.1.0/contracts/resolver/resolver.sol (about) 1 // This solidity file was added to the project to generate the ABI to consume 2 // the smart contract deployed at 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e 3 4 pragma solidity >=0.4.24; 5 6 interface ENS { 7 // Logged when the owner of a node assigns a new owner to a subnode. 8 event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); 9 10 // Logged when the owner of a node transfers ownership to a new account. 11 event Transfer(bytes32 indexed node, address owner); 12 13 // Logged when the resolver for a node changes. 14 event NewResolver(bytes32 indexed node, address resolver); 15 16 // Logged when the TTL of a node changes 17 event NewTTL(bytes32 indexed node, uint64 ttl); 18 19 // Logged when an operator is added or removed. 20 event ApprovalForAll( 21 address indexed owner, 22 address indexed operator, 23 bool approved 24 ); 25 26 function setRecord( 27 bytes32 node, 28 address owner, 29 address resolver, 30 uint64 ttl 31 ) external; 32 33 function setSubnodeRecord( 34 bytes32 node, 35 bytes32 label, 36 address owner, 37 address resolver, 38 uint64 ttl 39 ) external; 40 41 function setSubnodeOwner( 42 bytes32 node, 43 bytes32 label, 44 address owner 45 ) external returns (bytes32); 46 47 function setResolver(bytes32 node, address resolver) external; 48 49 function setOwner(bytes32 node, address owner) external; 50 51 function setTTL(bytes32 node, uint64 ttl) external; 52 53 function setApprovalForAll(address operator, bool approved) external; 54 55 function owner(bytes32 node) external view returns (address); 56 57 function resolver(bytes32 node) external view returns (address); 58 59 function ttl(bytes32 node) external view returns (uint64); 60 61 function recordExists(bytes32 node) external view returns (bool); 62 63 function isApprovedForAll(address owner, address operator) 64 external 65 view 66 returns (bool); 67 } 68 69 /** 70 * The ENS registry contract. 71 */ 72 contract ENSRegistry is ENS { 73 struct Record { 74 address owner; 75 address resolver; 76 uint64 ttl; 77 } 78 79 /** 80 * @dev Sets the record for a node. 81 * @param node The node to update. 82 * @param owner The address of the new owner. 83 * @param resolver The address of the resolver. 84 * @param ttl The TTL in seconds. 85 */ 86 function setRecord( 87 bytes32 node, 88 address owner, 89 address resolver, 90 uint64 ttl 91 ) external; 92 93 /** 94 * @dev Sets the record for a subnode. 95 * @param node The parent node. 96 * @param label The hash of the label specifying the subnode. 97 * @param owner The address of the new owner. 98 * @param resolver The address of the resolver. 99 * @param ttl The TTL in seconds. 100 */ 101 function setSubnodeRecord( 102 bytes32 node, 103 bytes32 label, 104 address owner, 105 address resolver, 106 uint64 ttl 107 ) external; 108 109 /** 110 * @dev Transfers ownership of a node to a new address. May only be called by the current owner of the node. 111 * @param node The node to transfer ownership of. 112 * @param owner The address of the new owner. 113 */ 114 function setOwner(bytes32 node, address owner) public; 115 116 /** 117 * @dev Transfers ownership of a subnode keccak256(node, label) to a new address. May only be called by the owner of the parent node. 118 * @param node The parent node. 119 * @param label The hash of the label specifying the subnode. 120 * @param owner The address of the new owner. 121 */ 122 function setSubnodeOwner( 123 bytes32 node, 124 bytes32 label, 125 address owner 126 ) public returns (bytes32); 127 128 /** 129 * @dev Sets the resolver address for the specified node. 130 * @param node The node to update. 131 * @param resolver The address of the resolver. 132 */ 133 function setResolver(bytes32 node, address resolver) public; 134 135 /** 136 * @dev Sets the TTL for the specified node. 137 * @param node The node to update. 138 * @param ttl The TTL in seconds. 139 */ 140 function setTTL(bytes32 node, uint64 ttl) public; 141 142 /** 143 * @dev Enable or disable approval for a third party ("operator") to manage 144 * all of `msg.sender`'s ENS records. Emits the ApprovalForAll event. 145 * @param operator Address to add to the set of authorized operators. 146 * @param approved True if the operator is approved, false to revoke approval. 147 */ 148 function setApprovalForAll(address operator, bool approved) external; 149 150 /** 151 * @dev Returns the address that owns the specified node. 152 * @param node The specified node. 153 * @return address of the owner. 154 */ 155 function owner(bytes32 node) public view returns (address); 156 157 /** 158 * @dev Returns the address of the resolver for the specified node. 159 * @param node The specified node. 160 * @return address of the resolver. 161 */ 162 function resolver(bytes32 node) public view returns (address); 163 164 /** 165 * @dev Returns the TTL of a node, and any records associated with it. 166 * @param node The specified node. 167 * @return ttl of the node. 168 */ 169 function ttl(bytes32 node) public view returns (uint64); 170 171 /** 172 * @dev Returns whether a record has been imported to the registry. 173 * @param node The specified node. 174 * @return Bool if record exists 175 */ 176 function recordExists(bytes32 node) public view returns (bool); 177 178 /** 179 * @dev Query if an address is an authorized operator for another address. 180 * @param owner The address that owns the records. 181 * @param operator The address that acts on behalf of the owner. 182 * @return True if `operator` is an approved operator for `owner`, false otherwise. 183 */ 184 function isApprovedForAll(address owner, address operator) 185 external 186 view 187 returns (bool); 188 } 189 190 /** 191 * The ENS registry contract. 192 */ 193 contract ENSRegistryWithFallback is ENSRegistry { 194 /** 195 * @dev Returns the address of the resolver for the specified node. 196 * @param node The specified node. 197 * @return address of the resolver. 198 */ 199 function resolver(bytes32 node) public view returns (address); 200 201 /** 202 * @dev Returns the address that owns the specified node. 203 * @param node The specified node. 204 * @return address of the owner. 205 */ 206 function owner(bytes32 node) public view returns (address); 207 208 /** 209 * @dev Returns the TTL of a node, and any records associated with it. 210 * @param node The specified node. 211 * @return ttl of the node. 212 */ 213 function ttl(bytes32 node) public view returns (uint64); 214 } 215 216 contract ResolverBase { 217 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 218 } 219 220 contract ABIResolver is ResolverBase { 221 event ABIChanged(bytes32 indexed node, uint256 indexed contentType); 222 223 /** 224 * Sets the ABI associated with an ENS node. 225 * Nodes may have one ABI of each content type. To remove an ABI, set it to 226 * the empty string. 227 * @param node The node to update. 228 * @param contentType The content type of the ABI 229 * @param data The ABI data. 230 */ 231 function setABI( 232 bytes32 node, 233 uint256 contentType, 234 bytes calldata data 235 ) external; 236 237 /** 238 * Returns the ABI associated with an ENS node. 239 * Defined in EIP205. 240 * @param node The ENS node to query 241 * @param contentTypes A bitwise OR of the ABI formats accepted by the caller. 242 * @return contentType The content type of the return value 243 * @return data The ABI data 244 */ 245 function ABI(bytes32 node, uint256 contentTypes) 246 external 247 view 248 returns (uint256, bytes memory); 249 250 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 251 } 252 253 contract AddrResolver is ResolverBase { 254 event AddrChanged(bytes32 indexed node, address a); 255 event AddressChanged( 256 bytes32 indexed node, 257 uint256 coinType, 258 bytes newAddress 259 ); 260 261 /** 262 * Sets the address associated with an ENS node. 263 * May only be called by the owner of that node in the ENS registry. 264 * @param node The node to update. 265 * @param a The address to set. 266 */ 267 function setAddr(bytes32 node, address a) external; 268 269 /** 270 * Returns the address associated with an ENS node. 271 * @param node The ENS node to query. 272 * @return The associated address. 273 */ 274 function addr(bytes32 node) public view returns (address payable); 275 276 function setAddr( 277 bytes32 node, 278 uint256 coinType, 279 bytes memory a 280 ) public; 281 282 function addr(bytes32 node, uint256 coinType) 283 public 284 view 285 returns (bytes memory); 286 287 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 288 } 289 290 contract ContentHashResolver is ResolverBase { 291 event ContenthashChanged(bytes32 indexed node, bytes hash); 292 293 /** 294 * Sets the contenthash associated with an ENS node. 295 * May only be called by the owner of that node in the ENS registry. 296 * @param node The node to update. 297 * @param hash The contenthash to set 298 */ 299 function setContenthash(bytes32 node, bytes calldata hash) external; 300 301 /** 302 * Returns the contenthash associated with an ENS node. 303 * @param node The ENS node to query. 304 * @return The associated contenthash. 305 */ 306 function contenthash(bytes32 node) external view returns (bytes memory); 307 308 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 309 } 310 311 contract DNSResolver is ResolverBase { 312 // DNSRecordChanged is emitted whenever a given node/name/resource's RRSET is updated. 313 event DNSRecordChanged( 314 bytes32 indexed node, 315 bytes name, 316 uint16 resource, 317 bytes record 318 ); 319 // DNSRecordDeleted is emitted whenever a given node/name/resource's RRSET is deleted. 320 event DNSRecordDeleted(bytes32 indexed node, bytes name, uint16 resource); 321 // DNSZoneCleared is emitted whenever a given node's zone information is cleared. 322 event DNSZoneCleared(bytes32 indexed node); 323 324 /** 325 * Set one or more DNS records. Records are supplied in wire-format. 326 * Records with the same node/name/resource must be supplied one after the 327 * other to ensure the data is updated correctly. For example, if the data 328 * was supplied: 329 * a.example.com IN A 1.2.3.4 330 * a.example.com IN A 5.6.7.8 331 * www.example.com IN CNAME a.example.com. 332 * then this would store the two A records for a.example.com correctly as a 333 * single RRSET, however if the data was supplied: 334 * a.example.com IN A 1.2.3.4 335 * www.example.com IN CNAME a.example.com. 336 * a.example.com IN A 5.6.7.8 337 * then this would store the first A record, the CNAME, then the second A 338 * record which would overwrite the first. 339 * 340 * @param node the namehash of the node for which to set the records 341 * @param data the DNS wire format records to set 342 */ 343 function setDNSRecords(bytes32 node, bytes calldata data) external; 344 345 /** 346 * Obtain a DNS record. 347 * @param node the namehash of the node for which to fetch the record 348 * @param name the keccak-256 hash of the fully-qualified name for which to fetch the record 349 * @param resource the ID of the resource as per https://en.wikipedia.org/wiki/List_of_DNS_record_types 350 * @return the DNS record in wire format if present, otherwise empty 351 */ 352 function dnsRecord( 353 bytes32 node, 354 bytes32 name, 355 uint16 resource 356 ) public view returns (bytes memory); 357 358 /** 359 * Check if a given node has records. 360 * @param node the namehash of the node for which to check the records 361 * @param name the namehash of the node for which to check the records 362 */ 363 function hasDNSRecords(bytes32 node, bytes32 name) 364 public 365 view 366 returns (bool); 367 368 /** 369 * Clear all information for a DNS zone. 370 * @param node the namehash of the node for which to clear the zone 371 */ 372 function clearDNSZone(bytes32 node) public; 373 374 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 375 } 376 377 contract InterfaceResolver is ResolverBase, AddrResolver { 378 event InterfaceChanged( 379 bytes32 indexed node, 380 bytes4 indexed interfaceID, 381 address implementer 382 ); 383 384 /** 385 * Sets an interface associated with a name. 386 * Setting the address to 0 restores the default behaviour of querying the contract at `addr()` for interface support. 387 * @param node The node to update. 388 * @param interfaceID The EIP 168 interface ID. 389 * @param implementer The address of a contract that implements this interface for this node. 390 */ 391 function setInterface( 392 bytes32 node, 393 bytes4 interfaceID, 394 address implementer 395 ) external; 396 397 /** 398 * Returns the address of a contract that implements the specified interface for this name. 399 * If an implementer has not been set for this interfaceID and name, the resolver will query 400 * the contract at `addr()`. If `addr()` is set, a contract exists at that address, and that 401 * contract implements EIP168 and returns `true` for the specified interfaceID, its address 402 * will be returned. 403 * @param node The ENS node to query. 404 * @param interfaceID The EIP 168 interface ID to check for. 405 * @return The address that implements this interface, or 0 if the interface is unsupported. 406 */ 407 function interfaceImplementer(bytes32 node, bytes4 interfaceID) 408 external 409 view 410 returns (address); 411 412 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 413 } 414 415 contract NameResolver is ResolverBase { 416 event NameChanged(bytes32 indexed node, string name); 417 418 /** 419 * Sets the name associated with an ENS node, for reverse records. 420 * May only be called by the owner of that node in the ENS registry. 421 * @param node The node to update. 422 * @param name The name to set. 423 */ 424 function setName(bytes32 node, string calldata name) external; 425 426 /** 427 * Returns the name associated with an ENS node, for reverse records. 428 * Defined in EIP181. 429 * @param node The ENS node to query. 430 * @return The associated name. 431 */ 432 function name(bytes32 node) external view returns (string memory); 433 434 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 435 } 436 437 contract PubkeyResolver is ResolverBase { 438 event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y); 439 440 struct PublicKey { 441 bytes32 x; 442 bytes32 y; 443 } 444 445 /** 446 * Sets the SECP256k1 public key associated with an ENS node. 447 * @param node The ENS node to query 448 * @param x the X coordinate of the curve point for the public key. 449 * @param y the Y coordinate of the curve point for the public key. 450 */ 451 function setPubkey( 452 bytes32 node, 453 bytes32 x, 454 bytes32 y 455 ) external; 456 457 /** 458 * Returns the SECP256k1 public key associated with an ENS node. 459 * Defined in EIP 619. 460 * @param node The ENS node to query 461 * @return x, y the X and Y coordinates of the curve point for the public key. 462 */ 463 function pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y); 464 465 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 466 } 467 468 contract TextResolver is ResolverBase { 469 event TextChanged( 470 bytes32 indexed node, 471 string indexed indexedKey, 472 string key 473 ); 474 475 /** 476 * Sets the text data associated with an ENS node and key. 477 * May only be called by the owner of that node in the ENS registry. 478 * @param node The node to update. 479 * @param key The key to set. 480 * @param value The text data value to set. 481 */ 482 function setText( 483 bytes32 node, 484 string calldata key, 485 string calldata value 486 ) external; 487 488 /** 489 * Returns the text data associated with an ENS node and key. 490 * @param node The ENS node to query. 491 * @param key The text data key to query. 492 * @return The associated text data. 493 */ 494 function text(bytes32 node, string calldata key) 495 external 496 view 497 returns (string memory); 498 499 function supportsInterface(bytes4 interfaceID) public pure returns (bool); 500 } 501 502 pragma experimental ABIEncoderV2; 503 504 /** 505 * A simple resolver anyone can use; only allows the owner of a node to set its 506 * address. 507 */ 508 contract PublicResolver is 509 ABIResolver, 510 AddrResolver, 511 ContentHashResolver, 512 DNSResolver, 513 InterfaceResolver, 514 NameResolver, 515 PubkeyResolver, 516 TextResolver 517 { 518 /** 519 * A mapping of authorisations. An address that is authorised for a name 520 * may make any changes to the name that the owner could, but may not update 521 * the set of authorisations. 522 * (node, owner, caller) => isAuthorised 523 */ 524 mapping(bytes32 => mapping(address => mapping(address => bool))) 525 public authorisations; 526 527 event AuthorisationChanged( 528 bytes32 indexed node, 529 address indexed owner, 530 address indexed target, 531 bool isAuthorised 532 ); 533 534 /** 535 * @dev Sets or clears an authorisation. 536 * Authorisations are specific to the caller. Any account can set an authorisation 537 * for any name, but the authorisation that is checked will be that of the 538 * current owner of a name. Thus, transferring a name effectively clears any 539 * existing authorisations, and new authorisations can be set in advance of 540 * an ownership transfer if desired. 541 * 542 * @param node The name to change the authorisation on. 543 * @param target The address that is to be authorised or deauthorised. 544 * @param isAuthorised True if the address should be authorised, or false if it should be deauthorised. 545 */ 546 function setAuthorisation( 547 bytes32 node, 548 address target, 549 bool isAuthorised 550 ) external; 551 552 function multicall(bytes[] calldata data) 553 external 554 returns (bytes[] memory results); 555 }