More dapp samples

* Info DApp, coin DApp
* Additional rpc methods
This commit is contained in:
obscuren
2015-01-29 20:39:26 +01:00
parent 6488a392a3
commit 0031f388ac
7 changed files with 351 additions and 41 deletions

View File

@ -35,20 +35,31 @@ func NewObject(state *state.StateObject) *Object {
func (self *Object) StorageString(str string) *ethutil.Value {
if ethutil.IsHex(str) {
return self.Storage(ethutil.Hex2Bytes(str[2:]))
return self.storage(ethutil.Hex2Bytes(str[2:]))
} else {
return self.Storage(ethutil.RightPadBytes([]byte(str), 32))
return self.storage(ethutil.RightPadBytes([]byte(str), 32))
}
}
func (self *Object) StorageValue(addr *ethutil.Value) *ethutil.Value {
return self.Storage(addr.Bytes())
return self.storage(addr.Bytes())
}
func (self *Object) Storage(addr []byte) *ethutil.Value {
func (self *Object) storage(addr []byte) *ethutil.Value {
return self.StateObject.GetStorage(ethutil.BigD(addr))
}
func (self *Object) Storage() (storage map[string]string) {
storage = make(map[string]string)
it := self.StateObject.Trie().Iterator()
for it.Next() {
storage[toHex(it.Key)] = toHex(it.Value)
}
return
}
// Block interface exposed to QML
type Block struct {
//Transactions string `json:"transactions"`

View File

@ -11,7 +11,7 @@ func NewState(xeth *XEth) *State {
}
func (self *State) State() *state.StateDB {
return self.xeth.chainManager.State()
return self.xeth.chainManager.TransState()
}
func (self *State) Get(addr string) *Object {