Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #333 from ensdomains/add-index
Browse files Browse the repository at this point in the history
Add index file, publish script, update README
  • Loading branch information
jefflau committed May 30, 2019
2 parents e46a3ab + d979baf commit fef2d83
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 19 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
test
51 changes: 41 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,44 @@ To run unit tests, clone this repository, and run:
$ npm install
$ npm test

# npm package

This repo doubles as an npm package with the compiled JSON contracts

```js
import {
Deed,
DeedImplementation,
ENS,
ENSRegistry,
FIFSRegistrar,
HashRegistrar,
Migrations,
Registrar,
Resolver,
ReverseRegistrar,
TestRegistrar
} from '@ensdomains/ens'
```

## ENSRegistry.sol

Implementation of the ENS Registry, the central contract used to look up resolvers and owners for domains.

## FIFSRegistrar.sol

Implementation of a simple first-in-first-served registrar, which issues (sub-)domains to the first account to request them.

## HashRegistrar.sol

Implementation of a registrar based on second-price blind auctions and funds held on deposit, with a renewal process that weights renewal costs according to the change in mean price of registering a domain. Largely untested!

## HashRegistrarSimplified.sol

Simplified version of the above, with no support for renewals. This is the current proposal for interim registrar of the ENS system until a permanent registrar is decided on.

## PublicResolver.sol

Simple resolver implementation that allows the owner of any domain to configure how its name should resolve. One deployment of this contract allows any number of people to use it, by setting it as their resolver in the registry.

# ENS Registry interface
Expand All @@ -32,28 +57,33 @@ The ENS registry is a single central contract that provides a mapping from domai

The ENS operates on 'nodes' instead of human-readable names; a human readable name is converted to a node using the namehash algorithm, which is as follows:

def namehash(name):
if name == '':
return '\0' * 32
else:
label, _, remainder = name.partition('.')
return sha3(namehash(remainder) + sha3(label))
def namehash(name):
if name == '':
return '\0' * 32
else:
label, _, remainder = name.partition('.')
return sha3(namehash(remainder) + sha3(label))

The registry's interface is as follows:

## owner(bytes32 node) constant returns (address)

Returns the owner of the specified node.

## resolver(bytes32 node) constant returns (address)

Returns the resolver for the specified node.

## setOwner(bytes32 node, address owner)

Updates the owner of a node. Only the current owner may call this function.

## setSubnodeOwner(bytes32 node, bytes32 label, address owner)

Updates the owner of a subnode. For instance, the owner of "foo.com" may change the owner of "bar.foo.com" by calling `setSubnodeOwner(namehash("foo.com"), sha3("bar"), newowner)`. Only callable by the owner of `node`.

## setResolver(bytes32 node, address resolver)

Sets the resolver address for the specified node.

# Resolvers
Expand All @@ -71,20 +101,21 @@ The files in the abi directory were generated with the following command:
$ solc --abi -o abi AbstractENS.sol FIFSRegistrar.sol HashRegistrarSimplified.sol PublicResolver.sol

# Getting started

Install Truffle

$ npm install -g truffle
$ npm install -g truffle

Launch the RPC client, for example TestRPC:

$ testrpc
$ testrpc

Deploy `ENS` and `FIFSRegistrar` to the private network, the deployment process is defined at [here](migrations/2_deploy_contracts.js):

$ truffle migrate --network dev.fifs
$ truffle migrate --network dev.fifs

alternatively, deploy the `HashRegistrar`:

$ truffle migrate --network dev.auction
$ truffle migrate --network dev.auction

Check the truffle [documentation](http://truffleframework.com/docs/) for more information.
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const Deed = require('./build/contracts/Deed.json')
const DeedImplementation = require('./build/contracts/DeedImplementation.json')
const ENS = require('./build/contracts/ENS.json')
const ENSRegistry = require('./build/contracts/ENSRegistry.json')
const FIFSRegistrar = require('./build/contracts/FIFSRegistrar.json')
const HashRegistrar = require('./build/contracts/HashRegistrar.json')
const Migrations = require('./build/contracts/Migrations.json')
const Registrar = require('./build/contracts/Registrar.json')
const Resolver = require('./build/contracts/Resolver.json')
const ReverseRegistrar = require('./build/contracts/ReverseRegistrar.json')
const TestRegistrar = require('./build/contracts/TestRegistrar.json')

module.exports = {
Deed,
DeedImplementation,
ENS,
ENSRegistry,
FIFSRegistrar,
HashRegistrar,
Migrations,
Registrar,
Resolver,
ReverseRegistrar,
TestRegistrar
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "@ensdomains/ens",
"version": "0.3.6",
"version": "0.3.10",
"description": "Implementations for registrars and local resolvers for the Ethereum Name Service",
"scripts": {
"test": "truffle test",
"lint": "solium --dir ./contracts",
"prepublishOnly": "truffle compile && truffle networks --clean"
"prepublishOnly": "truffle compile && truffle networks --clean",
"pub": "npm run prepublishOnly && npm publish"
},
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ensdomains/ens.git"
Expand All @@ -18,18 +20,18 @@
},
"homepage": "https://github.com/ensdomains/ens#readme",
"dependencies": {
"ganache-cli": "^6.1.0",
"testrpc": "0.0.1",
"bluebird": "^3.5.2",
"eth-ens-namehash": "^1.0.2",
"web3-utils": "^1.0.0-beta.31",
"ethereumjs-testrpc": "^6.0.3",
"ganache-cli": "^6.1.0",
"solc": "^0.4.20",
"bluebird": "^3.5.2"
"testrpc": "0.0.1",
"web3-utils": "^1.0.0-beta.31"
},
"devDependencies": {
"@ensdomains/test-utils": "^1.2.0",
"solidity-coverage": "^0.3.5",
"solium": "^1.0.4",
"truffle": "^5.0.0",
"@ensdomains/test-utils": "^1.2.0"
"truffle": "^5.0.0"
}
}

0 comments on commit fef2d83

Please sign in to comment.