2014-08-05 09:10:24 +00:00
|
|
|
package ethpipe
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/eth-go/ethstate"
|
|
|
|
"github.com/ethereum/eth-go/ethutil"
|
|
|
|
)
|
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
type Object struct {
|
2014-08-05 09:10:24 +00:00
|
|
|
*ethstate.StateObject
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
func (self *Object) StorageString(str string) *ethutil.Value {
|
2014-08-05 09:10:24 +00:00
|
|
|
if ethutil.IsHex(str) {
|
|
|
|
return self.Storage(ethutil.Hex2Bytes(str[2:]))
|
|
|
|
} else {
|
|
|
|
return self.Storage(ethutil.RightPadBytes([]byte(str), 32))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
func (self *Object) StorageValue(addr *ethutil.Value) *ethutil.Value {
|
2014-08-05 09:10:24 +00:00
|
|
|
return self.Storage(addr.Bytes())
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:26:12 +00:00
|
|
|
func (self *Object) Storage(addr []byte) *ethutil.Value {
|
2014-08-05 09:10:24 +00:00
|
|
|
return self.StateObject.GetStorage(ethutil.BigD(addr))
|
|
|
|
}
|