From 600ade0efe6b6c73701266d72e9ca63aa04ce5d9 Mon Sep 17 00:00:00 2001 From: Elad Nachmias Date: Wed, 20 Feb 2019 16:00:50 +0700 Subject: [PATCH] contracts/ens: implement public resolver changes --- contracts/ens/ens.go | 8 +++++--- contracts/ens/ens_test.go | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/ens/ens.go b/contracts/ens/ens.go index 3b3e230b6f..776c622f44 100644 --- a/contracts/ens/ens.go +++ b/contracts/ens/ens.go @@ -17,6 +17,7 @@ package ens //go:generate abigen --sol contract/ENS.sol --pkg contract --out contract/ens.go +//go:generate abigen --sol contract/ENSRegistry.sol --exc contract/ENS.sol:ENS --pkg contract --out contract/ensregistry.go //go:generate abigen --sol contract/FIFSRegistrar.sol --exc contract/ENS.sol:ENS --pkg contract --out contract/fifsregistrar.go //go:generate abigen --sol contract/PublicResolver.sol --exc contract/ENS.sol:ENS --pkg contract --out contract/publicresolver.go @@ -60,7 +61,7 @@ func NewENS(transactOpts *bind.TransactOpts, contractAddr common.Address, contra // DeployENS deploys an instance of the ENS nameservice, with a 'first-in, first-served' root registrar. func DeployENS(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend) (common.Address, *ENS, error) { // Deploy the ENS registry - ensAddr, _, _, err := contract.DeployENS(transactOpts, contractBackend) + ensAddr, _, _, err := contract.DeployENSRegistry(transactOpts, contractBackend) if err != nil { return ensAddr, nil, err } @@ -133,6 +134,7 @@ func (ens *ENS) Resolve(name string) (common.Hash, error) { if err != nil { return common.Hash{}, err } + ret, err := resolver.Contenthash(node) if err != nil { return common.Hash{}, err @@ -181,8 +183,8 @@ func (ens *ENS) Register(name string) (*types.Transaction, error) { } // SetContentHash sets the content hash associated with a name. Only works if the caller -// owns the name, and the associated resolver implements a `setContent` function. -func (ens *ENS) SetContentHash(name string, hash common.Hash) (*types.Transaction, error) { +// owns the name, and the associated resolver implements a `setContenthash` function. +func (ens *ENS) SetContentHash(name string, hash []byte) (*types.Transaction, error) { node := EnsNode(name) resolver, err := ens.getResolver(node) diff --git a/contracts/ens/ens_test.go b/contracts/ens/ens_test.go index cd64fbf15f..862d462580 100644 --- a/contracts/ens/ens_test.go +++ b/contracts/ens/ens_test.go @@ -63,7 +63,7 @@ func TestENS(t *testing.T) { contractBackend.Commit() // Set the content hash for the name. - if _, err = ens.SetContentHash(name, hash); err != nil { + if _, err = ens.SetContentHash(name, hash.Bytes()); err != nil { t.Fatalf("can't set content hash: %v", err) } contractBackend.Commit() @@ -88,7 +88,7 @@ func TestENS(t *testing.T) { if err != nil { t.Fatalf("expected no error, got %v", err) } - if vhost != hash { + if testAddr != recoveredAddr { t.Fatalf("resolve error, expected %v, got %v", testAddr.Hex(), recoveredAddr.Hex()) } }