Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions contracts/PublicResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ contract PublicResolver {
bytes4 constant INTERFACE_META_ID = 0x01ffc9a7;
bytes4 constant ADDR_INTERFACE_ID = 0x3b3b57de;
bytes4 constant CONTENT_INTERFACE_ID = 0xd8389dc5;
bytes4 constant MULTIHASH_INTERFACE_ID = 0xe89401a1;
bytes4 constant NAME_INTERFACE_ID = 0x691f3431;
bytes4 constant ABI_INTERFACE_ID = 0x2203ab56;
bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233;
bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c;

event AddrChanged(bytes32 indexed node, address a);
event ContentChanged(bytes32 indexed node, bytes32 hash);
event MultihashChanged(bytes32 indexed node, bytes multihash);
event NameChanged(bytes32 indexed node, string name);
event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
Expand All @@ -30,6 +32,7 @@ contract PublicResolver {
struct Record {
address addr;
bytes32 content;
bytes multihash;
string name;
PublicKey pubkey;
mapping(string=>string) text;
Expand Down Expand Up @@ -60,6 +63,7 @@ contract PublicResolver {
function supportsInterface(bytes4 interfaceID) constant returns (bool) {
return interfaceID == ADDR_INTERFACE_ID ||
interfaceID == CONTENT_INTERFACE_ID ||
interfaceID == MULTIHASH_INTERFACE_ID ||
interfaceID == NAME_INTERFACE_ID ||
interfaceID == ABI_INTERFACE_ID ||
interfaceID == PUBKEY_INTERFACE_ID ||
Expand Down Expand Up @@ -98,6 +102,8 @@ contract PublicResolver {
ret = records[node].content;
}



/**
* Sets the content hash associated with an ENS node.
* May only be called by the owner of that node in the ENS registry.
Expand All @@ -111,6 +117,27 @@ contract PublicResolver {
ContentChanged(node, hash);
}

/**
* Returns the content multihash associated with an ENS node.
* @param node The ENS node to query.
* @return The associated content multihash.
*/
function multihash(bytes32 node) public constant returns (bytes ret) {
ret = records[node].multihash;
}

/**
* Sets the content hash associated with an ENS node.
* May only be called by the owner of that node in the ENS registry.
* @param node The node to update.
* @param multihash The content hash to set
*/
function setMultihash(bytes32 node, bytes multihash) public only_owner(node) {
records[node].multihash = multihash;
MultihashChanged(node, multihash);
}


/**
* Returns the name associated with an ENS node, for reverse records.
* Defined in EIP181.
Expand All @@ -120,7 +147,7 @@ contract PublicResolver {
function name(bytes32 node) constant returns (string ret) {
ret = records[node].name;
}

/**
* Sets the name associated with an ENS node, for reverse records.
* May only be called by the owner of that node in the ENS registry.
Expand Down Expand Up @@ -162,11 +189,11 @@ contract PublicResolver {
function setABI(bytes32 node, uint256 contentType, bytes data) only_owner(node) {
// Content types must be powers of 2
if (((contentType - 1) & contentType) != 0) throw;

records[node].abis[contentType] = data;
ABIChanged(node, contentType);
}

/**
* Returns the SECP256k1 public key associated with an ENS node.
* Defined in EIP 619.
Expand All @@ -176,7 +203,7 @@ contract PublicResolver {
function pubkey(bytes32 node) constant returns (bytes32 x, bytes32 y) {
return (records[node].pubkey.x, records[node].pubkey.y);
}

/**
* Sets the SECP256k1 public key associated with an ENS node.
* @param node The ENS node to query
Expand Down