mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
swarm/services/ens:
* Fix tests by including ENS contracts to deploy * update bin with bytecode compiled with solc v0.3.5-0 * update go bindings with abigen * complete README with generate instructions * simplify ens.Resolve removing legacy versioning support * remove glogging from test swarm/network: guard against short data in store requests cmd/utils: add missing file input.go for relocated UnlockAccount
This commit is contained in:
parent
0460fbad11
commit
4d59db2988
12 changed files with 964 additions and 22 deletions
113
cmd/utils/input.go
Normal file
113
cmd/utils/input.go
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// go-ethereum 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 General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
// "strings"
|
||||||
|
"github.com/ethereum/go-ethereum/console"
|
||||||
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
|
"github.com/ethereum/go-ethereum/logger/glog"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
// "github.com/peterh/liner"
|
||||||
|
)
|
||||||
|
|
||||||
|
// tries unlocking the specified account a few times.
|
||||||
|
func UnlockAccount(ctx *cli.Context, accman *accounts.Manager, address string, i int, passwords []string) (accounts.Account, string) {
|
||||||
|
account, err := MakeAddress(accman, address)
|
||||||
|
if err != nil {
|
||||||
|
Fatalf("Could not list accounts: %v", err)
|
||||||
|
}
|
||||||
|
for trials := 0; trials < 3; trials++ {
|
||||||
|
prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3)
|
||||||
|
password := GetPassPhrase(prompt, false, i, passwords)
|
||||||
|
err = accman.Unlock(account, password)
|
||||||
|
if err == nil {
|
||||||
|
glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
|
||||||
|
return account, password
|
||||||
|
}
|
||||||
|
if err, ok := err.(*accounts.AmbiguousAddrError); ok {
|
||||||
|
glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
|
||||||
|
return AmbiguousAddrRecovery(accman, err, password), password
|
||||||
|
}
|
||||||
|
if err != accounts.ErrDecrypt {
|
||||||
|
// No need to prompt again if the error is not decryption-related.
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// All trials expended to unlock account, bail out
|
||||||
|
Fatalf("Failed to unlock account %s (%v)", address, err)
|
||||||
|
return accounts.Account{}, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// getPassPhrase retrieves the passwor associated with an account, either fetched
|
||||||
|
// from a list of preloaded passphrases, or requested interactively from the user.
|
||||||
|
func GetPassPhrase(prompt string, confirmation bool, i int, passwords []string) string {
|
||||||
|
// If a list of passwords was supplied, retrieve from them
|
||||||
|
if len(passwords) > 0 {
|
||||||
|
if i < len(passwords) {
|
||||||
|
return passwords[i]
|
||||||
|
}
|
||||||
|
return passwords[len(passwords)-1]
|
||||||
|
}
|
||||||
|
// Otherwise prompt the user for the password
|
||||||
|
if prompt != "" {
|
||||||
|
fmt.Println(prompt)
|
||||||
|
}
|
||||||
|
password, err := console.Stdin.PromptPassword("Passphrase: ")
|
||||||
|
if err != nil {
|
||||||
|
Fatalf("Failed to read passphrase: %v", err)
|
||||||
|
}
|
||||||
|
if confirmation {
|
||||||
|
confirm, err := console.Stdin.PromptPassword("Repeat passphrase: ")
|
||||||
|
if err != nil {
|
||||||
|
Fatalf("Failed to read passphrase confirmation: %v", err)
|
||||||
|
}
|
||||||
|
if password != confirm {
|
||||||
|
Fatalf("Passphrases do not match")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return password
|
||||||
|
}
|
||||||
|
|
||||||
|
func AmbiguousAddrRecovery(am *accounts.Manager, err *accounts.AmbiguousAddrError, auth string) accounts.Account {
|
||||||
|
fmt.Printf("Multiple key files exist for address %x:\n", err.Addr)
|
||||||
|
for _, a := range err.Matches {
|
||||||
|
fmt.Println(" ", a.File)
|
||||||
|
}
|
||||||
|
fmt.Println("Testing your passphrase against all of them...")
|
||||||
|
var match *accounts.Account
|
||||||
|
for _, a := range err.Matches {
|
||||||
|
if err := am.Unlock(a, auth); err == nil {
|
||||||
|
match = &a
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if match == nil {
|
||||||
|
Fatalf("None of the listed files could be unlocked.")
|
||||||
|
}
|
||||||
|
fmt.Printf("Your passphrase unlocked %s\n", match.File)
|
||||||
|
fmt.Println("In order to avoid this warning, you need to remove the following duplicate key files:")
|
||||||
|
for _, a := range err.Matches {
|
||||||
|
if a != *match {
|
||||||
|
fmt.Println(" ", a.File)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *match
|
||||||
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ func (self *Depo) HandleStoreRequestMsg(req *storeRequestMsgData, p *peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update chunk with size and data
|
// update chunk with size and data
|
||||||
chunk.SData = req.SData
|
chunk.SData = req.SData // protocol validates that SData is minimum 9 bytes long (int64 size + at least one byte of data)
|
||||||
chunk.Size = int64(binary.LittleEndian.Uint64(req.SData[0:8]))
|
chunk.Size = int64(binary.LittleEndian.Uint64(req.SData[0:8]))
|
||||||
glog.V(logger.Detail).Infof("[BZZ] delivery of %p from %v", chunk, p)
|
glog.V(logger.Detail).Infof("[BZZ] delivery of %p from %v", chunk, p)
|
||||||
chunk.Source = p
|
chunk.Source = p
|
||||||
|
|
@ -136,7 +136,7 @@ func (self *Depo) HandleRetrieveRequestMsg(req *retrieveRequestMsgData, p *peer)
|
||||||
|
|
||||||
// call storage.NetStore#Get which
|
// call storage.NetStore#Get which
|
||||||
// blocks until local retrieval finished
|
// blocks until local retrieval finished
|
||||||
// launches cloud retrieval in a separate go routine
|
// launches cloud retrieval
|
||||||
chunk, _ := self.netStore.Get(req.Key)
|
chunk, _ := self.netStore.Get(req.Key)
|
||||||
req = self.strategyUpdateRequest(chunk.Req, req)
|
req = self.strategyUpdateRequest(chunk.Req, req)
|
||||||
// check if we can immediately deliver
|
// check if we can immediately deliver
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,9 @@ func (self *bzz) handle() error {
|
||||||
if err := msg.Decode(&req); err != nil {
|
if err := msg.Decode(&req); err != nil {
|
||||||
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
|
return self.protoError(ErrDecode, "<- %v: %v", msg, err)
|
||||||
}
|
}
|
||||||
|
if len(req.SData) < 9 {
|
||||||
|
return self.protoError(ErrDecode, "<- %v: Data too short (%v)", msg)
|
||||||
|
}
|
||||||
glog.V(logger.Detail).Infof("[BZZ] incoming store request: %s", req.String())
|
glog.V(logger.Detail).Infof("[BZZ] incoming store request: %s", req.String())
|
||||||
// swap accounting is done within forwarding
|
// swap accounting is done within forwarding
|
||||||
self.storage.HandleStoreRequestMsg(&req, &peer{bzz: self})
|
self.storage.HandleStoreRequestMsg(&req, &peer{bzz: self})
|
||||||
|
|
|
||||||
23
swarm/services/ens/README.md
Normal file
23
swarm/services/ens/README.md
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Swarm ENS interface
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
The solidity source code can be found at [github.com/arachnid/ens/](https://github.com/arachnid/ens/).
|
||||||
|
|
||||||
|
The ABI and BIN files in the contract subdirectory were generated by
|
||||||
|
|
||||||
|
```shell
|
||||||
|
solc -o `pwd` --optimise --abi --bin OpenRegistrar.sol
|
||||||
|
solc -o `pwd` --optimise --abi --bin PersonalResolver.sol
|
||||||
|
```
|
||||||
|
|
||||||
|
using the .sol files in [revision 8b38b23a23100d5c325ae3fa24935f5ab93d61ba](https://github.com/Arachnid/ens/commit/8b38b23a23100d5c325ae3fa24935f5ab93d61ba)
|
||||||
|
with solc version 0.3.5-0/RelWithDebInfo-Linux/g++/Interpreter
|
||||||
|
|
||||||
|
The go bindings for ENS contracts are generated using `abigen` via the go generator:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
godep go generate ./swarm/services/ens
|
||||||
|
```
|
||||||
|
|
||||||
|
see the preprocessor directives in leading comments of ens.go and ens_test.go
|
||||||
1
swarm/services/ens/contract/OpenRegistrar.abi
Normal file
1
swarm/services/ens/contract/OpenRegistrar.abi
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"id","type":"bytes32"}],"name":"getExtended","outputs":[{"name":"data","type":"bytes"}],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"qtype","type":"bytes32"},{"name":"index","type":"uint16"}],"name":"resolve","outputs":[{"name":"rcode","type":"uint16"},{"name":"rtype","type":"bytes16"},{"name":"ttl","type":"uint32"},{"name":"len","type":"uint16"},{"name":"data","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"resolver","type":"address"},{"name":"nodeId","type":"bytes12"}],"name":"register","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"resolver","type":"address"},{"name":"nodeId","type":"bytes12"}],"name":"setResolver","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"label","type":"bytes32"}],"name":"getOwner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"label","type":"bytes32"}],"name":"findResolver","outputs":[{"name":"rcode","type":"uint16"},{"name":"ttl","type":"uint32"},{"name":"rnode","type":"bytes12"},{"name":"raddress","type":"address"}],"type":"function"}]
|
||||||
1
swarm/services/ens/contract/OpenRegistrar.bin
Normal file
1
swarm/services/ens/contract/OpenRegistrar.bin
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
60606040526103b1806100126000396000f3606060405236156100615760e060020a60003504635b0fc9c381146100635780638021061c14610085578063a16fdafa146100a2578063a1f8f8f0146100d5578063a9f2a1b2146100fa578063deb931a21461011f578063edc0277c14610145575b005b610061600435602435600081600160a060020a03166000141561028157610002565b6101956004356000606081905260a060405260809081525b919050565b610203600435602435604435600080808080600160a060020a0319881681146100ca57600394505b939792965093509350565b610061600435602435604435600082600160a060020a0316600014156102c157610002565b610061600435602435604435600082600160a060020a03166000141561033657610002565b610229600435600081815260208190526040902060010154600160a060020a031661009d565b6102466004356024356000818152602081905260408120819081908190600160a060020a031987168214158061018757506001810154600160a060020a031682145b1561038957600394506103a7565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b50505061ffff919091166060908152608082905260a082815260c083905260e092909252f35b60408051600160a060020a03929092168252519081900360200190f35b61ffff93909316606090815263ffffffff929092166080908152600160a060020a03199190911660a052600160a060020a039290921660c052f35b828152602081905260409020600181015433600160a060020a039081169116146102aa57610002565b6001018054600160a060020a031916909117905550565b83815260208190526040812060018101549091600160a060020a03909116146102e957610002565b60018101805460c0604052606085905260808490523360a08190528354600160a060020a03199081168717600160a060020a031660a060020a808804021785559190911617905550505050565b838152602081905260409020600181015433600160a060020a0390811691161461035f57610002565b8054600160a060020a031916909217600160a060020a031660a060020a9182900490910217905550565b8054610e10945060a060020a808204029350600160a060020a031691505b509295919450925056
|
||||||
366
swarm/services/ens/contract/OpenRegistrar.go
Normal file
366
swarm/services/ens/contract/OpenRegistrar.go
Normal file
|
|
@ -0,0 +1,366 @@
|
||||||
|
// This file is an automatically generated Go binding. Do not modify as any
|
||||||
|
// change will likely be lost upon the next re-generation!
|
||||||
|
|
||||||
|
package contract
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OpenRegistrarABI is the input ABI used to generate the binding from.
|
||||||
|
const OpenRegistrarABI = `[{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"id","type":"bytes32"}],"name":"getExtended","outputs":[{"name":"data","type":"bytes"}],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"qtype","type":"bytes32"},{"name":"index","type":"uint16"}],"name":"resolve","outputs":[{"name":"rcode","type":"uint16"},{"name":"rtype","type":"bytes16"},{"name":"ttl","type":"uint32"},{"name":"len","type":"uint16"},{"name":"data","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"resolver","type":"address"},{"name":"nodeId","type":"bytes12"}],"name":"register","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"label","type":"bytes32"},{"name":"resolver","type":"address"},{"name":"nodeId","type":"bytes12"}],"name":"setResolver","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"label","type":"bytes32"}],"name":"getOwner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"label","type":"bytes32"}],"name":"findResolver","outputs":[{"name":"rcode","type":"uint16"},{"name":"ttl","type":"uint32"},{"name":"rnode","type":"bytes12"},{"name":"raddress","type":"address"}],"type":"function"}]`
|
||||||
|
|
||||||
|
// OpenRegistrarBin is the compiled bytecode used for deploying new contracts.
|
||||||
|
const OpenRegistrarBin = `606060405261083b806100126000396000f36060604052361561007f576000357c0100000000000000000000000000000000000000000000000000000000900480635b0fc9c3146100815780638021061c146100a2578063a16fdafa14610126578063a1f8f8f0146101a5578063a9f2a1b2146101cf578063deb931a2146101f9578063edc0277c1461023b5761007f565b005b6100a060048080359060200190919080359060200190919050506102bc565b005b6100b86004808035906020019091905050610392565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156101185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61014e60048080359060200190919080359060200190919080359060200190919050506103c6565b604051808661ffff168152602001856fffffffffffffffffffffffffffffffff191681526020018463ffffffff1681526020018361ffff168152602001826000191681526020019550505050505060405180910390f35b6101cd600480803590602001909190803590602001909190803590602001909190505061041f565b005b6101f760048080359060200190919080359060200190919080359060200190919050506105ac565b005b61020f60048080359060200190919050506106c0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61025a600480803590602001909190803590602001909190505061070f565b604051808561ffff1681526020018463ffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff191681526020018273ffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405180910390f35b600060008273ffffffffffffffffffffffffffffffffffffffff1614156102e257610002565b600060005060008460001916815260200190815260200160002060005090503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561035f57610002565b818160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b505050565b6020604051908101604052806000815260200150602060405190810160405280600081526020015090506103c1565b919050565b60006000600060006000600074010000000000000000000000000000000000000000028873ffffffffffffffffffffffffffffffffffffffff191614151561041357600394508450610414565b5b939792965093509350565b600060008373ffffffffffffffffffffffffffffffffffffffff16141561044557610002565b60006000506000856000191681526020019081526020016000206000509050600073ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156104c357610002565b60606040519081016040528084815260200183815260200133815260200150600060005060008660001916815260200190815260200160002060005060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff0219169083021790555060208201518160000160146101000a8154816bffffffffffffffffffffffff0219169083740100000000000000000000000000000000000000009004021790555060408201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055509050505b50505050565b600060008373ffffffffffffffffffffffffffffffffffffffff1614156105d257610002565b600060005060008560001916815260200190815260200160002060005090503373ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561064f57610002565b828160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550818160000160146101000a8154816bffffffffffffffffffffffff021916908374010000000000000000000000000000000000000000900402179055505b50505050565b6000600060005060008360001916815260200190815260200160002060005060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061070a565b919050565b6000600060006000600060006000506000876000191681526020019081526020016000206000509050600074010000000000000000000000000000000000000000028773ffffffffffffffffffffffffffffffffffffffff19161415806107c65750600073ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156107d657600394508450610831565b610e10935083508060000160149054906101000a90047401000000000000000000000000000000000000000002925082508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915081505b509295919450925056`
|
||||||
|
|
||||||
|
// DeployOpenRegistrar deploys a new Ethereum contract, binding an instance of OpenRegistrar to it.
|
||||||
|
func DeployOpenRegistrar(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *OpenRegistrar, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(OpenRegistrarABI))
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(OpenRegistrarBin), backend)
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
return address, tx, &OpenRegistrar{OpenRegistrarCaller: OpenRegistrarCaller{contract: contract}, OpenRegistrarTransactor: OpenRegistrarTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrar is an auto generated Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrar struct {
|
||||||
|
OpenRegistrarCaller // Read-only binding to the contract
|
||||||
|
OpenRegistrarTransactor // Write-only binding to the contract
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrarCaller struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrarTransactor struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarSession is an auto generated Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call and transact options.
|
||||||
|
type OpenRegistrarSession struct {
|
||||||
|
Contract *OpenRegistrar // 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call options.
|
||||||
|
type OpenRegistrarCallerSession struct {
|
||||||
|
Contract *OpenRegistrarCaller // Generic contract caller binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set transact options.
|
||||||
|
type OpenRegistrarTransactorSession struct {
|
||||||
|
Contract *OpenRegistrarTransactor // Generic contract transactor binding to set the session for
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrarRaw struct {
|
||||||
|
Contract *OpenRegistrar // Generic contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrarCallerRaw struct {
|
||||||
|
Contract *OpenRegistrarCaller // Generic read-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenRegistrarTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||||
|
type OpenRegistrarTransactorRaw struct {
|
||||||
|
Contract *OpenRegistrarTransactor // Generic write-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOpenRegistrar creates a new instance of OpenRegistrar, bound to a specific deployed contract.
|
||||||
|
func NewOpenRegistrar(address common.Address, backend bind.ContractBackend) (*OpenRegistrar, error) {
|
||||||
|
contract, err := bindOpenRegistrar(address, backend.(bind.ContractCaller), backend.(bind.ContractTransactor))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &OpenRegistrar{OpenRegistrarCaller: OpenRegistrarCaller{contract: contract}, OpenRegistrarTransactor: OpenRegistrarTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOpenRegistrarCaller creates a new read-only instance of OpenRegistrar, bound to a specific deployed contract.
|
||||||
|
func NewOpenRegistrarCaller(address common.Address, caller bind.ContractCaller) (*OpenRegistrarCaller, error) {
|
||||||
|
contract, err := bindOpenRegistrar(address, caller, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &OpenRegistrarCaller{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOpenRegistrarTransactor creates a new write-only instance of OpenRegistrar, bound to a specific deployed contract.
|
||||||
|
func NewOpenRegistrarTransactor(address common.Address, transactor bind.ContractTransactor) (*OpenRegistrarTransactor, error) {
|
||||||
|
contract, err := bindOpenRegistrar(address, nil, transactor)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &OpenRegistrarTransactor{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindOpenRegistrar binds a generic wrapper to an already deployed contract.
|
||||||
|
func bindOpenRegistrar(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(OpenRegistrarABI))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bind.NewBoundContract(address, parsed, caller, transactor), 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 (_OpenRegistrar *OpenRegistrarRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _OpenRegistrar.Contract.OpenRegistrarCaller.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 (_OpenRegistrar *OpenRegistrarRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.OpenRegistrarTransactor.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_OpenRegistrar *OpenRegistrarRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.OpenRegistrarTransactor.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 (_OpenRegistrar *OpenRegistrarCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _OpenRegistrar.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 (_OpenRegistrar *OpenRegistrarTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindResolver is a free data retrieval call binding the contract method 0xedc0277c.
|
||||||
|
//
|
||||||
|
// Solidity: function findResolver(nodeId bytes12, label bytes32) constant returns(rcode uint16, ttl uint32, rnode bytes12, raddress address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCaller) FindResolver(opts *bind.CallOpts, nodeId [12]byte, label [32]byte) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Ttl uint32
|
||||||
|
Rnode [12]byte
|
||||||
|
Raddress common.Address
|
||||||
|
}, error) {
|
||||||
|
ret := new(struct {
|
||||||
|
Rcode uint16
|
||||||
|
Ttl uint32
|
||||||
|
Rnode [12]byte
|
||||||
|
Raddress common.Address
|
||||||
|
})
|
||||||
|
out := ret
|
||||||
|
err := _OpenRegistrar.contract.Call(opts, out, "findResolver", nodeId, label)
|
||||||
|
return *ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindResolver is a free data retrieval call binding the contract method 0xedc0277c.
|
||||||
|
//
|
||||||
|
// Solidity: function findResolver(nodeId bytes12, label bytes32) constant returns(rcode uint16, ttl uint32, rnode bytes12, raddress address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) FindResolver(nodeId [12]byte, label [32]byte) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Ttl uint32
|
||||||
|
Rnode [12]byte
|
||||||
|
Raddress common.Address
|
||||||
|
}, error) {
|
||||||
|
return _OpenRegistrar.Contract.FindResolver(&_OpenRegistrar.CallOpts, nodeId, label)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindResolver is a free data retrieval call binding the contract method 0xedc0277c.
|
||||||
|
//
|
||||||
|
// Solidity: function findResolver(nodeId bytes12, label bytes32) constant returns(rcode uint16, ttl uint32, rnode bytes12, raddress address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCallerSession) FindResolver(nodeId [12]byte, label [32]byte) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Ttl uint32
|
||||||
|
Rnode [12]byte
|
||||||
|
Raddress common.Address
|
||||||
|
}, error) {
|
||||||
|
return _OpenRegistrar.Contract.FindResolver(&_OpenRegistrar.CallOpts, nodeId, label)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExtended is a free data retrieval call binding the contract method 0x8021061c.
|
||||||
|
//
|
||||||
|
// Solidity: function getExtended(id bytes32) constant returns(data bytes)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCaller) GetExtended(opts *bind.CallOpts, id [32]byte) ([]byte, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new([]byte)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _OpenRegistrar.contract.Call(opts, out, "getExtended", id)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExtended is a free data retrieval call binding the contract method 0x8021061c.
|
||||||
|
//
|
||||||
|
// Solidity: function getExtended(id bytes32) constant returns(data bytes)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) GetExtended(id [32]byte) ([]byte, error) {
|
||||||
|
return _OpenRegistrar.Contract.GetExtended(&_OpenRegistrar.CallOpts, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExtended is a free data retrieval call binding the contract method 0x8021061c.
|
||||||
|
//
|
||||||
|
// Solidity: function getExtended(id bytes32) constant returns(data bytes)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCallerSession) GetExtended(id [32]byte) ([]byte, error) {
|
||||||
|
return _OpenRegistrar.Contract.GetExtended(&_OpenRegistrar.CallOpts, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOwner is a free data retrieval call binding the contract method 0xdeb931a2.
|
||||||
|
//
|
||||||
|
// Solidity: function getOwner(label bytes32) constant returns(address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCaller) GetOwner(opts *bind.CallOpts, label [32]byte) (common.Address, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(common.Address)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _OpenRegistrar.contract.Call(opts, out, "getOwner", label)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOwner is a free data retrieval call binding the contract method 0xdeb931a2.
|
||||||
|
//
|
||||||
|
// Solidity: function getOwner(label bytes32) constant returns(address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) GetOwner(label [32]byte) (common.Address, error) {
|
||||||
|
return _OpenRegistrar.Contract.GetOwner(&_OpenRegistrar.CallOpts, label)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOwner is a free data retrieval call binding the contract method 0xdeb931a2.
|
||||||
|
//
|
||||||
|
// Solidity: function getOwner(label bytes32) constant returns(address)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCallerSession) GetOwner(label [32]byte) (common.Address, error) {
|
||||||
|
return _OpenRegistrar.Contract.GetOwner(&_OpenRegistrar.CallOpts, label)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve is a free data retrieval call binding the contract method 0xa16fdafa.
|
||||||
|
//
|
||||||
|
// Solidity: function resolve(nodeId bytes12, qtype bytes32, index uint16) constant returns(rcode uint16, rtype bytes16, ttl uint32, len uint16, data bytes32)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCaller) Resolve(opts *bind.CallOpts, nodeId [12]byte, qtype [32]byte, index uint16) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Rtype [16]byte
|
||||||
|
Ttl uint32
|
||||||
|
Len uint16
|
||||||
|
Data [32]byte
|
||||||
|
}, error) {
|
||||||
|
ret := new(struct {
|
||||||
|
Rcode uint16
|
||||||
|
Rtype [16]byte
|
||||||
|
Ttl uint32
|
||||||
|
Len uint16
|
||||||
|
Data [32]byte
|
||||||
|
})
|
||||||
|
out := ret
|
||||||
|
err := _OpenRegistrar.contract.Call(opts, out, "resolve", nodeId, qtype, index)
|
||||||
|
return *ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve is a free data retrieval call binding the contract method 0xa16fdafa.
|
||||||
|
//
|
||||||
|
// Solidity: function resolve(nodeId bytes12, qtype bytes32, index uint16) constant returns(rcode uint16, rtype bytes16, ttl uint32, len uint16, data bytes32)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) Resolve(nodeId [12]byte, qtype [32]byte, index uint16) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Rtype [16]byte
|
||||||
|
Ttl uint32
|
||||||
|
Len uint16
|
||||||
|
Data [32]byte
|
||||||
|
}, error) {
|
||||||
|
return _OpenRegistrar.Contract.Resolve(&_OpenRegistrar.CallOpts, nodeId, qtype, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve is a free data retrieval call binding the contract method 0xa16fdafa.
|
||||||
|
//
|
||||||
|
// Solidity: function resolve(nodeId bytes12, qtype bytes32, index uint16) constant returns(rcode uint16, rtype bytes16, ttl uint32, len uint16, data bytes32)
|
||||||
|
func (_OpenRegistrar *OpenRegistrarCallerSession) Resolve(nodeId [12]byte, qtype [32]byte, index uint16) (struct {
|
||||||
|
Rcode uint16
|
||||||
|
Rtype [16]byte
|
||||||
|
Ttl uint32
|
||||||
|
Len uint16
|
||||||
|
Data [32]byte
|
||||||
|
}, error) {
|
||||||
|
return _OpenRegistrar.Contract.Resolve(&_OpenRegistrar.CallOpts, nodeId, qtype, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register is a paid mutator transaction binding the contract method 0xa1f8f8f0.
|
||||||
|
//
|
||||||
|
// Solidity: function register(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactor) Register(opts *bind.TransactOpts, label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.contract.Transact(opts, "register", label, resolver, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register is a paid mutator transaction binding the contract method 0xa1f8f8f0.
|
||||||
|
//
|
||||||
|
// Solidity: function register(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) Register(label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.Register(&_OpenRegistrar.TransactOpts, label, resolver, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register is a paid mutator transaction binding the contract method 0xa1f8f8f0.
|
||||||
|
//
|
||||||
|
// Solidity: function register(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactorSession) Register(label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.Register(&_OpenRegistrar.TransactOpts, label, resolver, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(label bytes32, newOwner address) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactor) SetOwner(opts *bind.TransactOpts, label [32]byte, newOwner common.Address) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.contract.Transact(opts, "setOwner", label, newOwner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(label bytes32, newOwner address) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) SetOwner(label [32]byte, newOwner common.Address) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.SetOwner(&_OpenRegistrar.TransactOpts, label, newOwner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(label bytes32, newOwner address) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactorSession) SetOwner(label [32]byte, newOwner common.Address) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.SetOwner(&_OpenRegistrar.TransactOpts, label, newOwner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0xa9f2a1b2.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactor) SetResolver(opts *bind.TransactOpts, label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.contract.Transact(opts, "setResolver", label, resolver, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0xa9f2a1b2.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarSession) SetResolver(label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.SetResolver(&_OpenRegistrar.TransactOpts, label, resolver, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0xa9f2a1b2.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(label bytes32, resolver address, nodeId bytes12) returns()
|
||||||
|
func (_OpenRegistrar *OpenRegistrarTransactorSession) SetResolver(label [32]byte, resolver common.Address, nodeId [12]byte) (*types.Transaction, error) {
|
||||||
|
return _OpenRegistrar.Contract.SetResolver(&_OpenRegistrar.TransactOpts, label, resolver, nodeId)
|
||||||
|
}
|
||||||
1
swarm/services/ens/contract/PersonalResolver.abi
Normal file
1
swarm/services/ens/contract/PersonalResolver.abi
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"rootNodeId","type":"bytes12"},{"name":"name","type":"bytes32[]"}],"name":"deletePrivateRR","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"isPersonalResolver","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"id","type":"bytes32"}],"name":"getExtended","outputs":[{"name":"data","type":"bytes"}],"type":"function"},{"constant":false,"inputs":[{"name":"rootNodeId","type":"bytes12"},{"name":"name","type":"string"},{"name":"rtype","type":"bytes16"},{"name":"ttl","type":"uint32"},{"name":"len","type":"uint16"},{"name":"data","type":"bytes32"}],"name":"setRR","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"rootNodeId","type":"bytes12"},{"name":"name","type":"bytes32[]"},{"name":"rtype","type":"bytes16"},{"name":"ttl","type":"uint32"},{"name":"len","type":"uint16"},{"name":"data","type":"bytes32"}],"name":"setPrivateRR","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"qtype","type":"bytes32"},{"name":"index","type":"uint16"}],"name":"resolve","outputs":[{"name":"rcode","type":"uint16"},{"name":"rtype","type":"bytes16"},{"name":"ttl","type":"uint32"},{"name":"len","type":"uint16"},{"name":"data","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"rootNodeId","type":"bytes12"},{"name":"name","type":"string"}],"name":"deleteRR","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"nodeId","type":"bytes12"},{"name":"label","type":"bytes32"}],"name":"findResolver","outputs":[{"name":"rcode","type":"uint16"},{"name":"ttl","type":"uint32"},{"name":"rnode","type":"bytes12"},{"name":"raddress","type":"address"}],"type":"function"},{"inputs":[],"type":"constructor"}]
|
||||||
1
swarm/services/ens/contract/PersonalResolver.bin
Normal file
1
swarm/services/ens/contract/PersonalResolver.bin
Normal file
File diff suppressed because one or more lines are too long
434
swarm/services/ens/contract/PersonalResolver.go
Normal file
434
swarm/services/ens/contract/PersonalResolver.go
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -3,7 +3,6 @@ package ens
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
|
@ -14,7 +13,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var domainAndVersion = regexp.MustCompile("[@:;,]+")
|
|
||||||
var qtypeChash = [32]byte{ 0x43, 0x48, 0x41, 0x53, 0x48}
|
var qtypeChash = [32]byte{ 0x43, 0x48, 0x41, 0x53, 0x48}
|
||||||
var rtypeChash = [16]byte{ 0x43, 0x48, 0x41, 0x53, 0x48}
|
var rtypeChash = [16]byte{ 0x43, 0x48, 0x41, 0x53, 0x48}
|
||||||
|
|
||||||
|
|
@ -46,13 +44,8 @@ func (self *ENS) newResolver(contractAddr common.Address) (*contract.ResolverSes
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve is a non-tranasctional call, returns hash as storage.Key
|
// resolve is a non-tranasctional call, returns hash as storage.Key
|
||||||
func (self *ENS) Resolve(hostPort string) (storage.Key, error) {
|
func (self *ENS) Resolve(name string) (storage.Key, error) {
|
||||||
host := hostPort
|
return self.resolveName(self.rootAddress, name)
|
||||||
parts := domainAndVersion.Split(host, 3)
|
|
||||||
if len(parts) > 1 && parts[1] != "" {
|
|
||||||
host = parts[0]
|
|
||||||
}
|
|
||||||
return self.resolveName(self.rootAddress, host)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ENS) nextResolver(resolver *contract.ResolverSession, nodeId [12]byte, label string) (*contract.ResolverSession, [12]byte, error) {
|
func (self *ENS) nextResolver(resolver *contract.ResolverSession, nodeId [12]byte, label string) (*contract.ResolverSession, [12]byte, error) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//go:generate abigen --abi contract/OpenRegistrar.abi --bin contract/OpenRegistrar.bin --pkg contract --type OpenRegistrar --out contract/OpenRegistrar.go
|
||||||
|
//go:generate abigen --abi contract/PersonalResolver.abi --bin contract/PersonalResolver.bin --pkg contract --type PersonalResolver --out contract/PersonalResolver.go
|
||||||
package ens
|
package ens
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -10,15 +12,9 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/logger/glog"
|
|
||||||
"github.com/ethereum/go-ethereum/swarm/services/ens/contract"
|
"github.com/ethereum/go-ethereum/swarm/services/ens/contract"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
glog.SetV(6)
|
|
||||||
glog.SetToStderr(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
name = "my name on ENS"
|
name = "my name on ENS"
|
||||||
|
|
@ -26,10 +22,21 @@ var (
|
||||||
addr = crypto.PubkeyToAddress(key.PublicKey)
|
addr = crypto.PubkeyToAddress(key.PublicKey)
|
||||||
)
|
)
|
||||||
|
|
||||||
func deploy(prvKey *ecdsa.PrivateKey, amount *big.Int, backend *backends.SimulatedBackend) (common.Address, error) {
|
func deployRegistrar(prvKey *ecdsa.PrivateKey, amount *big.Int, backend *backends.SimulatedBackend) (common.Address, error) {
|
||||||
deployTransactor := bind.NewKeyedTransactor(prvKey)
|
deployTransactor := bind.NewKeyedTransactor(prvKey)
|
||||||
deployTransactor.Value = amount
|
deployTransactor.Value = amount
|
||||||
addr, _, _, err := contract.DeployResolver(deployTransactor, backend)
|
addr, _, _, err := contract.DeployOpenRegistrar(deployTransactor, backend)
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, err
|
||||||
|
}
|
||||||
|
backend.Commit()
|
||||||
|
return addr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func deployResolver(prvKey *ecdsa.PrivateKey, amount *big.Int, backend *backends.SimulatedBackend) (common.Address, error) {
|
||||||
|
deployTransactor := bind.NewKeyedTransactor(prvKey)
|
||||||
|
deployTransactor.Value = amount
|
||||||
|
addr, _, _, err := contract.DeployPersonalResolver(deployTransactor, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, err
|
return common.Address{}, err
|
||||||
}
|
}
|
||||||
|
|
@ -40,12 +47,12 @@ func deploy(prvKey *ecdsa.PrivateKey, amount *big.Int, backend *backends.Simulat
|
||||||
func TestENS(t *testing.T) {
|
func TestENS(t *testing.T) {
|
||||||
contractBackend := backends.NewSimulatedBackend(core.GenesisAccount{addr, big.NewInt(1000000000)})
|
contractBackend := backends.NewSimulatedBackend(core.GenesisAccount{addr, big.NewInt(1000000000)})
|
||||||
transactOpts := bind.NewKeyedTransactor(key)
|
transactOpts := bind.NewKeyedTransactor(key)
|
||||||
contractAddr, err := deploy(key, big.NewInt(0), contractBackend)
|
contractAddr, err := deployRegistrar(key, big.NewInt(0), contractBackend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolverAddr, err := deploy(key, big.NewInt(0), contractBackend)
|
resolverAddr, err := deployResolver(key, big.NewInt(0), contractBackend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +76,6 @@ func TestENS(t *testing.T) {
|
||||||
}
|
}
|
||||||
if vhost.Hex() != hash.Hex()[2:] {
|
if vhost.Hex() != hash.Hex()[2:] {
|
||||||
t.Fatalf("resolve error, expected %v, got %v", hash.Hex(), vhost)
|
t.Fatalf("resolve error, expected %v, got %v", hash.Hex(), vhost)
|
||||||
// t.Fatalf("resolve error, expected %v, got %v", transactOpts.From, hash)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue