Skip to content

Commit 6d596b1

Browse files
author
Bas van Kervel
committed
fixed eth sign unittest
1 parent 2e0b56a commit 6d596b1

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

rpc/api/eth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
"eth_getData": (*ethApi).GetData,
4747
"eth_getCode": (*ethApi).GetData,
4848
"eth_sign": (*ethApi).Sign,
49-
"eth_sendRawTransaction": (*ethApi).PushTx,
49+
"eth_sendRawTransaction": (*ethApi).SendRawTransaction,
5050
"eth_sendTransaction": (*ethApi).SendTransaction,
5151
"eth_transact": (*ethApi).SendTransaction,
5252
"eth_estimateGas": (*ethApi).EstimateGas,
@@ -250,7 +250,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
250250
return v, nil
251251
}
252252

253-
func (self *ethApi) PushTx(req *shared.Request) (interface{}, error) {
253+
func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error) {
254254
args := new(NewDataArgs)
255255
if err := self.codec.Decode(req.Params, &args); err != nil {
256256
return nil, shared.NewDecodeParamError(err.Error())

rpc/api/eth_args.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
466466
}
467467
args.Value = num
468468

469-
if ext.Gas == nil {
470-
num = big.NewInt(0)
471-
} else {
469+
if ext.Gas != nil {
472470
if num, err = numString(ext.Gas); err != nil {
473471
return err
474472
}
473+
} else {
474+
num = nil
475475
}
476476
args.Gas = num
477477

478-
if ext.GasPrice == nil {
479-
num = big.NewInt(0)
480-
} else {
478+
if ext.GasPrice != nil {
481479
if num, err = numString(ext.GasPrice); err != nil {
482480
return err
483481
}
482+
} else {
483+
num = nil
484484
}
485485
args.GasPrice = num
486486

rpc/api/eth_js.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
package api
22

33
// JS api provided by web3.js
4+
// eth_sign not standard
5+
6+
const Eth_JS = `
7+
web3._extend({
8+
property: 'eth',
9+
methods:
10+
[
11+
new web3._extend.Method({
12+
name: 'sign',
13+
call: 'eth_sign',
14+
params: 2,
15+
inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
16+
outputFormatter: web3._extend.formatters.formatOutputString
17+
})
18+
]
19+
});
20+
`

rpc/api/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ func Javascript(name string) string {
178178
return Debug_JS
179179
case shared.DbApiName:
180180
return Db_JS
181+
case shared.EthApiName:
182+
return Eth_JS
181183
case shared.MinerApiName:
182184
return Miner_JS
183185
case shared.NetApiName:

rpc/shared/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ var (
2525
ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
2626
}, ",")
2727
)
28-

0 commit comments

Comments
 (0)