aboutsummaryrefslogtreecommitdiffstats
path: root/common/natspec/natspec.go
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-04-08 18:35:02 +0800
committerzelig <viktor.tron@gmail.com>2015-04-20 03:57:49 +0800
commitb46e15217131e4ebe64e1ee55594c3ab0620395c (patch)
tree1a732f7461c606db75e204dc46f08aefd313888d /common/natspec/natspec.go
parent8e6a068d2d5b6374e0a8588a34a96a26562bae83 (diff)
downloadgo-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar.gz
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar.bz2
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar.lz
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar.xz
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.tar.zst
go-tangerine-b46e15217131e4ebe64e1ee55594c3ab0620395c.zip
default fallback NatSpec messages
Diffstat (limited to 'common/natspec/natspec.go')
-rw-r--r--common/natspec/natspec.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/common/natspec/natspec.go b/common/natspec/natspec.go
index 0253ebd81..ceac3f5d3 100644
--- a/common/natspec/natspec.go
+++ b/common/natspec/natspec.go
@@ -24,6 +24,33 @@ type NatSpec struct {
// abiDoc abiDoc
}
+func getFallbackNotice(comment, tx string) string {
+
+ return "About to submit transaction (" + comment + "): " + tx
+
+}
+
+func GetNotice(xeth *xeth.XEth, tx string, http *docserver.DocServer) (notice string) {
+
+ ns, err := New(xeth, tx, http)
+ if err != nil {
+ if ns == nil {
+ return getFallbackNotice("no NatSpec info found for contract", tx)
+ } else {
+ return getFallbackNotice("invalid NatSpec info", tx)
+ }
+ }
+
+ notice, err2 := ns.Notice()
+
+ if err2 != nil {
+ return getFallbackNotice("couldn't create NatSpec notice", tx)
+ }
+
+ return
+
+}
+
func New(xeth *xeth.XEth, tx string, http *docserver.DocServer) (self *NatSpec, err error) {
// extract contract address from tx
@@ -46,7 +73,7 @@ func New(xeth *xeth.XEth, tx string, http *docserver.DocServer) (self *NatSpec,
return
}
codehex := xeth.CodeAt(contractAddress)
- codeHash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex)))
+ codeHash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex[2:])))
// parse out host/domain
// set up nameresolver with natspecreg + urlhint contract addresses