Skip to content

Commit 5b3b3cb

Browse files
committed
swarm, internal: Rewrote ENS support for the new EIP
1 parent 8f0eafb commit 5b3b3cb

File tree

13 files changed

+1012
-1296
lines changed

13 files changed

+1012
-1296
lines changed

internal/web3ext/web3ext.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,19 @@ web3._extend({
117117
property: 'ens',
118118
methods:
119119
[
120-
new web3._extend.Method({
121-
name: 'deployRegistrar',
122-
call: 'ens_deployRegistrar',
123-
}),
124-
new web3._extend.Method({
125-
name: 'deployResolver',
126-
call: 'ens_deployResolver',
127-
}),
128120
new web3._extend.Method({
129121
name: 'register',
130122
call: 'ens_register',
131-
params: 2,
132-
inputFormatter: [null, null]
123+
params: 1,
124+
inputFormatter: [null]
133125
}),
134-
new web3._extend.Method({
126+
new web3._extend.Method({
135127
name: 'setContentHash',
136128
call: 'ens_setContentHash',
137129
params: 2,
138130
inputFormatter: [null, null]
139131
}),
140-
new web3._extend.Method({
132+
new web3._extend.Method({
141133
name: 'resolve',
142134
call: 'ens_resolve',
143135
params: 1,

swarm/services/ens/README.md

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,41 @@
22

33
## Usage
44

5-
Full documentation for the Ethereum Name Service [can be found as EIP]()
5+
Full documentation for the Ethereum Name Service [can be found as EIP 137](https://github.com/ethereum/EIPs/issues/137)
66
Swarm offers a simple phase-one interface that streamlines the registration of swarm content hashes to arbitrary utf8 domain names.
77
The interface is offered through the ENS RPC API module under the `ens` namespace. The API can be used via the console, rpc or web3.js.
88

9-
### `ens.deployRegistrar()`
9+
### `ens.register(name)`
1010

11-
sends a contract creation transaction from your bzz account deploying an open registrar contract which can serve as ENS root resolver. A root resolver is deployed on the testnet and set as default for EnsRoot. Alternative can be given by changing the `ENSRoot` parameter in swarm `config.json` file.
11+
Sends a transaction that registers a name as a top-level domain, giving ownership to the current account, and automatically deploying a simple resolver contract for it.
1212

13-
To deploy an alternative top-level domain root resolver:
13+
This line registers the top-level domain `swarm`:
1414

15-
```js
16-
registrarAddr=ens.deployRegistrar()
17-
// "0xa90b9572f094660f8f314b591a365985e98d2fd0"
18-
eth.getCode(registrarAddr) // check if contract was successfully deployed
19-
// "0x" // not mined yet
20-
// miner.start(1) // to start mining on a private chain
21-
// true
2215
```
23-
24-
### `ens.deployResolver()`
25-
26-
sends a contract creation transaction from your bzz account deploying a simple personal resolver contract, that can be registered with a (sub)domain on the root resolver. As a result the root resolver will delegate all hostnames under that domain to the child resolver.
27-
28-
To deploy a personal resolver:
29-
30-
```js
31-
resolverAddr = ens.deployResolver()
32-
// "0x2ba72b924a7d654c54467f7bda035ddc2f6fb4eb"
33-
eth.getCode(registrarAddr) // check if contract was successfully deployed
34-
// "0x" // not mined yet
35-
// miner.start(1) // to start mining on a private chain
36-
// true
37-
```
38-
39-
### `ens.register(name, address)`
40-
41-
Sends a transaction that registers a resolver contract with domain on the top-level resolver.
42-
As a result the bzz account becomes the owner of that domain.
43-
This line registers the (already deployed) personal resolver at address `resolverAddr` to the top-level domain `swarm`
44-
45-
```
46-
ens.register("swarm",resolverAddr)
16+
ens.register("swarm")
4717
// {}
4818
```
4919

5020
### `ens.setContentHash(name, hash)`
5121

52-
sends a transaction that sets a content hash to a name using a (sub-domain) resolver:
22+
Sends a transaction that sets a content hash to a name using a (sub-domain) resolver:
5323

5424
```js
5525
ens.setContentHash("swarm","0x7420f14a28e276dd39da6a967dec332a932256717451155fbd3870b202b561c4")
5626
// {}
5727
```
5828

59-
The content hash argument is the bzz hash as returned by a swarm upload, e.g., using `bzz.upload`:
60-
The name here will allow the name setting, if the top-level domain is 'swarm', it dispatches to the
61-
resolver just registered.
29+
To function, the domain must have a resolver deployed that supports the `setContent` function, and the sending account must have permission to call that function. `ens.register()` deploys a resolver for you that meets this requirement.
30+
31+
The content hash argument is the bzz hash as returned by a swarm upload, e.g., using `bzz.upload`. The name here will allow the name setting, if the top-level domain is 'swarm', it dispatches to the resolver just registered.
6232

6333
```js
6434
bzz.upload("path/to/my/directory", "index.html")
6535
```
6636

6737
Here the second argument to `bzz.upload` is the relative path to the asset mapped on to the root hash of entire collection, effectively the landing page served on the bare hash (and therefore the root of the domain registered with that hash) as url.
6838

69-
The same resolver will allow setting subdomains:
39+
`setContentHash` can also be used on subdomains:
7040

7141
```js
7242
ens.setContentHash("album.swarm","7a59235e5f9c23bf74deb4838e24f75a77f786163f404c8004d79b5674625db0")
@@ -88,20 +58,10 @@ This same backend method is used within swarm to resolve hostnames in urls, henc
8858

8959
## Development
9060

91-
The ABI and BIN files in contract subdirectory implement simple registrar and personal resolver contracts; they're used in tests, and can be used to deploy these contracts for your own purposes.
61+
The SOL file in contract subdirectory implements the ENS root registry, a simple first-in-first-served registrar for the root namespace, and a simple resolver contract; they're used in tests, and can be used to deploy these contracts for your own purposes.
9262

9363
The solidity source code can be found at [github.com/arachnid/ens/](https://github.com/arachnid/ens/).
9464

95-
The ABI and BIN files in the contract subdirectory were generated by
96-
97-
```shell
98-
solc -o `pwd` --optimise --abi --bin OpenRegistrar.sol
99-
solc -o `pwd` --optimise --abi --bin PersonalResolver.sol
100-
```
101-
102-
using the .sol files in [revision 1cbd90d0631e8e30e1c28a394c128e7503ea85c6](https://github.com/Arachnid/ens/commit/1cbd90d0631e8e30e1c28a394c128e7503ea85c6)
103-
with solc version 0.3.2-e3c54185
104-
10565
The go bindings for ENS contracts are generated using `abigen` via the go generator:
10666

10767
```shell

swarm/services/ens/contract/OpenRegistrar.abi

Lines changed: 0 additions & 1 deletion
This file was deleted.

swarm/services/ens/contract/OpenRegistrar.bin

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)