@@ -5,20 +5,20 @@ import (
5
5
6
6
"github.com/ethereum/eth-go"
7
7
"github.com/ethereum/eth-go/ethchain"
8
- "github.com/ethereum/eth-go/ethpub "
8
+ "github.com/ethereum/eth-go/ethpipe "
9
9
"github.com/ethereum/eth-go/ethstate"
10
10
"github.com/ethereum/eth-go/ethutil"
11
11
"github.com/obscuren/otto"
12
12
)
13
13
14
14
type JSStateObject struct {
15
- * ethpub. PStateObject
15
+ * ethpipe. JSObject
16
16
eth * JSEthereum
17
17
}
18
18
19
19
func (self * JSStateObject ) EachStorage (call otto.FunctionCall ) otto.Value {
20
20
cb := call .Argument (0 )
21
- self .PStateObject .EachStorage (func (key string , value * ethutil.Value ) {
21
+ self .JSObject .EachStorage (func (key string , value * ethutil.Value ) {
22
22
value .Decode ()
23
23
24
24
cb .Call (self .eth .toVal (self ), self .eth .toVal (key ), self .eth .toVal (ethutil .Bytes2Hex (value .Bytes ())))
@@ -30,12 +30,12 @@ func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value {
30
30
// The JSEthereum object attempts to wrap the PEthereum object and returns
31
31
// meaningful javascript objects
32
32
type JSBlock struct {
33
- * ethpub. PBlock
33
+ * ethpipe. JSBlock
34
34
eth * JSEthereum
35
35
}
36
36
37
37
func (self * JSBlock ) GetTransaction (hash string ) otto.Value {
38
- return self .eth .toVal (self .PBlock .GetTransaction (hash ))
38
+ return self .eth .toVal (self .JSBlock .GetTransaction (hash ))
39
39
}
40
40
41
41
type JSMessage struct {
@@ -67,33 +67,29 @@ func NewJSMessage(message *ethstate.Message) JSMessage {
67
67
}
68
68
69
69
type JSEthereum struct {
70
- * ethpub. PEthereum
70
+ * ethpipe. JSPipe
71
71
vm * otto.Otto
72
72
ethereum * eth.Ethereum
73
73
}
74
74
75
75
func (self * JSEthereum ) GetBlock (hash string ) otto.Value {
76
- return self .toVal (& JSBlock {self .PEthereum . GetBlock (hash ), self })
76
+ return self .toVal (& JSBlock {self .JSPipe . GetBlockByHash (hash ), self })
77
77
}
78
78
79
79
func (self * JSEthereum ) GetPeers () otto.Value {
80
- return self .toVal (self .PEthereum .GetPeers ())
80
+ return self .toVal (self .JSPipe .GetPeers ())
81
81
}
82
82
83
83
func (self * JSEthereum ) GetKey () otto.Value {
84
- return self .toVal (self .PEthereum .GetKey ())
84
+ return self .toVal (self .JSPipe .GetKey ())
85
85
}
86
86
87
87
func (self * JSEthereum ) GetStateObject (addr string ) otto.Value {
88
- return self .toVal (& JSStateObject {self .PEthereum .GetStateObject (addr ), self })
89
- }
90
-
91
- func (self * JSEthereum ) GetStateKeyVals (addr string ) otto.Value {
92
- return self .toVal (self .PEthereum .GetStateObject (addr ).StateKeyVal (false ))
88
+ return self .toVal (& JSStateObject {ethpipe .NewJSObject (self .JSPipe .World ().SafeGet (ethutil .Hex2Bytes (addr ))), self })
93
89
}
94
90
95
91
func (self * JSEthereum ) Transact (key , recipient , valueStr , gasStr , gasPriceStr , dataStr string ) otto.Value {
96
- r , err := self .PEthereum .Transact (key , recipient , valueStr , gasStr , gasPriceStr , dataStr )
92
+ r , err := self .JSPipe .Transact (key , recipient , valueStr , gasStr , gasPriceStr , dataStr )
97
93
if err != nil {
98
94
fmt .Println (err )
99
95
@@ -104,7 +100,7 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr,
104
100
}
105
101
106
102
func (self * JSEthereum ) Create (key , valueStr , gasStr , gasPriceStr , scriptStr string ) otto.Value {
107
- r , err := self .PEthereum . Create (key , valueStr , gasStr , gasPriceStr , scriptStr )
103
+ r , err := self .JSPipe . Transact (key , "" , valueStr , gasStr , gasPriceStr , scriptStr )
108
104
109
105
if err != nil {
110
106
fmt .Println (err )
0 commit comments