From 3a540425a3d7fc29233b5cd3e7b79b4866f35d57 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 31 Mar 2015 16:02:55 +0100 Subject: reorg: - statereg methods move to natspec/resolver/docserver - fix failing test on invalid js input --- common/natspec/natspec.go | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'common/natspec/natspec.go') diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go index 883e27ef3..a9ac2d1b2 100644 --- a/common/natspec/natspec.go +++ b/common/natspec/natspec.go @@ -8,6 +8,8 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/docserver" + "github.com/ethereum/go-ethereum/common/resolver" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/xeth" ) @@ -22,8 +24,7 @@ type NatSpec struct { // abiDoc abiDoc } -// TODO: should initialise with abi and userdoc jsons -func New(xeth *xeth.XEth, tx string) (self *NatSpec, err error) { +func New(xeth *xeth.XEth, tx string, http *docserver.DocServer) (self *NatSpec, err error) { // extract contract address from tx @@ -45,21 +46,26 @@ func New(xeth *xeth.XEth, tx string) (self *NatSpec, err error) { return } codeHash := xeth.CodeAt(contractAddress) - - // retrieve natspec info content hash - - statereg := NewStateReg(xeth) - - natspecHash, err1 := statereg.GetNatSpec(codeHash) - if err1 != nil { - return nil, err1 + // parse out host/domain + + // set up nameresolver with natspecreg + urlhint contract addresses + stateReg := NewStateReg(xeth) + res := resolver.New( + xeth, + stateReg.caNatSpec, + stateReg.caURL, + ) + + // resolve host via nameReg/UrlHint Resolver + uri, hash, err := res.NameToUrl(codeHash) + if err != nil { + return } - // retrieve content - - content, err2 := statereg.GetContent(natspecHash) - if err2 != nil { - return nil, err2 + // get content via http client and authenticate content using hash + content, err := http.GetAuthContent(uri, hash) + if err != nil { + return } // get abi, userdoc -- cgit