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
6d012f62
Commit
6d012f62
authored
Jan 29, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement transact
parent
ec854586
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
48 deletions
+24
-48
ethereum.js
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
+0
-3
main.qml
cmd/mist/assets/qml/main.qml
+2
-2
args.go
rpc/args.go
+2
-35
message.go
rpc/message.go
+11
-6
packages.go
rpc/packages.go
+9
-2
No files found.
cmd/mist/assets/ext/ethereum.js/dist/ethereum.js
View file @
6d012f62
...
...
@@ -550,9 +550,6 @@ var contract = function (address, desc) {
result
[
displayName
][
typeName
]
=
impl
;
});
console
.
log
(
"call:"
)
console
.
log
(
result
.
call
)
console
.
log
(
JSON
.
stringify
(
result
));
return
result
;
};
...
...
cmd/mist/assets/qml/main.qml
View file @
6d012f62
...
...
@@ -45,8 +45,8 @@ ApplicationWindow {
mainSplit
.
setView
(
wallet
.
view
,
wallet
.
menuItem
);
console
.
log
(
"starting browser"
)
newBrowserTab
(
"
http://etherian.io
"
);
//newBrowserTab("http://etherian.io");
newBrowserTab
(
"
file:///users/jeffrey/test.html
"
);
// Command setup
gui
.
sendCommand
(
0
)
...
...
rpc/args.go
View file @
6d012f62
package
rpc
import
(
"encoding/json"
)
import
"encoding/json"
type
GetBlockArgs
struct
{
BlockNumber
int32
...
...
@@ -30,33 +28,18 @@ func (obj *GetBlockArgs) requirements() error {
}
type
NewTxArgs
struct
{
Sec
string
`json:"sec"`
Recipient
string
`json:"recipient"`
Value
string
`json:"value"`
Gas
string
`json:"gas"`
GasPrice
string
`json:"gasprice"`
Init
string
`json:"init"`
Body
string
`json:"body"`
Data
string
`json:"data"`
}
// type TxResponse struct {
// Hash string
// }
func
(
obj
*
NewTxArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
if
err
=
json
.
Unmarshal
(
b
,
obj
);
err
==
nil
{
return
}
return
NewErrorResponse
(
ErrorDecodeArgs
)
}
func
(
a
*
NewTxArgs
)
requirements
()
error
{
if
a
.
Recipient
==
""
{
return
NewErrorResponse
(
"Transact requires a 'recipient' address as argument"
)
}
if
a
.
Value
==
""
{
return
NewErrorResponse
(
"Transact requires a 'value' as argument"
)
}
if
a
.
Gas
==
""
{
return
NewErrorResponse
(
"Transact requires a 'gas' value as argument"
)
}
...
...
@@ -66,22 +49,6 @@ func (a *NewTxArgs) requirements() error {
return
nil
}
func
(
a
*
NewTxArgs
)
requirementsContract
()
error
{
if
a
.
Value
==
""
{
return
NewErrorResponse
(
"Create requires a 'value' as argument"
)
}
if
a
.
Gas
==
""
{
return
NewErrorResponse
(
"Create requires a 'gas' value as argument"
)
}
if
a
.
GasPrice
==
""
{
return
NewErrorResponse
(
"Create requires a 'gasprice' value as argument"
)
}
if
a
.
Body
==
""
{
return
NewErrorResponse
(
"Create requires a 'body' value as argument"
)
}
return
nil
}
type
PushTxArgs
struct
{
Tx
string
`json:"tx"`
}
...
...
rpc/message.go
View file @
6d012f62
...
...
@@ -20,6 +20,7 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
)
const
(
...
...
@@ -56,6 +57,14 @@ type RpcRequest struct {
Params
[]
json
.
RawMessage
`json:"params"`
}
func
NewErrorResponse
(
msg
string
)
error
{
return
errors
.
New
(
msg
)
}
func
NewErrorResponseWithError
(
msg
string
,
err
error
)
error
{
return
fmt
.
Errorf
(
"%s: %v"
,
msg
,
err
)
}
func
(
req
*
RpcRequest
)
ToSha3Args
()
(
*
Sha3Args
,
error
)
{
if
len
(
req
.
Params
)
<
1
{
return
nil
,
NewErrorResponse
(
ErrorArguments
)
...
...
@@ -86,7 +95,7 @@ func (req *RpcRequest) ToGetBlockArgs() (*GetBlockArgs, error) {
}
func
(
req
*
RpcRequest
)
ToNewTxArgs
()
(
*
NewTxArgs
,
error
)
{
if
len
(
req
.
Params
)
<
7
{
if
len
(
req
.
Params
)
<
1
{
return
nil
,
NewErrorResponse
(
ErrorArguments
)
}
...
...
@@ -94,7 +103,7 @@ func (req *RpcRequest) ToNewTxArgs() (*NewTxArgs, error) {
r
:=
bytes
.
NewReader
(
req
.
Params
[
0
])
err
:=
json
.
NewDecoder
(
r
)
.
Decode
(
args
)
if
err
!=
nil
{
return
nil
,
NewErrorResponse
(
ErrorDecodeArgs
)
return
nil
,
NewErrorResponse
WithError
(
ErrorDecodeArgs
,
err
)
}
rpclogger
.
DebugDetailf
(
"%T %v"
,
args
,
args
)
return
args
,
nil
...
...
@@ -175,7 +184,3 @@ func (req *RpcRequest) ToGetCodeAtArgs() (*GetCodeAtArgs, error) {
rpclogger
.
DebugDetailf
(
"%T %v"
,
args
,
args
)
return
args
,
nil
}
func
NewErrorResponse
(
msg
string
)
error
{
return
errors
.
New
(
msg
)
}
rpc/packages.go
View file @
6d012f62
...
...
@@ -67,7 +67,8 @@ 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
.
Body
)
result
,
_
:=
p
.
xeth
.
Transact
(
/* TODO specify account */
args
.
Recipient
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Data
)
fmt
.
Println
(
"result:"
,
result
)
*
reply
=
result
return
nil
}
...
...
@@ -78,7 +79,7 @@ func (p *EthereumApi) Create(args *NewTxArgs, reply *interface{}) error {
return
err
}
result
,
_
:=
p
.
xeth
.
Transact
(
/* TODO specify account */
""
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Body
)
result
,
_
:=
p
.
xeth
.
Transact
(
/* TODO specify account */
""
,
args
.
Value
,
args
.
Gas
,
args
.
GasPrice
,
args
.
Data
)
*
reply
=
result
return
nil
}
...
...
@@ -210,6 +211,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
err
}
return
p
.
GetBlock
(
args
,
reply
)
case
"eth_transact"
:
args
,
err
:=
req
.
ToNewTxArgs
()
if
err
!=
nil
{
return
err
}
return
p
.
Transact
(
args
,
reply
)
case
"web3_sha3"
:
args
,
err
:=
req
.
ToSha3Args
()
if
err
!=
nil
{
...
...
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