Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
84adf77b
Commit
84adf77b
authored
Jan 29, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added RPC "Call" for JS calls to contracts
parent
f75dcc7f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
11 deletions
+55
-11
main.qml
cmd/mist/assets/qml/main.qml
+1
-2
javascript_runtime.go
javascript/javascript_runtime.go
+1
-2
args.go
rpc/args.go
+6
-5
packages.go
rpc/packages.go
+17
-2
vm.go
vm/vm.go
+2
-0
xeth.go
xeth/xeth.go
+28
-0
No files found.
cmd/mist/assets/qml/main.qml
View file @
84adf77b
...
...
@@ -45,8 +45,7 @@ ApplicationWindow {
mainSplit
.
setView
(
wallet
.
view
,
wallet
.
menuItem
);
//newBrowserTab("http://etherian.io");
newBrowserTab
(
"file:///users/jeffrey/test.html"
);
newBrowserTab
(
"http://etherian.io"
);
// Command setup
gui
.
sendCommand
(
0
)
...
...
javascript/javascript_runtime.go
View file @
84adf77b
...
...
@@ -58,8 +58,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
re
.
Vm
.
Run
(
jsLib
)
// Load extra javascript files
re
.
LoadIntFile
(
"string.js"
)
re
.
LoadIntFile
(
"big.js"
)
re
.
LoadIntFile
(
"bignumber.min.js"
)
// Subscribe to events
mux
:=
ethereum
.
EventMux
()
...
...
rpc/args.go
View file @
84adf77b
...
...
@@ -28,11 +28,12 @@ func (obj *GetBlockArgs) requirements() error {
}
type
NewTxArgs
struct
{
Recipient
string
`json:"recipient"`
Value
string
`json:"value"`
Gas
string
`json:"gas"`
GasPrice
string
`json:"gasprice"`
Data
string
`json:"data"`
From
string
`json:"from"`
To
string
`json:"to"`
Value
string
`json:"value"`
Gas
string
`json:"gas"`
GasPrice
string
`json:"gasPrice"`
Data
string
`json:"data"`
}
// type TxResponse struct {
...
...
rpc/packages.go
View file @
84adf77b
...
...
@@ -67,8 +67,17 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
if
err
!=
nil
{
return
err
}
result
,
_
:=
p
.
xeth
.
Transact
(
/* TODO specify account */
args
.
Recipient
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Data
)
fmt
.
Println
(
"result:"
,
result
)
result
,
_
:=
p
.
xeth
.
Transact
(
/* TODO specify account */
args
.
To
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Data
)
*
reply
=
result
return
nil
}
func
(
p
*
EthereumApi
)
Call
(
args
*
NewTxArgs
,
reply
*
interface
{})
error
{
result
,
err
:=
p
.
xeth
.
Call
(
/* TODO specify account */
args
.
To
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Data
)
if
err
!=
nil
{
return
err
}
*
reply
=
result
return
nil
}
...
...
@@ -206,6 +215,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
err
}
return
p
.
Transact
(
args
,
reply
)
case
"eth_call"
:
args
,
err
:=
req
.
ToNewTxArgs
()
if
err
!=
nil
{
return
err
}
return
p
.
Call
(
args
,
reply
)
case
"web3_sha3"
:
args
,
err
:=
req
.
ToSha3Args
()
if
err
!=
nil
{
...
...
vm/vm.go
View file @
84adf77b
...
...
@@ -634,6 +634,8 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
continue
}
self
.
Printf
(
" ~> false"
)
case
JUMPDEST
:
case
PC
:
stack
.
Push
(
big
.
NewInt
(
int64
(
pc
)))
...
...
xeth/xeth.go
View file @
84adf77b
...
...
@@ -204,6 +204,34 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
return
toHex
(
tx
.
Hash
()),
nil
}
func
(
self
*
XEth
)
Call
(
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
string
)
(
string
,
error
)
{
if
len
(
gasStr
)
==
0
{
gasStr
=
"100000"
}
if
len
(
gasPriceStr
)
==
0
{
gasPriceStr
=
"1"
}
var
(
statedb
=
self
.
chainManager
.
TransState
()
initiator
=
state
.
NewStateObject
(
self
.
eth
.
KeyManager
()
.
KeyPair
()
.
Address
(),
self
.
eth
.
Db
())
block
=
self
.
chainManager
.
CurrentBlock
()
to
=
statedb
.
GetOrNewStateObject
(
fromHex
(
toStr
))
data
=
fromHex
(
dataStr
)
gas
=
ethutil
.
Big
(
gasStr
)
price
=
ethutil
.
Big
(
gasPriceStr
)
value
=
ethutil
.
Big
(
valueStr
)
)
vmenv
:=
NewEnv
(
self
.
chainManager
,
statedb
,
block
,
value
,
initiator
.
Address
())
res
,
err
:=
vmenv
.
Call
(
initiator
,
to
.
Address
(),
data
,
gas
,
price
,
value
)
if
err
!=
nil
{
return
""
,
err
}
return
toHex
(
res
),
nil
}
func
(
self
*
XEth
)
Transact
(
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
string
,
error
)
{
var
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment