forked from mirror/go-ethereum
contracts, swarm: implement EIP-1577 (#19285)
* contracts/ens: update public resolver solidity code * contracts/ens: update public resolver, update go bindings * update build * fix ens.sol * contracts/ens: change contract interface * contracts/ens: implement public resolver changes * contracts/ens: added ENSRegistry contract * contracts/ens: reinstate old contract code * contracts/ens: update README.md * contracts/ens: added test coverage for fallback contract * contracts/ens: added support for fallback contract * contracts/ens: removed unused contract code * contracts/ens: add todo and decode multicodec stub * add encode * vendor: add ipfs cid libraries * contracts/ens: cid sanity tests * contracts/ens: more cid sanity checks * contracts/ens: wip integration * wip * Revert "vendor: add ipfs cid libraries" This reverts commit 29d9b6b294ded903a1065d96c8149119713cfd12. * contracts/ens: removed multiformats dependencies * contracts/ens: added decode tests * contracts/ens: added eip spec test, minor changes to exiting tests * contracts/ens: moved cid decoding to own file * contracts/ens: added unit test to encode hash to content hash * contracts/ens: removed unused code * contracts/ens: fix ens tests to use cid decode and encode * contracts/ens: adjust swarm multicodecs after pr merge * contracts/ens: fix linter error * constracts/ens: address PR comments * cmd, contracts: make peoples lives easier * contracts/ens: fix linter error * contracts/ens: address PR commentsChrisChinchilla-patch-3
parent
fb458280d1
commit
e7d1867964
@ -0,0 +1,121 @@ |
||||
// Copyright 2016 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package ens |
||||
|
||||
import ( |
||||
"encoding/binary" |
||||
"errors" |
||||
"fmt" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
) |
||||
|
||||
const ( |
||||
cidv1 = 0x1 |
||||
|
||||
nsIpfs = 0xe3 |
||||
nsSwarm = 0xe4 |
||||
|
||||
swarmTypecode = 0xfa //swarm manifest, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
||||
swarmHashtype = 0xd6 // BMT, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
||||
|
||||
hashLength = 32 |
||||
) |
||||
|
||||
// deocodeEIP1577ContentHash decodes a chain-stored content hash from an ENS record according to EIP-1577
|
||||
// a successful decode will result the different parts of the content hash in accordance to the CID spec
|
||||
// Note: only CIDv1 is supported
|
||||
func decodeEIP1577ContentHash(buf []byte) (storageNs, contentType, hashType, hashLength uint64, hash []byte, err error) { |
||||
if len(buf) < 10 { |
||||
return 0, 0, 0, 0, nil, errors.New("buffer too short") |
||||
} |
||||
|
||||
storageNs, n := binary.Uvarint(buf) |
||||
|
||||
buf = buf[n:] |
||||
vers, n := binary.Uvarint(buf) |
||||
|
||||
if vers != 1 { |
||||
return 0, 0, 0, 0, nil, fmt.Errorf("expected cid v1, got: %d", vers) |
||||
} |
||||
buf = buf[n:] |
||||
contentType, n = binary.Uvarint(buf) |
||||
|
||||
buf = buf[n:] |
||||
hashType, n = binary.Uvarint(buf) |
||||
|
||||
buf = buf[n:] |
||||
hashLength, n = binary.Uvarint(buf) |
||||
|
||||
hash = buf[n:] |
||||
|
||||
if len(hash) != int(hashLength) { |
||||
return 0, 0, 0, 0, nil, errors.New("hash length mismatch") |
||||
} |
||||
return storageNs, contentType, hashType, hashLength, hash, nil |
||||
} |
||||
|
||||
func extractContentHash(buf []byte) (common.Hash, error) { |
||||
storageNs, _ /*contentType*/, _ /* hashType*/, decodedHashLength, hashBytes, err := decodeEIP1577ContentHash(buf) |
||||
|
||||
if err != nil { |
||||
return common.Hash{}, err |
||||
} |
||||
|
||||
if storageNs != nsSwarm { |
||||
return common.Hash{}, errors.New("unknown storage system") |
||||
} |
||||
|
||||
//todo: for the time being we implement loose enforcement for the EIP rules until ENS manager is updated
|
||||
/*if contentType != swarmTypecode { |
||||
return common.Hash{}, errors.New("unknown content type") |
||||
} |
||||
|
||||
if hashType != swarmHashtype { |
||||
return common.Hash{}, errors.New("unknown multihash type") |
||||
}*/ |
||||
|
||||
if decodedHashLength != hashLength { |
||||
return common.Hash{}, errors.New("odd hash length, swarm expects 32 bytes") |
||||
} |
||||
|
||||
if len(hashBytes) != int(hashLength) { |
||||
return common.Hash{}, errors.New("hash length mismatch") |
||||
} |
||||
|
||||
return common.BytesToHash(buf), nil |
||||
} |
||||
|
||||
func EncodeSwarmHash(hash common.Hash) ([]byte, error) { |
||||
var cidBytes []byte |
||||
var headerBytes = []byte{ |
||||
nsSwarm, //swarm namespace
|
||||
cidv1, // CIDv1
|
||||
swarmTypecode, // swarm hash
|
||||
swarmHashtype, // swarm bmt hash
|
||||
hashLength, //hash length. 32 bytes
|
||||
} |
||||
|
||||
varintbuf := make([]byte, binary.MaxVarintLen64) |
||||
for _, v := range headerBytes { |
||||
n := binary.PutUvarint(varintbuf, uint64(v)) |
||||
cidBytes = append(cidBytes, varintbuf[:n]...) |
||||
} |
||||
|
||||
cidBytes = append(cidBytes, hash[:]...) |
||||
return cidBytes, nil |
||||
} |
@ -0,0 +1,158 @@ |
||||
// Copyright 2016 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package ens |
||||
|
||||
import ( |
||||
"bytes" |
||||
"encoding/binary" |
||||
"encoding/hex" |
||||
"fmt" |
||||
"testing" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
) |
||||
|
||||
// Tests for the decoding of the example ENS
|
||||
func TestEIPSpecCidDecode(t *testing.T) { |
||||
const ( |
||||
eipSpecHash = "e3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f" |
||||
eipHash = "29f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f" |
||||
dagPb = 0x70 |
||||
sha2256 = 0x12 |
||||
) |
||||
b, err := hex.DecodeString(eipSpecHash) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
hashBytes, err := hex.DecodeString(eipHash) |
||||
|
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
|
||||
storageNs, contentType, hashType, hashLength, decodedHashBytes, err := decodeEIP1577ContentHash(b) |
||||
|
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if storageNs != nsIpfs { |
||||
t.Fatal("wrong ns") |
||||
} |
||||
if contentType != dagPb { |
||||
t.Fatal("should be ipfs typecode") |
||||
} |
||||
if hashType != sha2256 { |
||||
t.Fatal("should be sha2-256") |
||||
} |
||||
if hashLength != 32 { |
||||
t.Fatal("should be 32") |
||||
} |
||||
if !bytes.Equal(hashBytes, decodedHashBytes) { |
||||
t.Fatal("should be equal") |
||||
} |
||||
|
||||
} |
||||
func TestManualCidDecode(t *testing.T) { |
||||
// call cid encode method with hash. expect byte slice returned, compare according to spec
|
||||
|
||||
for _, v := range []struct { |
||||
name string |
||||
headerBytes []byte |
||||
wantErr bool |
||||
}{ |
||||
{ |
||||
name: "values correct, should not fail", |
||||
headerBytes: []byte{0xe4, 0x01, 0xfa, 0xd6, 0x20}, |
||||
wantErr: false, |
||||
}, |
||||
{ |
||||
name: "cid version wrong, should fail", |
||||
headerBytes: []byte{0xe4, 0x00, 0xfa, 0xd6, 0x20}, |
||||
wantErr: true, |
||||
}, |
||||
{ |
||||
name: "hash length wrong, should fail", |
||||
headerBytes: []byte{0xe4, 0x01, 0xfa, 0xd6, 0x1f}, |
||||
wantErr: true, |
||||
}, |
||||
{ |
||||
name: "values correct for ipfs, should fail", |
||||
headerBytes: []byte{0xe3, 0x01, 0x70, 0x12, 0x20}, |
||||
wantErr: true, |
||||
}, |
||||
{ |
||||
name: "loose values for swarm, todo remove, should not fail", |
||||
headerBytes: []byte{0xe4, 0x01, 0x70, 0x12, 0x20}, |
||||
wantErr: false, |
||||
}, |
||||
{ |
||||
name: "loose values for swarm, todo remove, should not fail", |
||||
headerBytes: []byte{0xe4, 0x01, 0x99, 0x99, 0x20}, |
||||
wantErr: false, |
||||
}, |
||||
} { |
||||
t.Run(v.name, func(t *testing.T) { |
||||
const eipHash = "29f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f" |
||||
|
||||
var bb []byte |
||||
buf := make([]byte, binary.MaxVarintLen64) |
||||
for _, vv := range v.headerBytes { |
||||
n := binary.PutUvarint(buf, uint64(vv)) |
||||
bb = append(bb, buf[:n]...) |
||||
} |
||||
|
||||
h := common.HexToHash(eipHash) |
||||
bb = append(bb, h[:]...) |
||||
str := hex.EncodeToString(bb) |
||||
fmt.Println(str) |
||||
decodedHash, e := extractContentHash(bb) |
||||
switch v.wantErr { |
||||
case true: |
||||
if e == nil { |
||||
t.Fatal("the decode should fail") |
||||
} |
||||
case false: |
||||
if e != nil { |
||||
t.Fatalf("the deccode shouldnt fail: %v", e) |
||||
} |
||||
if !bytes.Equal(decodedHash[:], h[:]) { |
||||
t.Fatal("hashes not equal") |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
func TestManuelCidEncode(t *testing.T) { |
||||
// call cid encode method with hash. expect byte slice returned, compare according to spec
|
||||
const eipHash = "29f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f" |
||||
cidBytes, err := EncodeSwarmHash(common.HexToHash(eipHash)) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
|
||||
// logic in extractContentHash is unit tested thoroughly
|
||||
// hence we just check that the returned hash is equal
|
||||
h, err := extractContentHash(cidBytes) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
|
||||
if bytes.Equal(h[:], cidBytes) { |
||||
t.Fatal("should be equal") |
||||
} |
||||
} |
@ -1,23 +0,0 @@ |
||||
pragma solidity ^0.4.0; |
||||
|
||||
contract AbstractENS { |
||||
function owner(bytes32 node) constant returns(address); |
||||
function resolver(bytes32 node) constant returns(address); |
||||
function ttl(bytes32 node) constant returns(uint64); |
||||
function setOwner(bytes32 node, address owner); |
||||
function setSubnodeOwner(bytes32 node, bytes32 label, address owner); |
||||
function setResolver(bytes32 node, address resolver); |
||||
function setTTL(bytes32 node, uint64 ttl); |
||||
|
||||
// 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); |
||||
} |
@ -1,94 +1,26 @@ |
||||
pragma solidity ^0.4.0; |
||||
pragma solidity >=0.4.24; |
||||
|
||||
import './AbstractENS.sol'; |
||||
interface ENS { |
||||
|
||||
/** |
||||
* The ENS registry contract. |
||||
*/ |
||||
contract ENS is AbstractENS { |
||||
struct Record { |
||||
address owner; |
||||
address resolver; |
||||
uint64 ttl; |
||||
} |
||||
// Logged when the owner of a node assigns a new owner to a subnode. |
||||
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); |
||||
|
||||
mapping(bytes32=>Record) records; |
||||
// Logged when the owner of a node transfers ownership to a new account. |
||||
event Transfer(bytes32 indexed node, address owner); |
||||
|
||||
// Permits modifications only by the owner of the specified node. |
||||
modifier only_owner(bytes32 node) { |
||||
if (records[node].owner != msg.sender) throw; |
||||
_; |
||||
} |
||||
// Logged when the resolver for a node changes. |
||||
event NewResolver(bytes32 indexed node, address resolver); |
||||
|
||||
/** |
||||
* Constructs a new ENS registrar. |
||||
*/ |
||||
function ENS() { |
||||
records[0].owner = msg.sender; |
||||
} |
||||
// Logged when the TTL of a node changes |
||||
event NewTTL(bytes32 indexed node, uint64 ttl); |
||||
|
||||
/** |
||||
* Returns the address that owns the specified node. |
||||
*/ |
||||
function owner(bytes32 node) constant returns (address) { |
||||
return records[node].owner; |
||||
} |
||||
|
||||
/** |
||||
* Returns the address of the resolver for the specified node. |
||||
*/ |
||||
function resolver(bytes32 node) constant returns (address) { |
||||
return records[node].resolver; |
||||
} |
||||
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); |
||||
|
||||
/** |
||||
* Returns the TTL of a node, and any records associated with it. |
||||
*/ |
||||
function ttl(bytes32 node) constant returns (uint64) { |
||||
return records[node].ttl; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
Transfer(node, owner); |
||||
records[node].owner = owner; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
var subnode = sha3(node, label); |
||||
NewOwner(node, label, owner); |
||||
records[subnode].owner = owner; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
NewResolver(node, resolver); |
||||
records[node].resolver = resolver; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
NewTTL(node, ttl); |
||||
records[node].ttl = ttl; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,99 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
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) { |
||||
require(records[node].owner == msg.sender); |
||||
_; |
||||
} |
||||
|
||||
/** |
||||
* @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) external only_owner(node) { |
||||
emit Transfer(node, owner); |
||||
records[node].owner = owner; |
||||
} |
||||
|
||||
/** |
||||
* @dev Transfers ownership of a subnode keccak256(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) external only_owner(node) { |
||||
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) external only_owner(node) { |
||||
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) external only_owner(node) { |
||||
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) external 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) external 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) external view returns (uint64) { |
||||
return records[node].ttl; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,892 @@ |
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package contract |
||||
|
||||
import ( |
||||
"math/big" |
||||
"strings" |
||||
|
||||
ethereum "github.com/ethereum/go-ethereum" |
||||
"github.com/ethereum/go-ethereum/accounts/abi" |
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind" |
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/core/types" |
||||
"github.com/ethereum/go-ethereum/event" |
||||
) |
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var ( |
||||
_ = big.NewInt |
||||
_ = strings.NewReader |
||||
_ = ethereum.NotFound |
||||
_ = abi.U256 |
||||
_ = bind.Bind |
||||
_ = common.Big1 |
||||
_ = types.BloomLookup |
||||
_ = event.NewSubscription |
||||
) |
||||
|
||||
// ENSRegistryABI is the input ABI used to generate the binding from.
|
||||
const ENSRegistryABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"resolver\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"label\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setSubnodeOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"ttl\",\"type\":\"uint64\"}],\"name\":\"setTTL\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"ttl\",\"outputs\":[{\"name\":\"\",\"type\":\"uint64\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"setResolver\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"label\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"NewResolver\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"ttl\",\"type\":\"uint64\"}],\"name\":\"NewTTL\",\"type\":\"event\"}]" |
||||
|
||||
// ENSRegistryBin is the compiled bytecode used for deploying new contracts.
|
||||
const ENSRegistryBin = `0x608060405234801561001057600080fd5b5060008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a0319163317905561059d806100596000396000f3fe6080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008757806302571be3146100cd57806306ab5923146100f757806314ab90381461013857806316a25cbd146101725780631896f70a146101b95780635b0fc9c3146101f2575b600080fd5b34801561009357600080fd5b506100b1600480360360208110156100aa57600080fd5b503561022b565b60408051600160a060020a039092168252519081900360200190f35b3480156100d957600080fd5b506100b1600480360360208110156100f057600080fd5b5035610249565b34801561010357600080fd5b506101366004803603606081101561011a57600080fd5b5080359060208101359060400135600160a060020a0316610264565b005b34801561014457600080fd5b506101366004803603604081101561015b57600080fd5b508035906020013567ffffffffffffffff1661032e565b34801561017e57600080fd5b5061019c6004803603602081101561019557600080fd5b50356103f7565b6040805167ffffffffffffffff9092168252519081900360200190f35b3480156101c557600080fd5b50610136600480360360408110156101dc57600080fd5b5080359060200135600160a060020a031661042e565b3480156101fe57600080fd5b506101366004803603604081101561021557600080fd5b5080359060200135600160a060020a03166104d1565b600090815260208190526040902060010154600160a060020a031690565b600090815260208190526040902054600160a060020a031690565b6000838152602081905260409020548390600160a060020a0316331461028957600080fd5b6040805160208082018790528183018690528251808303840181526060830180855281519190920120600160a060020a0386169091529151859187917fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e829181900360800190a36000908152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039390931692909217909155505050565b6000828152602081905260409020548290600160a060020a0316331461035357600080fd5b6040805167ffffffffffffffff84168152905184917f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68919081900360200190a250600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b6000828152602081905260409020548290600160a060020a0316331461045357600080fd5b60408051600160a060020a0384168152905184917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a250600091825260208290526040909120600101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055565b6000828152602081905260409020548290600160a060020a031633146104f657600080fd5b60408051600160a060020a0384168152905184917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a250600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0390921691909117905556fea165627a7a723058208be97eda88107945616fbd44aa4f2f1ce188b1a930a4bc5f8e1fb7924395d1650029` |
||||
|
||||
// DeployENSRegistry deploys a new Ethereum contract, binding an instance of ENSRegistry to it.
|
||||
func DeployENSRegistry(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ENSRegistry, error) { |
||||
parsed, err := abi.JSON(strings.NewReader(ENSRegistryABI)) |
||||
if err != nil { |
||||
return common.Address{}, nil, nil, err |
||||
} |
||||
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ENSRegistryBin), backend) |
||||
if err != nil { |
||||
return common.Address{}, nil, nil, err |
||||
} |
||||
return address, tx, &ENSRegistry{ENSRegistryCaller: ENSRegistryCaller{contract: contract}, ENSRegistryTransactor: ENSRegistryTransactor{contract: contract}, ENSRegistryFilterer: ENSRegistryFilterer{contract: contract}}, nil |
||||
} |
||||
|
||||
// ENSRegistry is an auto generated Go binding around an Ethereum contract.
|
||||
type ENSRegistry struct { |
||||
ENSRegistryCaller // Read-only binding to the contract
|
||||
ENSRegistryTransactor // Write-only binding to the contract
|
||||
ENSRegistryFilterer // Log filterer for contract events
|
||||
} |
||||
|
||||
// ENSRegistryCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type ENSRegistryCaller struct { |
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
} |
||||
|
||||
// ENSRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type ENSRegistryTransactor struct { |
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
} |
||||
|
||||
// ENSRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type ENSRegistryFilterer struct { |
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
} |
||||
|
||||
// ENSRegistrySession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type ENSRegistrySession struct { |
||||
Contract *ENSRegistry // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
} |
||||
|
||||
// ENSRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type ENSRegistryCallerSession struct { |
||||
Contract *ENSRegistryCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
} |
||||
|
||||
// ENSRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type ENSRegistryTransactorSession struct { |
||||
Contract *ENSRegistryTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
} |
||||
|
||||
// ENSRegistryRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type ENSRegistryRaw struct { |
||||
Contract *ENSRegistry // Generic contract binding to access the raw methods on
|
||||
} |
||||
|
||||
// ENSRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type ENSRegistryCallerRaw struct { |
||||
Contract *ENSRegistryCaller // Generic read-only contract binding to access the raw methods on
|
||||
} |
||||
|
||||
// ENSRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type ENSRegistryTransactorRaw struct { |
||||
Contract *ENSRegistryTransactor // Generic write-only contract binding to access the raw methods on
|
||||
} |
||||
|
||||
// NewENSRegistry creates a new instance of ENSRegistry, bound to a specific deployed contract.
|
||||
func NewENSRegistry(address common.Address, backend bind.ContractBackend) (*ENSRegistry, error) { |
||||
contract, err := bindENSRegistry(address, backend, backend, backend) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistry{ENSRegistryCaller: ENSRegistryCaller{contract: contract}, ENSRegistryTransactor: ENSRegistryTransactor{contract: contract}, ENSRegistryFilterer: ENSRegistryFilterer{contract: contract}}, nil |
||||
} |
||||
|
||||
// NewENSRegistryCaller creates a new read-only instance of ENSRegistry, bound to a specific deployed contract.
|
||||
func NewENSRegistryCaller(address common.Address, caller bind.ContractCaller) (*ENSRegistryCaller, error) { |
||||
contract, err := bindENSRegistry(address, caller, nil, nil) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryCaller{contract: contract}, nil |
||||
} |
||||
|
||||
// NewENSRegistryTransactor creates a new write-only instance of ENSRegistry, bound to a specific deployed contract.
|
||||
func NewENSRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ENSRegistryTransactor, error) { |
||||
contract, err := bindENSRegistry(address, nil, transactor, nil) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryTransactor{contract: contract}, nil |
||||
} |
||||
|
||||
// NewENSRegistryFilterer creates a new log filterer instance of ENSRegistry, bound to a specific deployed contract.
|
||||
func NewENSRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ENSRegistryFilterer, error) { |
||||
contract, err := bindENSRegistry(address, nil, nil, filterer) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryFilterer{contract: contract}, nil |
||||
} |
||||
|
||||
// bindENSRegistry binds a generic wrapper to an already deployed contract.
|
||||
func bindENSRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { |
||||
parsed, err := abi.JSON(strings.NewReader(ENSRegistryABI)) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil |
||||
} |
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_ENSRegistry *ENSRegistryRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { |
||||
return _ENSRegistry.Contract.ENSRegistryCaller.contract.Call(opts, result, method, params...) |
||||
} |
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_ENSRegistry *ENSRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.ENSRegistryTransactor.contract.Transfer(opts) |
||||
} |
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_ENSRegistry *ENSRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.ENSRegistryTransactor.contract.Transact(opts, method, params...) |
||||
} |
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_ENSRegistry *ENSRegistryCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { |
||||
return _ENSRegistry.Contract.contract.Call(opts, result, method, params...) |
||||
} |
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_ENSRegistry *ENSRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.contract.Transfer(opts) |
||||
} |
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_ENSRegistry *ENSRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.contract.Transact(opts, method, params...) |
||||
} |
||||
|
||||
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||
//
|
||||
// Solidity: function owner(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistryCaller) Owner(opts *bind.CallOpts, node [32]byte) (common.Address, error) { |
||||
var ( |
||||
ret0 = new(common.Address) |
||||
) |
||||
out := ret0 |
||||
err := _ENSRegistry.contract.Call(opts, out, "owner", node) |
||||
return *ret0, err |
||||
} |
||||
|
||||
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||
//
|
||||
// Solidity: function owner(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistrySession) Owner(node [32]byte) (common.Address, error) { |
||||
return _ENSRegistry.Contract.Owner(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||
//
|
||||
// Solidity: function owner(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistryCallerSession) Owner(node [32]byte) (common.Address, error) { |
||||
return _ENSRegistry.Contract.Owner(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||
//
|
||||
// Solidity: function resolver(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistryCaller) Resolver(opts *bind.CallOpts, node [32]byte) (common.Address, error) { |
||||
var ( |
||||
ret0 = new(common.Address) |
||||
) |
||||
out := ret0 |
||||
err := _ENSRegistry.contract.Call(opts, out, "resolver", node) |
||||
return *ret0, err |
||||
} |
||||
|
||||
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||
//
|
||||
// Solidity: function resolver(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistrySession) Resolver(node [32]byte) (common.Address, error) { |
||||
return _ENSRegistry.Contract.Resolver(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||
//
|
||||
// Solidity: function resolver(bytes32 node) constant returns(address)
|
||||
func (_ENSRegistry *ENSRegistryCallerSession) Resolver(node [32]byte) (common.Address, error) { |
||||
return _ENSRegistry.Contract.Resolver(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||
//
|
||||
// Solidity: function ttl(bytes32 node) constant returns(uint64)
|
||||
func (_ENSRegistry *ENSRegistryCaller) Ttl(opts *bind.CallOpts, node [32]byte) (uint64, error) { |
||||
var ( |
||||
ret0 = new(uint64) |
||||
) |
||||
out := ret0 |
||||
err := _ENSRegistry.contract.Call(opts, out, "ttl", node) |
||||
return *ret0, err |
||||
} |
||||
|
||||
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||
//
|
||||
// Solidity: function ttl(bytes32 node) constant returns(uint64)
|
||||
func (_ENSRegistry *ENSRegistrySession) Ttl(node [32]byte) (uint64, error) { |
||||
return _ENSRegistry.Contract.Ttl(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||
//
|
||||
// Solidity: function ttl(bytes32 node) constant returns(uint64)
|
||||
func (_ENSRegistry *ENSRegistryCallerSession) Ttl(node [32]byte) (uint64, error) { |
||||
return _ENSRegistry.Contract.Ttl(&_ENSRegistry.CallOpts, node) |
||||
} |
||||
|
||||
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||
//
|
||||
// Solidity: function setOwner(bytes32 node, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactor) SetOwner(opts *bind.TransactOpts, node [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.contract.Transact(opts, "setOwner", node, owner) |
||||
} |
||||
|
||||
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||
//
|
||||
// Solidity: function setOwner(bytes32 node, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistrySession) SetOwner(node [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetOwner(&_ENSRegistry.TransactOpts, node, owner) |
||||
} |
||||
|
||||
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||
//
|
||||
// Solidity: function setOwner(bytes32 node, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactorSession) SetOwner(node [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetOwner(&_ENSRegistry.TransactOpts, node, owner) |
||||
} |
||||
|
||||
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||
//
|
||||
// Solidity: function setResolver(bytes32 node, address resolver) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactor) SetResolver(opts *bind.TransactOpts, node [32]byte, resolver common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.contract.Transact(opts, "setResolver", node, resolver) |
||||
} |
||||
|
||||
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||
//
|
||||
// Solidity: function setResolver(bytes32 node, address resolver) returns()
|
||||
func (_ENSRegistry *ENSRegistrySession) SetResolver(node [32]byte, resolver common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetResolver(&_ENSRegistry.TransactOpts, node, resolver) |
||||
} |
||||
|
||||
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||
//
|
||||
// Solidity: function setResolver(bytes32 node, address resolver) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactorSession) SetResolver(node [32]byte, resolver common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetResolver(&_ENSRegistry.TransactOpts, node, resolver) |
||||
} |
||||
|
||||
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||
//
|
||||
// Solidity: function setSubnodeOwner(bytes32 node, bytes32 label, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactor) SetSubnodeOwner(opts *bind.TransactOpts, node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.contract.Transact(opts, "setSubnodeOwner", node, label, owner) |
||||
} |
||||
|
||||
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||
//
|
||||
// Solidity: function setSubnodeOwner(bytes32 node, bytes32 label, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistrySession) SetSubnodeOwner(node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetSubnodeOwner(&_ENSRegistry.TransactOpts, node, label, owner) |
||||
} |
||||
|
||||
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||
//
|
||||
// Solidity: function setSubnodeOwner(bytes32 node, bytes32 label, address owner) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactorSession) SetSubnodeOwner(node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetSubnodeOwner(&_ENSRegistry.TransactOpts, node, label, owner) |
||||
} |
||||
|
||||
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||
//
|
||||
// Solidity: function setTTL(bytes32 node, uint64 ttl) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactor) SetTTL(opts *bind.TransactOpts, node [32]byte, ttl uint64) (*types.Transaction, error) { |
||||
return _ENSRegistry.contract.Transact(opts, "setTTL", node, ttl) |
||||
} |
||||
|
||||
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||
//
|
||||
// Solidity: function setTTL(bytes32 node, uint64 ttl) returns()
|
||||
func (_ENSRegistry *ENSRegistrySession) SetTTL(node [32]byte, ttl uint64) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetTTL(&_ENSRegistry.TransactOpts, node, ttl) |
||||
} |
||||
|
||||
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||
//
|
||||
// Solidity: function setTTL(bytes32 node, uint64 ttl) returns()
|
||||
func (_ENSRegistry *ENSRegistryTransactorSession) SetTTL(node [32]byte, ttl uint64) (*types.Transaction, error) { |
||||
return _ENSRegistry.Contract.SetTTL(&_ENSRegistry.TransactOpts, node, ttl) |
||||
} |
||||
|
||||
// ENSRegistryNewOwnerIterator is returned from FilterNewOwner and is used to iterate over the raw logs and unpacked data for NewOwner events raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewOwnerIterator struct { |
||||
Event *ENSRegistryNewOwner // Event containing the contract specifics and raw log
|
||||
|
||||
contract *bind.BoundContract // Generic contract to use for unpacking event data
|
||||
event string // Event name to use for unpacking event data
|
||||
|
||||
logs chan types.Log // Log channel receiving the found contract events
|
||||
sub ethereum.Subscription // Subscription for errors, completion and termination
|
||||
done bool // Whether the subscription completed delivering logs
|
||||
fail error // Occurred error to stop iteration
|
||||
} |
||||
|
||||
// Next advances the iterator to the subsequent event, returning whether there
|
||||
// are any more events found. In case of a retrieval or parsing error, false is
|
||||
// returned and Error() can be queried for the exact failure.
|
||||
func (it *ENSRegistryNewOwnerIterator) Next() bool { |
||||
// If the iterator failed, stop iterating
|
||||
if it.fail != nil { |
||||
return false |
||||
} |
||||
// If the iterator completed, deliver directly whatever's available
|
||||
if it.done { |
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewOwner) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
// Iterator still in progress, wait for either a data or an error event
|
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewOwner) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
case err := <-it.sub.Err(): |
||||
it.done = true |
||||
it.fail = err |
||||
return it.Next() |
||||
} |
||||
} |
||||
|
||||
// Error returns any retrieval or parsing error occurred during filtering.
|
||||
func (it *ENSRegistryNewOwnerIterator) Error() error { |
||||
return it.fail |
||||
} |
||||
|
||||
// Close terminates the iteration process, releasing any pending underlying
|
||||
// resources.
|
||||
func (it *ENSRegistryNewOwnerIterator) Close() error { |
||||
it.sub.Unsubscribe() |
||||
return nil |
||||
} |
||||
|
||||
// ENSRegistryNewOwner represents a NewOwner event raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewOwner struct { |
||||
Node [32]byte |
||||
Label [32]byte |
||||
Owner common.Address |
||||
Raw types.Log // Blockchain specific contextual infos
|
||||
} |
||||
|
||||
// FilterNewOwner is a free log retrieval operation binding the contract event 0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82.
|
||||
//
|
||||
// Solidity: event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) FilterNewOwner(opts *bind.FilterOpts, node [][32]byte, label [][32]byte) (*ENSRegistryNewOwnerIterator, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
var labelRule []interface{} |
||||
for _, labelItem := range label { |
||||
labelRule = append(labelRule, labelItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.FilterLogs(opts, "NewOwner", nodeRule, labelRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryNewOwnerIterator{contract: _ENSRegistry.contract, event: "NewOwner", logs: logs, sub: sub}, nil |
||||
} |
||||
|
||||
// WatchNewOwner is a free log subscription operation binding the contract event 0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82.
|
||||
//
|
||||
// Solidity: event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) WatchNewOwner(opts *bind.WatchOpts, sink chan<- *ENSRegistryNewOwner, node [][32]byte, label [][32]byte) (event.Subscription, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
var labelRule []interface{} |
||||
for _, labelItem := range label { |
||||
labelRule = append(labelRule, labelItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.WatchLogs(opts, "NewOwner", nodeRule, labelRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return event.NewSubscription(func(quit <-chan struct{}) error { |
||||
defer sub.Unsubscribe() |
||||
for { |
||||
select { |
||||
case log := <-logs: |
||||
// New log arrived, parse the event and forward to the user
|
||||
event := new(ENSRegistryNewOwner) |
||||
if err := _ENSRegistry.contract.UnpackLog(event, "NewOwner", log); err != nil { |
||||
return err |
||||
} |
||||
event.Raw = log |
||||
|
||||
select { |
||||
case sink <- event: |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
} |
||||
}), nil |
||||
} |
||||
|
||||
// ENSRegistryNewResolverIterator is returned from FilterNewResolver and is used to iterate over the raw logs and unpacked data for NewResolver events raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewResolverIterator struct { |
||||
Event *ENSRegistryNewResolver // Event containing the contract specifics and raw log
|
||||
|
||||
contract *bind.BoundContract // Generic contract to use for unpacking event data
|
||||
event string // Event name to use for unpacking event data
|
||||
|
||||
logs chan types.Log // Log channel receiving the found contract events
|
||||
sub ethereum.Subscription // Subscription for errors, completion and termination
|
||||
done bool // Whether the subscription completed delivering logs
|
||||
fail error // Occurred error to stop iteration
|
||||
} |
||||
|
||||
// Next advances the iterator to the subsequent event, returning whether there
|
||||
// are any more events found. In case of a retrieval or parsing error, false is
|
||||
// returned and Error() can be queried for the exact failure.
|
||||
func (it *ENSRegistryNewResolverIterator) Next() bool { |
||||
// If the iterator failed, stop iterating
|
||||
if it.fail != nil { |
||||
return false |
||||
} |
||||
// If the iterator completed, deliver directly whatever's available
|
||||
if it.done { |
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewResolver) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
// Iterator still in progress, wait for either a data or an error event
|
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewResolver) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
case err := <-it.sub.Err(): |
||||
it.done = true |
||||
it.fail = err |
||||
return it.Next() |
||||
} |
||||
} |
||||
|
||||
// Error returns any retrieval or parsing error occurred during filtering.
|
||||
func (it *ENSRegistryNewResolverIterator) Error() error { |
||||
return it.fail |
||||
} |
||||
|
||||
// Close terminates the iteration process, releasing any pending underlying
|
||||
// resources.
|
||||
func (it *ENSRegistryNewResolverIterator) Close() error { |
||||
it.sub.Unsubscribe() |
||||
return nil |
||||
} |
||||
|
||||
// ENSRegistryNewResolver represents a NewResolver event raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewResolver struct { |
||||
Node [32]byte |
||||
Resolver common.Address |
||||
Raw types.Log // Blockchain specific contextual infos
|
||||
} |
||||
|
||||
// FilterNewResolver is a free log retrieval operation binding the contract event 0x335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0.
|
||||
//
|
||||
// Solidity: event NewResolver(bytes32 indexed node, address resolver)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) FilterNewResolver(opts *bind.FilterOpts, node [][32]byte) (*ENSRegistryNewResolverIterator, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.FilterLogs(opts, "NewResolver", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryNewResolverIterator{contract: _ENSRegistry.contract, event: "NewResolver", logs: logs, sub: sub}, nil |
||||
} |
||||
|
||||
// WatchNewResolver is a free log subscription operation binding the contract event 0x335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0.
|
||||
//
|
||||
// Solidity: event NewResolver(bytes32 indexed node, address resolver)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) WatchNewResolver(opts *bind.WatchOpts, sink chan<- *ENSRegistryNewResolver, node [][32]byte) (event.Subscription, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.WatchLogs(opts, "NewResolver", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return event.NewSubscription(func(quit <-chan struct{}) error { |
||||
defer sub.Unsubscribe() |
||||
for { |
||||
select { |
||||
case log := <-logs: |
||||
// New log arrived, parse the event and forward to the user
|
||||
event := new(ENSRegistryNewResolver) |
||||
if err := _ENSRegistry.contract.UnpackLog(event, "NewResolver", log); err != nil { |
||||
return err |
||||
} |
||||
event.Raw = log |
||||
|
||||
select { |
||||
case sink <- event: |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
} |
||||
}), nil |
||||
} |
||||
|
||||
// ENSRegistryNewTTLIterator is returned from FilterNewTTL and is used to iterate over the raw logs and unpacked data for NewTTL events raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewTTLIterator struct { |
||||
Event *ENSRegistryNewTTL // Event containing the contract specifics and raw log
|
||||
|
||||
contract *bind.BoundContract // Generic contract to use for unpacking event data
|
||||
event string // Event name to use for unpacking event data
|
||||
|
||||
logs chan types.Log // Log channel receiving the found contract events
|
||||
sub ethereum.Subscription // Subscription for errors, completion and termination
|
||||
done bool // Whether the subscription completed delivering logs
|
||||
fail error // Occurred error to stop iteration
|
||||
} |
||||
|
||||
// Next advances the iterator to the subsequent event, returning whether there
|
||||
// are any more events found. In case of a retrieval or parsing error, false is
|
||||
// returned and Error() can be queried for the exact failure.
|
||||
func (it *ENSRegistryNewTTLIterator) Next() bool { |
||||
// If the iterator failed, stop iterating
|
||||
if it.fail != nil { |
||||
return false |
||||
} |
||||
// If the iterator completed, deliver directly whatever's available
|
||||
if it.done { |
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewTTL) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
// Iterator still in progress, wait for either a data or an error event
|
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryNewTTL) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
case err := <-it.sub.Err(): |
||||
it.done = true |
||||
it.fail = err |
||||
return it.Next() |
||||
} |
||||
} |
||||
|
||||
// Error returns any retrieval or parsing error occurred during filtering.
|
||||
func (it *ENSRegistryNewTTLIterator) Error() error { |
||||
return it.fail |
||||
} |
||||
|
||||
// Close terminates the iteration process, releasing any pending underlying
|
||||
// resources.
|
||||
func (it *ENSRegistryNewTTLIterator) Close() error { |
||||
it.sub.Unsubscribe() |
||||
return nil |
||||
} |
||||
|
||||
// ENSRegistryNewTTL represents a NewTTL event raised by the ENSRegistry contract.
|
||||
type ENSRegistryNewTTL struct { |
||||
Node [32]byte |
||||
Ttl uint64 |
||||
Raw types.Log // Blockchain specific contextual infos
|
||||
} |
||||
|
||||
// FilterNewTTL is a free log retrieval operation binding the contract event 0x1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68.
|
||||
//
|
||||
// Solidity: event NewTTL(bytes32 indexed node, uint64 ttl)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) FilterNewTTL(opts *bind.FilterOpts, node [][32]byte) (*ENSRegistryNewTTLIterator, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.FilterLogs(opts, "NewTTL", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryNewTTLIterator{contract: _ENSRegistry.contract, event: "NewTTL", logs: logs, sub: sub}, nil |
||||
} |
||||
|
||||
// WatchNewTTL is a free log subscription operation binding the contract event 0x1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68.
|
||||
//
|
||||
// Solidity: event NewTTL(bytes32 indexed node, uint64 ttl)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) WatchNewTTL(opts *bind.WatchOpts, sink chan<- *ENSRegistryNewTTL, node [][32]byte) (event.Subscription, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.WatchLogs(opts, "NewTTL", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return event.NewSubscription(func(quit <-chan struct{}) error { |
||||
defer sub.Unsubscribe() |
||||
for { |
||||
select { |
||||
case log := <-logs: |
||||
// New log arrived, parse the event and forward to the user
|
||||
event := new(ENSRegistryNewTTL) |
||||
if err := _ENSRegistry.contract.UnpackLog(event, "NewTTL", log); err != nil { |
||||
return err |
||||
} |
||||
event.Raw = log |
||||
|
||||
select { |
||||
case sink <- event: |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
} |
||||
}), nil |
||||
} |
||||
|
||||
// ENSRegistryTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the ENSRegistry contract.
|
||||
type ENSRegistryTransferIterator struct { |
||||
Event *ENSRegistryTransfer // Event containing the contract specifics and raw log
|
||||
|
||||
contract *bind.BoundContract // Generic contract to use for unpacking event data
|
||||
event string // Event name to use for unpacking event data
|
||||
|
||||
logs chan types.Log // Log channel receiving the found contract events
|
||||
sub ethereum.Subscription // Subscription for errors, completion and termination
|
||||
done bool // Whether the subscription completed delivering logs
|
||||
fail error // Occurred error to stop iteration
|
||||
} |
||||
|
||||
// Next advances the iterator to the subsequent event, returning whether there
|
||||
// are any more events found. In case of a retrieval or parsing error, false is
|
||||
// returned and Error() can be queried for the exact failure.
|
||||
func (it *ENSRegistryTransferIterator) Next() bool { |
||||
// If the iterator failed, stop iterating
|
||||
if it.fail != nil { |
||||
return false |
||||
} |
||||
// If the iterator completed, deliver directly whatever's available
|
||||
if it.done { |
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryTransfer) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
// Iterator still in progress, wait for either a data or an error event
|
||||
select { |
||||
case log := <-it.logs: |
||||
it.Event = new(ENSRegistryTransfer) |
||||
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { |
||||
it.fail = err |
||||
return false |
||||
} |
||||
it.Event.Raw = log |
||||
return true |
||||
|
||||
case err := <-it.sub.Err(): |
||||
it.done = true |
||||
it.fail = err |
||||
return it.Next() |
||||
} |
||||
} |
||||
|
||||
// Error returns any retrieval or parsing error occurred during filtering.
|
||||
func (it *ENSRegistryTransferIterator) Error() error { |
||||
return it.fail |
||||
} |
||||
|
||||
// Close terminates the iteration process, releasing any pending underlying
|
||||
// resources.
|
||||
func (it *ENSRegistryTransferIterator) Close() error { |
||||
it.sub.Unsubscribe() |
||||
return nil |
||||
} |
||||
|
||||
// ENSRegistryTransfer represents a Transfer event raised by the ENSRegistry contract.
|
||||
type ENSRegistryTransfer struct { |
||||
Node [32]byte |
||||
Owner common.Address |
||||
Raw types.Log // Blockchain specific contextual infos
|
||||
} |
||||
|
||||
// FilterTransfer is a free log retrieval operation binding the contract event 0xd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266.
|
||||
//
|
||||
// Solidity: event Transfer(bytes32 indexed node, address owner)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) FilterTransfer(opts *bind.FilterOpts, node [][32]byte) (*ENSRegistryTransferIterator, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.FilterLogs(opts, "Transfer", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return &ENSRegistryTransferIterator{contract: _ENSRegistry.contract, event: "Transfer", logs: logs, sub: sub}, nil |
||||
} |
||||
|
||||
// WatchTransfer is a free log subscription operation binding the contract event 0xd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266.
|
||||
//
|
||||
// Solidity: event Transfer(bytes32 indexed node, address owner)
|
||||
func (_ENSRegistry *ENSRegistryFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *ENSRegistryTransfer, node [][32]byte) (event.Subscription, error) { |
||||
|
||||
var nodeRule []interface{} |
||||
for _, nodeItem := range node { |
||||
nodeRule = append(nodeRule, nodeItem) |
||||
} |
||||
|
||||
logs, sub, err := _ENSRegistry.contract.WatchLogs(opts, "Transfer", nodeRule) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return event.NewSubscription(func(quit <-chan struct{}) error { |
||||
defer sub.Unsubscribe() |
||||
for { |
||||
select { |
||||
case log := <-logs: |
||||
// New log arrived, parse the event and forward to the user
|
||||
event := new(ENSRegistryTransfer) |
||||
if err := _ENSRegistry.contract.UnpackLog(event, "Transfer", log); err != nil { |
||||
return err |
||||
} |
||||
event.Raw = log |
||||
|
||||
select { |
||||
case sink <- event: |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
case err := <-sub.Err(): |
||||
return err |
||||
case <-quit: |
||||
return nil |
||||
} |
||||
} |
||||
}), nil |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,212 @@ |
||||
pragma solidity ^0.4.0; |
||||
|
||||
import './AbstractENS.sol'; |
||||
|
||||
/** |
||||
* A simple resolver anyone can use; only allows the owner of a node to set its |
||||
* address. |
||||
*/ |
||||
contract PublicResolver { |
||||
bytes4 constant INTERFACE_META_ID = 0x01ffc9a7; |
||||
bytes4 constant ADDR_INTERFACE_ID = 0x3b3b57de; |
||||
bytes4 constant CONTENT_INTERFACE_ID = 0xd8389dc5; |
||||
bytes4 constant NAME_INTERFACE_ID = 0x691f3431; |
||||
bytes4 constant ABI_INTERFACE_ID = 0x2203ab56; |
||||
bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233; |
||||
bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c; |
||||
|
||||
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 indexed 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; |
||||
} |
||||
|
||||
AbstractENS ens; |
||||
mapping(bytes32=>Record) records; |
||||
|
||||
modifier only_owner(bytes32 node) { |
||||
if (ens.owner(node) != msg.sender) throw; |
||||
_; |
||||
} |
||||
|
||||
/** |
||||
* Constructor. |
||||
* @param ensAddr The ENS registrar contract. |
||||
*/ |
||||
function PublicResolver(AbstractENS ensAddr) { |
||||
ens = ensAddr; |
||||
} |
||||
|
||||
/** |
||||
* Returns true if the resolver implements the interface specified by the provided hash. |
||||
* @param interfaceID The ID of the interface to check for. |
||||
* @return True if the contract implements the requested interface. |
||||
*/ |
||||
function supportsInterface(bytes4 interfaceID) constant returns (bool) { |
||||
return interfaceID == ADDR_INTERFACE_ID || |
||||
interfaceID == CONTENT_INTERFACE_ID || |
||||
interfaceID == NAME_INTERFACE_ID || |
||||
interfaceID == ABI_INTERFACE_ID || |
||||
interfaceID == PUBKEY_INTERFACE_ID || |
||||
interfaceID == TEXT_INTERFACE_ID || |
||||
interfaceID == INTERFACE_META_ID; |
||||
} |
||||
|
||||
/** |
||||
* Returns the address associated with an ENS node. |
||||
* @param node The ENS node to query. |
||||
* @return The associated address. |
||||
*/ |
||||
function addr(bytes32 node) constant returns (address ret) { |
||||
ret = records[node].addr; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
records[node].addr = addr; |
||||
AddrChanged(node, addr); |
||||
} |
||||
|
||||
/** |
||||
* 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) constant returns (bytes32 ret) { |
||||
ret = records[node].content; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
records[node].content = hash; |
||||
ContentChanged(node, hash); |
||||
} |
||||
|
||||
/** |
||||
* 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) constant returns (string ret) { |
||||
ret = records[node].name; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
records[node].name = name; |
||||
NameChanged(node, name); |
||||
} |
||||
|
||||
/** |
||||
* 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) constant returns (uint256 contentType, bytes data) { |
||||
var 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; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
// Content types must be powers of 2 |
||||
if (((contentType - 1) & contentType) != 0) throw; |
||||
|
||||
records[node].abis[contentType] = data; |
||||
ABIChanged(node, contentType); |
||||
} |
||||
|
||||
/** |
||||
* 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) constant returns (bytes32 x, bytes32 y) { |
||||
return (records[node].pubkey.x, records[node].pubkey.y); |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
records[node].pubkey = PublicKey(x, y); |
||||
PubkeyChanged(node, x, y); |
||||
} |
||||
|
||||
/** |
||||
* 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) constant returns (string ret) { |
||||
ret = records[node].text[key]; |
||||
} |
||||
|
||||
/** |
||||
* 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) only_owner(node) { |
||||
records[node].text[key] = value; |
||||
TextChanged(node, key, key); |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue