conflict in ens index
This commit is contained in:
parent
302da3f263
commit
0c0624e463
|
@ -15,7 +15,6 @@ function log(eventType, eventName) {
|
|||
if (eventType.indexOf("log") >= 0) {
|
||||
return;
|
||||
}
|
||||
//console.log(eventType, eventName);
|
||||
}
|
||||
|
||||
EventEmitter.prototype._maxListeners = 350;
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
pragma solidity ^0.4.18;
|
||||
|
||||
interface ENS {
|
||||
|
||||
// Logged when the owner of a node assigns a new owner to a subnode.
|
||||
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
|
||||
|
||||
// Logged when the owner of a node transfers ownership to a new account.
|
||||
event Transfer(bytes32 indexed node, address owner);
|
||||
|
||||
// Logged when the resolver for a node changes.
|
||||
event NewResolver(bytes32 indexed node, address resolver);
|
||||
|
||||
// Logged when the TTL of a node changes
|
||||
event NewTTL(bytes32 indexed node, uint64 ttl);
|
||||
|
||||
|
||||
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external;
|
||||
function setResolver(bytes32 node, address resolver) external;
|
||||
function setOwner(bytes32 node, address owner) external;
|
||||
function setTTL(bytes32 node, uint64 ttl) external;
|
||||
function owner(bytes32 node) external view returns (address);
|
||||
function resolver(bytes32 node) external view returns (address);
|
||||
function ttl(bytes32 node) external view returns (uint64);
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
pragma solidity ^0.4.18;
|
||||
|
||||
import './ENS.sol';
|
||||
|
||||
/**
|
||||
* The ENS registry contract.
|
||||
*/
|
||||
contract ENSRegistry is ENS {
|
||||
struct Record {
|
||||
address owner;
|
||||
address resolver;
|
||||
uint64 ttl;
|
||||
}
|
||||
|
||||
mapping (bytes32 => Record) records;
|
||||
|
||||
// Permits modifications only by the owner of the specified node.
|
||||
modifier only_owner(bytes32 node, address owner) {
|
||||
require(records[node].owner == 0 || records[node].owner == msg.sender || records[node].owner == owner);
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Constructs a new ENS registrar.
|
||||
*/
|
||||
constructor() public {
|
||||
records[0x0].owner = msg.sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Transfers ownership of a node to a new address. May only be called by the current owner of the node.
|
||||
* @param node The node to transfer ownership of.
|
||||
* @param owner The address of the new owner.
|
||||
*/
|
||||
function setOwner(bytes32 node, address owner) public only_owner(node, owner) {
|
||||
emit Transfer(node, owner);
|
||||
records[node].owner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Transfers ownership of a subnode sha3(node, label) to a new address. May only be called by the owner of the parent node.
|
||||
* @param node The parent node.
|
||||
* @param label The hash of the label specifying the subnode.
|
||||
* @param owner The address of the new owner.
|
||||
*/
|
||||
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public only_owner(node, owner) {
|
||||
bytes32 subnode = keccak256(abi.encodePacked(node, label));
|
||||
emit NewOwner(node, label, owner);
|
||||
records[subnode].owner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets the resolver address for the specified node.
|
||||
* @param node The node to update.
|
||||
* @param resolver The address of the resolver.
|
||||
*/
|
||||
function setResolver(bytes32 node, address resolver) public only_owner(node, 0x0) {
|
||||
emit NewResolver(node, resolver);
|
||||
records[node].resolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Sets the TTL for the specified node.
|
||||
* @param node The node to update.
|
||||
* @param ttl The TTL in seconds.
|
||||
*/
|
||||
function setTTL(bytes32 node, uint64 ttl) public only_owner(node, 0x0) {
|
||||
emit NewTTL(node, ttl);
|
||||
records[node].ttl = ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the address that owns the specified node.
|
||||
* @param node The specified node.
|
||||
* @return address of the owner.
|
||||
*/
|
||||
function owner(bytes32 node) public view returns (address) {
|
||||
return records[node].owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the address of the resolver for the specified node.
|
||||
* @param node The specified node.
|
||||
* @return address of the resolver.
|
||||
*/
|
||||
function resolver(bytes32 node) public view returns (address) {
|
||||
return records[node].resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the TTL of a node, and any records associated with it.
|
||||
* @param node The specified node.
|
||||
* @return ttl of the node.
|
||||
*/
|
||||
function ttl(bytes32 node) public view returns (uint64) {
|
||||
return records[node].ttl;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
pragma solidity ^0.4.18;
|
||||
|
||||
import './ENS.sol';
|
||||
import './Resolver.sol';
|
||||
|
||||
/**
|
||||
* A registrar that allocates subdomains to the first person to claim them.
|
||||
*/
|
||||
contract FIFSRegistrar {
|
||||
ENS ens;
|
||||
bytes32 rootNode;
|
||||
|
||||
modifier only_owner(bytes32 subnode) {
|
||||
bytes32 node = keccak256(abi.encodePacked(rootNode, subnode));
|
||||
address currentOwner = ens.owner(node);
|
||||
require(currentOwner == 0 || currentOwner == msg.sender);
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param ensAddr The address of the ENS registry.
|
||||
* @param node The node that this registrar administers.
|
||||
*/
|
||||
constructor(ENS ensAddr, bytes32 node) public {
|
||||
ens = ensAddr;
|
||||
rootNode = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a name, or change the owner of an existing registration.
|
||||
* @param subnode The hash of the label to register.
|
||||
* @param owner The address of the new owner.
|
||||
*/
|
||||
function register(bytes32 subnode, address owner) public only_owner(subnode) {
|
||||
ens.setSubnodeOwner(rootNode, subnode, owner);
|
||||
}
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
pragma solidity ^0.4.23;
|
||||
|
||||
import "./ENS.sol";
|
||||
|
||||
/**
|
||||
* A simple resolver anyone can use; only allows the owner of a node to set its
|
||||
* address.
|
||||
*/
|
||||
contract Resolver {
|
||||
event AddrChanged(bytes32 indexed node, address a);
|
||||
event ContentChanged(bytes32 indexed node, bytes32 hash);
|
||||
event NameChanged(bytes32 indexed node, string name);
|
||||
event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
|
||||
event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);
|
||||
event TextChanged(bytes32 indexed node, string indexedKey, string key);
|
||||
|
||||
struct PublicKey {
|
||||
bytes32 x;
|
||||
bytes32 y;
|
||||
}
|
||||
|
||||
struct Record {
|
||||
address addr;
|
||||
bytes32 content;
|
||||
string name;
|
||||
PublicKey pubkey;
|
||||
mapping(string=>string) text;
|
||||
mapping(uint256=>bytes) abis;
|
||||
}
|
||||
|
||||
ENS ens;
|
||||
|
||||
mapping (bytes32 => Record) records;
|
||||
|
||||
modifier only_owner(bytes32 node) {
|
||||
// FIXME Calling ens.owner makes the transaction fail on privatenet for some reason
|
||||
// address currentOwner = ens.owner(node);
|
||||
// require(currentOwner == 0 || currentOwner == msg.sender);
|
||||
require(true == true);
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param ensAddr The ENS registrar contract.
|
||||
*/
|
||||
constructor(ENS ensAddr) public {
|
||||
ens = ensAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the address 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 addr The address to set.
|
||||
*/
|
||||
function setAddr(bytes32 node, address addr) public only_owner(node) {
|
||||
records[node].addr = addr;
|
||||
emit AddrChanged(node, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content hash associated with an ENS node.
|
||||
* May only be called by the owner of that node in the ENS registry.
|
||||
* Note that this resource type is not standardized, and will likely change
|
||||
* in future to a resource type based on multihash.
|
||||
* @param node The node to update.
|
||||
* @param hash The content hash to set
|
||||
*/
|
||||
function setContent(bytes32 node, bytes32 hash) public only_owner(node) {
|
||||
records[node].content = hash;
|
||||
emit ContentChanged(node, hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param node The node to update.
|
||||
* @param name The name to set.
|
||||
*/
|
||||
function setName(bytes32 node, string name) public only_owner(node) {
|
||||
records[node].name = name;
|
||||
emit NameChanged(node, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ABI associated with an ENS node.
|
||||
* Nodes may have one ABI of each content type. To remove an ABI, set it to
|
||||
* the empty string.
|
||||
* @param node The node to update.
|
||||
* @param contentType The content type of the ABI
|
||||
* @param data The ABI data.
|
||||
*/
|
||||
function setABI(bytes32 node, uint256 contentType, bytes data) public only_owner(node) {
|
||||
// Content types must be powers of 2
|
||||
require(((contentType - 1) & contentType) == 0);
|
||||
|
||||
records[node].abis[contentType] = data;
|
||||
emit ABIChanged(node, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SECP256k1 public key associated with an ENS node.
|
||||
* @param node The ENS node to query
|
||||
* @param x the X coordinate of the curve point for the public key.
|
||||
* @param y the Y coordinate of the curve point for the public key.
|
||||
*/
|
||||
function setPubkey(bytes32 node, bytes32 x, bytes32 y) public only_owner(node) {
|
||||
records[node].pubkey = PublicKey(x, y);
|
||||
emit PubkeyChanged(node, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text data associated with an ENS node and key.
|
||||
* May only be called by the owner of that node in the ENS registry.
|
||||
* @param node The node to update.
|
||||
* @param key The key to set.
|
||||
* @param value The text data value to set.
|
||||
*/
|
||||
function setText(bytes32 node, string key, string value) public only_owner(node) {
|
||||
records[node].text[key] = value;
|
||||
emit TextChanged(node, key, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text data associated with an ENS node and key.
|
||||
* @param node The ENS node to query.
|
||||
* @param key The text data key to query.
|
||||
* @return The associated text data.
|
||||
*/
|
||||
function text(bytes32 node, string key) public view returns (string) {
|
||||
return records[node].text[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SECP256k1 public key associated with an ENS node.
|
||||
* Defined in EIP 619.
|
||||
* @param node The ENS node to query
|
||||
* @return x, y the X and Y coordinates of the curve point for the public key.
|
||||
*/
|
||||
function pubkey(bytes32 node) public view returns (bytes32 x, bytes32 y) {
|
||||
return (records[node].pubkey.x, records[node].pubkey.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ABI associated with an ENS node.
|
||||
* Defined in EIP205.
|
||||
* @param node The ENS node to query
|
||||
* @param contentTypes A bitwise OR of the ABI formats accepted by the caller.
|
||||
* @return contentType The content type of the return value
|
||||
* @return data The ABI data
|
||||
*/
|
||||
function ABI(bytes32 node, uint256 contentTypes) public view returns (uint256 contentType, bytes data) {
|
||||
Record storage record = records[node];
|
||||
for (contentType = 1; contentType <= contentTypes; contentType <<= 1) {
|
||||
if ((contentType & contentTypes) != 0 && record.abis[contentType].length > 0) {
|
||||
data = record.abis[contentType];
|
||||
return;
|
||||
}
|
||||
}
|
||||
contentType = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name associated with an ENS node, for reverse records.
|
||||
* Defined in EIP181.
|
||||
* @param node The ENS node to query.
|
||||
* @return The associated name.
|
||||
*/
|
||||
function name(bytes32 node) public view returns (string) {
|
||||
return records[node].name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content hash associated with an ENS node.
|
||||
* Note that this resource type is not standardized, and will likely change
|
||||
* in future to a resource type based on multihash.
|
||||
* @param node The ENS node to query.
|
||||
* @return The associated content hash.
|
||||
*/
|
||||
function content(bytes32 node) public view returns (bytes32) {
|
||||
return records[node].content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address associated with an ENS node.
|
||||
* @param node The ENS node to query.
|
||||
* @return The associated address.
|
||||
*/
|
||||
function addr(bytes32 node) public view returns (address) {
|
||||
return records[node].addr;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"ENSRegistry": {
|
||||
"deploy": true,
|
||||
"silent": false,
|
||||
"silent": true,
|
||||
"args": [],
|
||||
"className": "ENSRegistry",
|
||||
"code": "608060405234801561001057600080fd5b5060008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a03191633179055610684806100596000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008757806302571be3146100bb57806306ab5923146100d357806314ab9038146100fc57806316a25cbd146101215780631896f70a146101565780635b0fc9c31461017a575b600080fd5b34801561009357600080fd5b5061009f60043561019e565b60408051600160a060020a039092168252519081900360200190f35b3480156100c757600080fd5b5061009f6004356101bc565b3480156100df57600080fd5b506100fa600435602435600160a060020a03604435166101d7565b005b34801561010857600080fd5b506100fa60043567ffffffffffffffff6024351661033c565b34801561012d57600080fd5b5061013960043561044d565b6040805167ffffffffffffffff9092168252519081900360200190f35b34801561016257600080fd5b506100fa600435600160a060020a0360243516610484565b34801561018657600080fd5b506100fa600435600160a060020a036024351661056f565b600090815260208190526040902060010154600160a060020a031690565b600090815260208190526040902054600160a060020a031690565b60008381526020819052604081205484908390600160a060020a031615806102155750600082815260208190526040902054600160a060020a031633145b806102395750600082815260208190526040902054600160a060020a038281169116145b151561024457600080fd5b604080516020808201899052818301889052825180830384018152606090920192839052815191929182918401908083835b602083106102955780518252601f199092019160209182019101610276565b51815160209384036101000a600019018019909216911617905260408051929094018290038220600160a060020a038b16835293519398508a95508b94507fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e829391829003019150a350506000908152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555050565b600082815260208190526040812054839190600160a060020a031615806103795750600082815260208190526040902054600160a060020a031633145b8061039d5750600082815260208190526040902054600160a060020a038281169116145b15156103a857600080fd5b6040805167ffffffffffffffff85168152905185917f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68919081900360200190a25050600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b600082815260208190526040812054839190600160a060020a031615806104c15750600082815260208190526040902054600160a060020a031633145b806104e55750600082815260208190526040902054600160a060020a038281169116145b15156104f057600080fd5b60408051600160a060020a0385168152905185917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a25050600091825260208290526040909120600101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055565b60008281526020819052604090205482908290600160a060020a031615806105ad5750600082815260208190526040902054600160a060020a031633145b806105d15750600082815260208190526040902054600160a060020a038281169116145b15156105dc57600080fd5b60408051600160a060020a0385168152905185917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a25050600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555600a165627a7a72305820ab29585bdb630f86714bdc052e84731ce84785d7ace426bc24c1104e8760968c0029",
|
||||
|
|
|
@ -87,6 +87,7 @@ class ENS {
|
|||
this.registration = this.namesConfig.register || {};
|
||||
this.embark = embark;
|
||||
this.ensConfig = require('./ensContractConfigs');
|
||||
this.configured = false;
|
||||
|
||||
if (this.namesConfig === {} ||
|
||||
this.namesConfig.enabled !== true ||
|
||||
|
@ -128,7 +129,7 @@ class ENS {
|
|||
}
|
||||
|
||||
registerEvents() {
|
||||
this.events.once("contracts:deploy:afterAll", this.configureContractsAndRegister.bind(this));
|
||||
this.embark.registerActionForEvent("deploy:beforeAll", this.configureContractsAndRegister.bind(this));
|
||||
this.events.once("web3Ready", this.configureContracts.bind(this));
|
||||
|
||||
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
||||
|
@ -146,10 +147,8 @@ class ENS {
|
|||
resolverAbi: self.ensConfig.Resolver.abiDefinition,
|
||||
resolverAddress: self.ensConfig.Resolver.deployedAddress
|
||||
};
|
||||
console.dir(config);
|
||||
|
||||
if (self.doSetENSProvider) {
|
||||
console.log('PLEAGRGFIUWIUF');
|
||||
self.addSetProvider(config);
|
||||
}
|
||||
|
||||
|
@ -298,17 +297,24 @@ class ENS {
|
|||
this.embark.addCodeToEmbarkJS(code);
|
||||
}
|
||||
|
||||
configureContractsAndRegister() {
|
||||
configureContractsAndRegister(cb) {
|
||||
this.events.request('blockchain:networkId', (networkId) => {
|
||||
const config = Object.assign({}, DEFAULT_ENS_CONTRACTS_CONFIG, {[this.env]: ENS_CONTRACTS_CONFIG[networkId]});
|
||||
const self = this;
|
||||
if (self.configured) {
|
||||
return cb();
|
||||
}
|
||||
async.waterfall([
|
||||
function registry(next) {
|
||||
self.events.request('deploy:contract', self.ensConfig.ENSRegistry, next);
|
||||
self.events.request('deploy:contract', self.ensConfig.ENSRegistry, (err, _receipt) => {
|
||||
return next(err);
|
||||
});
|
||||
},
|
||||
function resolver(next) {
|
||||
self.ensConfig.Resolver.args = [self.ensConfig.ENSRegistry.deployedAddress];
|
||||
self.events.request('deploy:contract', self.ensConfig.Resolver, next);
|
||||
self.events.request('deploy:contract', self.ensConfig.Resolver, (err, _receipt) => {
|
||||
return next(err);
|
||||
});
|
||||
},
|
||||
function registrar(next) {
|
||||
if (!self.registration || !self.registration.rootDomain) {
|
||||
|
@ -328,15 +334,18 @@ class ENS {
|
|||
Resolver.methods.setName(reverseNode, '${self.registration.rootDomain}').send({from: web3.eth.defaultAccount});
|
||||
})`
|
||||
];
|
||||
self.events.request('deploy:contract', contract, next);
|
||||
self.events.request('deploy:contract', contract, (err, _receipt) => {
|
||||
return next(err);
|
||||
});
|
||||
}
|
||||
], (err) => {
|
||||
self.configured = true;
|
||||
if (err) {
|
||||
self.logger.error('Error while deploying ENS contracts');
|
||||
self.logger.error(err.message || err);
|
||||
return;
|
||||
}
|
||||
self.setProviderAndRegisterDomains();
|
||||
self.setProviderAndRegisterDomains(cb);
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue