forked from cerc-io/plugeth
console: avoid float64 when remarshaling parameters
With Go 1.7, encoding/json marshals float64 using scientific notation ("10e+6"), but Go's int and *big.Int decoders don't accept such numbers. This change disables use of float64 to avoid the problem.
This commit is contained in:
parent
f9be9a2302
commit
32db571681
@ -20,6 +20,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
@ -240,17 +241,19 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
|
|||||||
throwJSException(err.Error())
|
throwJSException(err.Error())
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
rawReq = []byte(reqVal.String())
|
rawReq = reqVal.String()
|
||||||
|
dec = json.NewDecoder(strings.NewReader(rawReq))
|
||||||
reqs []jsonrpcCall
|
reqs []jsonrpcCall
|
||||||
batch bool
|
batch bool
|
||||||
)
|
)
|
||||||
|
dec.UseNumber() // avoid float64s
|
||||||
if rawReq[0] == '[' {
|
if rawReq[0] == '[' {
|
||||||
batch = true
|
batch = true
|
||||||
json.Unmarshal(rawReq, &reqs)
|
dec.Decode(&reqs)
|
||||||
} else {
|
} else {
|
||||||
batch = false
|
batch = false
|
||||||
reqs = make([]jsonrpcCall, 1)
|
reqs = make([]jsonrpcCall, 1)
|
||||||
json.Unmarshal(rawReq, &reqs[0])
|
dec.Decode(&reqs[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the requests.
|
// Execute the requests.
|
||||||
|
Loading…
Reference in New Issue
Block a user