Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for content hash (EIP1577) for ENS domains #1411

Closed
wants to merge 12 commits into from
41 changes: 41 additions & 0 deletions docs/ens_overview.rst
Expand Up @@ -65,6 +65,26 @@ The ``ENS`` module has no opinion as to which TLD you can use,
but will not infer a TLD if it is not provided with the name.


Look up the content for an ENS name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

from ens.auto import ns


# look up the content record for a name

content = ns.content('almonit.eth')

assert content['type'] == ipfs-ns'
assert content['hash'] == 'QmaDyyRFycWw2WZLBwDMY2sHL4pscwFm3HwZKu7xKRjjmK'


The ``ENS`` module has no opinion as to which TLD you can use,
but will not infer a TLD if it is not provided with the name.


Get name from address
^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -125,6 +145,27 @@ Wait for the transaction to be mined, then:
assert ns.address('supreme.executive.power.derives.from.a.mandate.from.the.masses.jasoncarver.eth') == \
'0x5B2063246F2191f18F2675ceDB8b28102e957458'


Point your name to your content
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Do you want to set up your name so that :meth:`~ens.main.ENS.content` will show the
content it points to?

::

content = {
'type': 'ipfs-ns',
'hash': 'QmaDyyRFycWw2WZLBwDMY2sHL4pscwFm3HwZKu7xKRjjmK',
}
ns.setup_content('jasoncarver.eth', content)

You must already be the owner of the domain (or its parent).

You can claim arbitrarily deep subdomains. *Gas costs scale up with the
number of subdomains!*


Allow people to find your name using your address
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
172 changes: 144 additions & 28 deletions ens/abis.py
Expand Up @@ -959,6 +959,43 @@
]

RESOLVER = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@njgheorghita another place that should get updated eventually to use an EthPM package. I was under the impression you might already have the ENS contracts packaged up?

{
"constant": False,
"inputs": [
{
"name": "node",
"type": "bytes32"
},
{
"name": "hash",
"type": "bytes32"
}
],
"name": "setContent",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": True,
"inputs": [
{
"name": "node",
"type": "bytes32"
}
],
"name": "content",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
"constant": True,
"inputs": [
Expand All @@ -975,6 +1012,29 @@
}
],
"payable": False,
"stateMutability": "pure",
"type": "function"
},
{
"constant": False,
"inputs": [
{
"name": "node",
"type": "bytes32"
},
{
"name": "key",
"type": "string"
},
{
"name": "value",
"type": "string"
}
],
"name": "setText",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -1001,6 +1061,7 @@
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1022,6 +1083,25 @@
"name": "setPubkey",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": False,
"inputs": [
{
"name": "node",
"type": "bytes32"
},
{
"name": "hash",
"type": "bytes"
}
],
"name": "setContenthash",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -1032,14 +1112,15 @@
"type": "bytes32"
}
],
"name": "content",
"name": "addr",
"outputs": [
{
"name": "ret",
"type": "bytes32"
"name": "",
"type": "address"
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1048,16 +1129,21 @@
{
"name": "node",
"type": "bytes32"
},
{
"name": "key",
"type": "string"
}
],
"name": "addr",
"name": "text",
"outputs": [
{
"name": "ret",
"type": "address"
"name": "",
"type": "string"
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1079,6 +1165,7 @@
"name": "setABI",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -1092,11 +1179,12 @@
"name": "name",
"outputs": [
{
"name": "ret",
"name": "",
"type": "string"
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1114,23 +1202,26 @@
"name": "setName",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": False,
"constant": True,
"inputs": [
{
"name": "node",
"type": "bytes32"
},
}
],
"name": "contenthash",
"outputs": [
{
"name": "hash",
"type": "bytes32"
"name": "",
"type": "bytes"
}
],
"name": "setContent",
"outputs": [],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1153,6 +1244,7 @@
}
],
"payable": False,
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -1170,6 +1262,7 @@
"name": "setAddr",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -1180,6 +1273,7 @@
}
],
"payable": False,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
Expand Down Expand Up @@ -1209,11 +1303,11 @@
},
{
"indexed": False,
"name": "hash",
"type": "bytes32"
"name": "name",
"type": "string"
}
],
"name": "ContentChanged",
"name": "NameChanged",
"type": "event"
},
{
Expand All @@ -1225,12 +1319,12 @@
"type": "bytes32"
},
{
"indexed": False,
"name": "name",
"type": "string"
"indexed": True,
"name": "contentType",
"type": "uint256"
}
],
"name": "NameChanged",
"name": "ABIChanged",
"type": "event"
},
{
Expand All @@ -1242,12 +1336,17 @@
"type": "bytes32"
},
{
"indexed": True,
"name": "contentType",
"type": "uint256"
"indexed": False,
"name": "x",
"type": "bytes32"
},
{
"indexed": False,
"name": "y",
"type": "bytes32"
}
],
"name": "ABIChanged",
"name": "PubkeyChanged",
"type": "event"
},
{
Expand All @@ -1260,16 +1359,33 @@
},
{
"indexed": False,
"name": "x",
"type": "bytes32"
"name": "indexedKey",
"type": "string"
},
{
"indexed": False,
"name": "y",
"name": "key",
"type": "string"
}
],
"name": "TextChanged",
"type": "event"
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"name": "node",
"type": "bytes32"
},
{
"indexed": False,
"name": "hash",
"type": "bytes"
}
],
"name": "PubkeyChanged",
"name": "ContenthashChanged",
"type": "event"
}
]
Expand Down
3 changes: 3 additions & 0 deletions ens/constants.py
Expand Up @@ -8,3 +8,6 @@
EMPTY_ADDR_HEX = '0x' + '00' * 20

REVERSE_REGISTRAR_DOMAIN = 'addr.reverse'

RESOLVER_EIP1577_INTERFACE = '0xbc1c58d1'
RESOLVER_LEGACY_INTERFACE = '0xd8389dc5'
6 changes: 3 additions & 3 deletions ens/contract_data.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ens/exceptions.py
Expand Up @@ -61,6 +61,13 @@ class InvalidLabel(ValueError):
pass


class NonStandardResolver(ValueError):
"""
Raised if resolver is not standard
"""
pass


class OversizeTransaction(ValueError):
"""
Raised if a transaction you are trying to create would cost so
Expand Down