Changed getters on account objects. Closes #610
* GetCode * GetNonce * GetStorage * GetBalance
This commit is contained in:
parent
344b3556eb
commit
4391c38215
@ -95,10 +95,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
state := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address)
|
*reply = api.xethAtStateNum(args.BlockNumber).StorageAt(args.Address, args.Key)
|
||||||
value := state.StorageString(args.Key)
|
|
||||||
|
|
||||||
*reply = common.ToHex(value.Bytes())
|
|
||||||
case "eth_getTransactionCount":
|
case "eth_getTransactionCount":
|
||||||
args := new(GetTxCountArgs)
|
args := new(GetTxCountArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
|
10
xeth/xeth.go
10
xeth/xeth.go
@ -308,21 +308,19 @@ func (self *XEth) NumberToHuman(balance string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) StorageAt(addr, storageAddr string) string {
|
func (self *XEth) StorageAt(addr, storageAddr string) string {
|
||||||
storage := self.State().SafeGet(addr).StorageString(storageAddr)
|
return common.ToHex(self.State().state.GetState(common.HexToAddress(addr), common.HexToHash(storageAddr)))
|
||||||
|
|
||||||
return common.ToHex(storage.Bytes())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) BalanceAt(addr string) string {
|
func (self *XEth) BalanceAt(addr string) string {
|
||||||
return self.State().SafeGet(addr).Balance().String()
|
return self.State().state.GetBalance(common.HexToAddress(addr)).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) TxCountAt(address string) int {
|
func (self *XEth) TxCountAt(address string) int {
|
||||||
return int(self.State().SafeGet(address).Nonce())
|
return int(self.State().state.GetNonce(common.HexToAddress(address)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) CodeAt(address string) string {
|
func (self *XEth) CodeAt(address string) string {
|
||||||
return common.ToHex(self.State().SafeGet(address).Code())
|
return common.ToHex(self.State().state.GetCode(common.HexToAddress(address)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *XEth) IsContract(address string) bool {
|
func (self *XEth) IsContract(address string) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user