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
966cfa4b
Commit
966cfa4b
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NewTxArgs
parent
c7dc379d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
38 deletions
+17
-38
api.go
rpc/api.go
+2
-6
args.go
rpc/args.go
+8
-12
args_test.go
rpc/args_test.go
+7
-20
No files found.
rpc/api.go
View file @
966cfa4b
...
...
@@ -185,11 +185,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
return
err
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
.
Hex
(),
args
.
To
.
Hex
(),
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
if
err
!=
nil
{
return
err
}
...
...
@@ -200,7 +196,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
}
v
,
err
:=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
v
,
err
:=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
.
Hex
(),
args
.
To
.
Hex
()
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
if
err
!=
nil
{
return
err
}
...
...
rpc/args.go
View file @
966cfa4b
...
...
@@ -93,8 +93,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
}
type
NewTxArgs
struct
{
From
string
To
string
From
common
.
Address
To
common
.
Address
Value
*
big
.
Int
Gas
*
big
.
Int
GasPrice
*
big
.
Int
...
...
@@ -122,9 +122,12 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return
NewDecodeParamError
(
err
.
Error
())
}
// var ok bool
args
.
From
=
ext
.
From
args
.
To
=
ext
.
To
if
len
(
ext
.
From
)
==
0
{
return
NewValidationError
(
"from"
,
"is required"
)
}
args
.
From
=
common
.
HexToAddress
(
ext
.
From
)
args
.
To
=
common
.
HexToAddress
(
ext
.
To
)
args
.
Value
=
common
.
String2Big
(
ext
.
Value
)
args
.
Gas
=
common
.
String2Big
(
ext
.
Gas
)
args
.
GasPrice
=
common
.
String2Big
(
ext
.
GasPrice
)
...
...
@@ -145,13 +148,6 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
}
func
(
args
*
NewTxArgs
)
requirements
()
error
{
if
len
(
args
.
From
)
==
0
{
return
NewValidationError
(
"From"
,
"Is required"
)
}
return
nil
}
type
GetStorageArgs
struct
{
Address
string
BlockNumber
int64
...
...
rpc/args_test.go
View file @
966cfa4b
...
...
@@ -149,8 +149,8 @@ func TestNewTxArgs(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"0x10"]`
expected
:=
new
(
NewTxArgs
)
expected
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
expected
.
To
=
"0xd46e8dd67c5d32be8058bb8eb970870f072445675"
expected
.
From
=
common
.
HexToAddress
(
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
)
expected
.
To
=
common
.
HexToAddress
(
"0xd46e8dd67c5d32be8058bb8eb970870f072445675"
)
expected
.
Gas
=
big
.
NewInt
(
30400
)
expected
.
GasPrice
=
big
.
NewInt
(
10000000000000
)
expected
.
Value
=
big
.
NewInt
(
10000000000000
)
...
...
@@ -194,7 +194,7 @@ func TestNewTxArgs(t *testing.T) {
func
TestNewTxArgsBlockInt
(
t
*
testing
.
T
)
{
input
:=
`[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, 5]`
expected
:=
new
(
NewTxArgs
)
expected
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
expected
.
From
=
common
.
HexToAddress
(
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
)
expected
.
BlockNumber
=
big
.
NewInt
(
5
)
.
Int64
()
args
:=
new
(
NewTxArgs
)
...
...
@@ -221,31 +221,18 @@ func TestNewTxArgsEmpty(t *testing.T) {
}
}
func
TestNewTxArgsReqs
(
t
*
testing
.
T
)
{
args
:=
new
(
NewTxArgs
)
args
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
err
:=
args
.
requirements
()
switch
err
.
(
type
)
{
case
nil
:
break
default
:
t
.
Errorf
(
"Get %T"
,
err
)
}
}
func
TestNewTxArgsFromEmpty
(
t
*
testing
.
T
)
{
input
:=
`[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}]`
func
TestNewTxArgsReqsFromBlank
(
t
*
testing
.
T
)
{
args
:=
new
(
NewTxArgs
)
args
.
From
=
""
err
:=
args
.
requirements
()
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
case
*
ValidationError
:
break
default
:
t
.
Error
(
"Wrong type of error"
)
t
.
Error
f
(
"Expected *rpc.ValidationError, but got %T with message `%s`"
,
err
,
err
.
Error
()
)
}
}
...
...
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