diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-31 23:02:55 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-04-20 03:57:48 +0800 |
commit | 3a540425a3d7fc29233b5cd3e7b79b4866f35d57 (patch) | |
tree | d1e101d7dcf79d362d087d431f5c4cefafbd30fd /common/natspec/natspec.go | |
parent | 5b0ea1044ab7c14e11489bc6c612bb7f2e5a023e (diff) | |
download | go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar.gz go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar.bz2 go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar.lz go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar.xz go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.tar.zst go-tangerine-3a540425a3d7fc29233b5cd3e7b79b4866f35d57.zip |
reorg:
- statereg methods move to natspec/resolver/docserver
- fix failing test on invalid js input
Diffstat (limited to 'common/natspec/natspec.go')
-rw-r--r-- | common/natspec/natspec.go | 36 |
1 files changed, 21 insertions, 15 deletions
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 |