mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-01-22 08:38:48 +00:00
update PublicResolver contract to support multihash
This commit is contained in:
parent
23a53ec0f1
commit
2db113a390
@ -18,6 +18,7 @@
|
|||||||
"deploy": true
|
"deploy": true
|
||||||
},
|
},
|
||||||
"PublicResolver": {
|
"PublicResolver": {
|
||||||
|
"args": ["$ENSRegistry"],
|
||||||
"deploy": true
|
"deploy": true
|
||||||
},
|
},
|
||||||
"ENSSubdomainRegistry": {
|
"ENSSubdomainRegistry": {
|
||||||
@ -77,7 +78,7 @@
|
|||||||
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010"
|
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010"
|
||||||
},
|
},
|
||||||
"PublicResolver": {
|
"PublicResolver": {
|
||||||
"address": "0x5FfC014343cd971B7eb70732021E26C35B744cc4"
|
"address": "0x29754bADB2640b98F6deF0f52D41418b0d2e0C51"
|
||||||
},
|
},
|
||||||
"TestToken": {
|
"TestToken": {
|
||||||
"address": "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"
|
"address": "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pragma solidity ^0.4.23;
|
pragma solidity ^0.4.18;
|
||||||
|
|
||||||
import "./ENS.sol";
|
import './ENS.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple resolver anyone can use; only allows the owner of a node to set its
|
* A simple resolver anyone can use; only allows the owner of a node to set its
|
||||||
@ -15,6 +15,7 @@ contract PublicResolver {
|
|||||||
bytes4 constant ABI_INTERFACE_ID = 0x2203ab56;
|
bytes4 constant ABI_INTERFACE_ID = 0x2203ab56;
|
||||||
bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233;
|
bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233;
|
||||||
bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c;
|
bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c;
|
||||||
|
bytes4 constant MULTIHASH_INTERFACE_ID = 0xe89401a1;
|
||||||
|
|
||||||
event AddrChanged(bytes32 indexed node, address a);
|
event AddrChanged(bytes32 indexed node, address a);
|
||||||
event ContentChanged(bytes32 indexed node, bytes32 hash);
|
event ContentChanged(bytes32 indexed node, bytes32 hash);
|
||||||
@ -22,6 +23,7 @@ contract PublicResolver {
|
|||||||
event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
|
event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
|
||||||
event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
|
event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
|
||||||
event TextChanged(bytes32 indexed node, string indexedKey, string key);
|
event TextChanged(bytes32 indexed node, string indexedKey, string key);
|
||||||
|
event MultihashChanged(bytes32 indexed node, bytes hash);
|
||||||
|
|
||||||
struct PublicKey {
|
struct PublicKey {
|
||||||
bytes32 x;
|
bytes32 x;
|
||||||
@ -35,6 +37,7 @@ contract PublicResolver {
|
|||||||
PublicKey pubkey;
|
PublicKey pubkey;
|
||||||
mapping(string=>string) text;
|
mapping(string=>string) text;
|
||||||
mapping(uint256=>bytes) abis;
|
mapping(uint256=>bytes) abis;
|
||||||
|
bytes multihash;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENS ens;
|
ENS ens;
|
||||||
@ -50,7 +53,7 @@ contract PublicResolver {
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
* @param ensAddr The ENS registrar contract.
|
* @param ensAddr The ENS registrar contract.
|
||||||
*/
|
*/
|
||||||
constructor(ENS ensAddr) public {
|
function PublicResolver(ENS ensAddr) public {
|
||||||
ens = ensAddr;
|
ens = ensAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ contract PublicResolver {
|
|||||||
*/
|
*/
|
||||||
function setAddr(bytes32 node, address addr) public only_owner(node) {
|
function setAddr(bytes32 node, address addr) public only_owner(node) {
|
||||||
records[node].addr = addr;
|
records[node].addr = addr;
|
||||||
emit AddrChanged(node, addr);
|
AddrChanged(node, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +78,18 @@ contract PublicResolver {
|
|||||||
*/
|
*/
|
||||||
function setContent(bytes32 node, bytes32 hash) public only_owner(node) {
|
function setContent(bytes32 node, bytes32 hash) public only_owner(node) {
|
||||||
records[node].content = hash;
|
records[node].content = hash;
|
||||||
emit ContentChanged(node, hash);
|
ContentChanged(node, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the multihash 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 hash The multihash to set
|
||||||
|
*/
|
||||||
|
function setMultihash(bytes32 node, bytes hash) public only_owner(node) {
|
||||||
|
records[node].multihash = hash;
|
||||||
|
MultihashChanged(node, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +100,7 @@ contract PublicResolver {
|
|||||||
*/
|
*/
|
||||||
function setName(bytes32 node, string name) public only_owner(node) {
|
function setName(bytes32 node, string name) public only_owner(node) {
|
||||||
records[node].name = name;
|
records[node].name = name;
|
||||||
emit NameChanged(node, name);
|
NameChanged(node, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +116,7 @@ contract PublicResolver {
|
|||||||
require(((contentType - 1) & contentType) == 0);
|
require(((contentType - 1) & contentType) == 0);
|
||||||
|
|
||||||
records[node].abis[contentType] = data;
|
records[node].abis[contentType] = data;
|
||||||
emit ABIChanged(node, contentType);
|
ABIChanged(node, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +127,7 @@ contract PublicResolver {
|
|||||||
*/
|
*/
|
||||||
function setPubkey(bytes32 node, bytes32 x, bytes32 y) public only_owner(node) {
|
function setPubkey(bytes32 node, bytes32 x, bytes32 y) public only_owner(node) {
|
||||||
records[node].pubkey = PublicKey(x, y);
|
records[node].pubkey = PublicKey(x, y);
|
||||||
emit PubkeyChanged(node, x, y);
|
PubkeyChanged(node, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +139,7 @@ contract PublicResolver {
|
|||||||
*/
|
*/
|
||||||
function setText(bytes32 node, string key, string value) public only_owner(node) {
|
function setText(bytes32 node, string key, string value) public only_owner(node) {
|
||||||
records[node].text[key] = value;
|
records[node].text[key] = value;
|
||||||
emit TextChanged(node, key, key);
|
TextChanged(node, key, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,6 +202,15 @@ contract PublicResolver {
|
|||||||
return records[node].content;
|
return records[node].content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the multihash associated with an ENS node.
|
||||||
|
* @param node The ENS node to query.
|
||||||
|
* @return The associated multihash.
|
||||||
|
*/
|
||||||
|
function multihash(bytes32 node) public view returns (bytes) {
|
||||||
|
return records[node].multihash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the address associated with an ENS node.
|
* Returns the address associated with an ENS node.
|
||||||
* @param node The ENS node to query.
|
* @param node The ENS node to query.
|
||||||
@ -209,6 +232,7 @@ contract PublicResolver {
|
|||||||
interfaceID == ABI_INTERFACE_ID ||
|
interfaceID == ABI_INTERFACE_ID ||
|
||||||
interfaceID == PUBKEY_INTERFACE_ID ||
|
interfaceID == PUBKEY_INTERFACE_ID ||
|
||||||
interfaceID == TEXT_INTERFACE_ID ||
|
interfaceID == TEXT_INTERFACE_ID ||
|
||||||
|
interfaceID == MULTIHASH_INTERFACE_ID ||
|
||||||
interfaceID == INTERFACE_META_ID;
|
interfaceID == INTERFACE_META_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user