good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
966cfa4b
Commit
966cfa4b
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Downloads
Patches
Plain Diff
NewTxArgs
parent
c7dc379d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
rpc/api.go
+2
-6
2 additions, 6 deletions
rpc/api.go
rpc/args.go
+8
-12
8 additions, 12 deletions
rpc/args.go
rpc/args_test.go
+7
-20
7 additions, 20 deletions
rpc/args_test.go
with
17 additions
and
38 deletions
rpc/api.go
+
2
−
6
View file @
966cfa4b
...
@@ -185,11 +185,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -185,11 +185,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
return
err
}
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
.
Hex
(),
args
.
To
.
Hex
(),
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
return
err
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -200,7 +196,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -200,7 +196,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
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
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
This diff is collapsed.
Click to expand it.
rpc/args.go
+
8
−
12
View file @
966cfa4b
...
@@ -93,8 +93,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -93,8 +93,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
}
}
type
NewTxArgs
struct
{
type
NewTxArgs
struct
{
From
string
From
common
.
Address
To
string
To
common
.
Address
Value
*
big
.
Int
Value
*
big
.
Int
Gas
*
big
.
Int
Gas
*
big
.
Int
GasPrice
*
big
.
Int
GasPrice
*
big
.
Int
...
@@ -122,9 +122,12 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -122,9 +122,12 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return
NewDecodeParamError
(
err
.
Error
())
return
NewDecodeParamError
(
err
.
Error
())
}
}
// var ok bool
if
len
(
ext
.
From
)
==
0
{
args
.
From
=
ext
.
From
return
NewValidationError
(
"from"
,
"is required"
)
args
.
To
=
ext
.
To
}
args
.
From
=
common
.
HexToAddress
(
ext
.
From
)
args
.
To
=
common
.
HexToAddress
(
ext
.
To
)
args
.
Value
=
common
.
String2Big
(
ext
.
Value
)
args
.
Value
=
common
.
String2Big
(
ext
.
Value
)
args
.
Gas
=
common
.
String2Big
(
ext
.
Gas
)
args
.
Gas
=
common
.
String2Big
(
ext
.
Gas
)
args
.
GasPrice
=
common
.
String2Big
(
ext
.
GasPrice
)
args
.
GasPrice
=
common
.
String2Big
(
ext
.
GasPrice
)
...
@@ -145,13 +148,6 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -145,13 +148,6 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
return
nil
}
}
func
(
args
*
NewTxArgs
)
requirements
()
error
{
if
len
(
args
.
From
)
==
0
{
return
NewValidationError
(
"From"
,
"Is required"
)
}
return
nil
}
type
GetStorageArgs
struct
{
type
GetStorageArgs
struct
{
Address
string
Address
string
BlockNumber
int64
BlockNumber
int64
...
...
This diff is collapsed.
Click to expand it.
rpc/args_test.go
+
7
−
20
View file @
966cfa4b
...
@@ -149,8 +149,8 @@ func TestNewTxArgs(t *testing.T) {
...
@@ -149,8 +149,8 @@ func TestNewTxArgs(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"0x10"]`
"0x10"]`
expected
:=
new
(
NewTxArgs
)
expected
:=
new
(
NewTxArgs
)
expected
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
expected
.
From
=
common
.
HexToAddress
(
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
)
expected
.
To
=
"0xd46e8dd67c5d32be8058bb8eb970870f072445675"
expected
.
To
=
common
.
HexToAddress
(
"0xd46e8dd67c5d32be8058bb8eb970870f072445675"
)
expected
.
Gas
=
big
.
NewInt
(
30400
)
expected
.
Gas
=
big
.
NewInt
(
30400
)
expected
.
GasPrice
=
big
.
NewInt
(
10000000000000
)
expected
.
GasPrice
=
big
.
NewInt
(
10000000000000
)
expected
.
Value
=
big
.
NewInt
(
10000000000000
)
expected
.
Value
=
big
.
NewInt
(
10000000000000
)
...
@@ -194,7 +194,7 @@ func TestNewTxArgs(t *testing.T) {
...
@@ -194,7 +194,7 @@ func TestNewTxArgs(t *testing.T) {
func
TestNewTxArgsBlockInt
(
t
*
testing
.
T
)
{
func
TestNewTxArgsBlockInt
(
t
*
testing
.
T
)
{
input
:=
`[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, 5]`
input
:=
`[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, 5]`
expected
:=
new
(
NewTxArgs
)
expected
:=
new
(
NewTxArgs
)
expected
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
expected
.
From
=
common
.
HexToAddress
(
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
)
expected
.
BlockNumber
=
big
.
NewInt
(
5
)
.
Int64
()
expected
.
BlockNumber
=
big
.
NewInt
(
5
)
.
Int64
()
args
:=
new
(
NewTxArgs
)
args
:=
new
(
NewTxArgs
)
...
@@ -221,31 +221,18 @@ func TestNewTxArgsEmpty(t *testing.T) {
...
@@ -221,31 +221,18 @@ func TestNewTxArgsEmpty(t *testing.T) {
}
}
}
}
func
TestNewTxArgsReqs
(
t
*
testing
.
T
)
{
func
TestNewTxArgsFromEmpty
(
t
*
testing
.
T
)
{
args
:=
new
(
NewTxArgs
)
input
:=
`[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}]`
args
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
err
:=
args
.
requirements
()
switch
err
.
(
type
)
{
case
nil
:
break
default
:
t
.
Errorf
(
"Get %T"
,
err
)
}
}
func
TestNewTxArgsReqsFromBlank
(
t
*
testing
.
T
)
{
args
:=
new
(
NewTxArgs
)
args
:=
new
(
NewTxArgs
)
args
.
From
=
""
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
err
:=
args
.
requirements
()
switch
err
.
(
type
)
{
switch
err
.
(
type
)
{
case
nil
:
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
t
.
Error
(
"Expected error but didn't get one"
)
case
*
ValidationError
:
case
*
ValidationError
:
break
break
default
:
default
:
t
.
Error
(
"
Wrong type of error"
)
t
.
Error
f
(
"
Expected *rpc.ValidationError, but got %T with message `%s`"
,
err
,
err
.
Error
()
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment