aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/ens/ens.go
diff options
context:
space:
mode:
authorJavier Peletier <jpeletier@users.noreply.github.com>2018-09-29 04:46:41 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-09-29 04:46:41 +0800
commitf1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0 (patch)
tree8a69bda14344da2d8829b74992fa6de5cb213890 /contracts/ens/ens.go
parent79ca6c7a657f5f6660fb136707edb07951bb3309 (diff)
downloaddexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.gz
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.bz2
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.lz
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.xz
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.zst
dexon-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.zip
contracts/ens: expose Add and SetAddr in ENS (#17661)
I am planning to use this to resolve names to user addresses for Swarm/MRU feeds.
Diffstat (limited to 'contracts/ens/ens.go')
-rw-r--r--contracts/ens/ens.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/contracts/ens/ens.go b/contracts/ens/ens.go
index 75d9d0e4b..b7448c471 100644
--- a/contracts/ens/ens.go
+++ b/contracts/ens/ens.go
@@ -151,6 +151,38 @@ func (self *ENS) Resolve(name string) (common.Hash, error) {
return common.BytesToHash(ret[:]), nil
}
+// Addr is a non-transactional call that returns the address associated with a name.
+func (self *ENS) Addr(name string) (common.Address, error) {
+ node := EnsNode(name)
+
+ resolver, err := self.getResolver(node)
+ if err != nil {
+ return common.Address{}, err
+ }
+
+ ret, err := resolver.Addr(node)
+ if err != nil {
+ return common.Address{}, err
+ }
+
+ return common.BytesToAddress(ret[:]), nil
+}
+
+// SetAddress sets the address associated with a name. Only works if the caller
+// owns the name, and the associated resolver implements a `setAddress` function.
+func (self *ENS) SetAddr(name string, addr common.Address) (*types.Transaction, error) {
+ node := EnsNode(name)
+
+ resolver, err := self.getResolver(node)
+ if err != nil {
+ return nil, err
+ }
+
+ opts := self.TransactOpts
+ opts.GasLimit = 200000
+ return resolver.Contract.SetAddr(&opts, node, addr)
+}
+
// Register registers a new domain name for the caller, making them the owner of the new name.
// Only works if the registrar for the parent domain implements the FIFS registrar protocol.
func (self *ENS) Register(name string) (*types.Transaction, error) {