diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-22 20:51:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-22 20:51:21 +0800 |
commit | 65a802c6787184951753ba2f79fdf60dce526721 (patch) | |
tree | dcb344f23469197f4b26705495e17625d99917d9 /ethpipe/js_pipe.go | |
parent | 151f9c7f8214a2702a76f36f566b52266949ac89 (diff) | |
download | dexon-65a802c6787184951753ba2f79fdf60dce526721.tar dexon-65a802c6787184951753ba2f79fdf60dce526721.tar.gz dexon-65a802c6787184951753ba2f79fdf60dce526721.tar.bz2 dexon-65a802c6787184951753ba2f79fdf60dce526721.tar.lz dexon-65a802c6787184951753ba2f79fdf60dce526721.tar.xz dexon-65a802c6787184951753ba2f79fdf60dce526721.tar.zst dexon-65a802c6787184951753ba2f79fdf60dce526721.zip |
Re-wrote Call and Execute to use the new vm messages
Diffstat (limited to 'ethpipe/js_pipe.go')
-rw-r--r-- | ethpipe/js_pipe.go | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/ethpipe/js_pipe.go b/ethpipe/js_pipe.go index 32212b26a..96990b671 100644 --- a/ethpipe/js_pipe.go +++ b/ethpipe/js_pipe.go @@ -85,10 +85,6 @@ func (self *JSPipe) CoinBase() string { return ethutil.Bytes2Hex(self.obj.KeyManager().Address()) } -func (self *JSPipe) BalanceAt(addr string) string { - return self.World().SafeGet(ethutil.Hex2Bytes(addr)).Balance.String() -} - func (self *JSPipe) NumberToHuman(balance string) string { b := ethutil.Big(balance) @@ -101,10 +97,18 @@ func (self *JSPipe) StorageAt(addr, storageAddr string) string { return ethutil.Bytes2Hex(storage.Bytes()) } +func (self *JSPipe) BalanceAt(addr string) string { + return self.World().SafeGet(ethutil.Hex2Bytes(addr)).Balance.String() +} + func (self *JSPipe) TxCountAt(address string) int { return int(self.World().SafeGet(ethutil.Hex2Bytes(address)).Nonce) } +func (self *JSPipe) CodeAt(address string) string { + return ethutil.Bytes2Hex(self.World().SafeGet(ethutil.Hex2Bytes(address)).Code) +} + func (self *JSPipe) IsContract(address string) bool { return len(self.World().SafeGet(ethutil.Hex2Bytes(address)).Code) > 0 } @@ -118,6 +122,18 @@ func (self *JSPipe) SecretToAddress(key string) string { return ethutil.Bytes2Hex(pair.Address()) } +func (self *JSPipe) Execute(addr, value, gas, price, data string) (string, error) { + ret, err := self.ExecuteObject(&Object{ + self.World().safeGet(ethutil.Hex2Bytes(addr))}, + ethutil.Hex2Bytes(data), + ethutil.NewValue(value), + ethutil.NewValue(gas), + ethutil.NewValue(price), + ) + + return ethutil.Bytes2Hex(ret), err +} + type KeyVal struct { Key string `json:"key"` Value string `json:"value"` @@ -224,9 +240,9 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr } func (self *JSPipe) PushTx(txStr string) (*JSReceipt, error) { - tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr)) - self.obj.TxPool().QueueTransaction(tx) - return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(), tx.Hash(), tx.Sender()), nil + tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr)) + self.obj.TxPool().QueueTransaction(tx) + return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(), tx.Hash(), tx.Sender()), nil } func (self *JSPipe) CompileMutan(code string) string { |