Skip to content

Commit 0255ed6

Browse files
authored
Merge pull request #14403 from fjl/console-number
console: avoid float64 when remarshaling parameters
2 parents 5494e6e + 32db571 commit 0255ed6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎console/bridge.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"fmt"
2222
"io"
23+
"strings"
2324
"time"
2425

2526
"github.com/ethereum/go-ethereum/log"
@@ -240,17 +241,19 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
240241
throwJSException(err.Error())
241242
}
242243
var (
243-
rawReq = []byte(reqVal.String())
244+
rawReq = reqVal.String()
245+
dec = json.NewDecoder(strings.NewReader(rawReq))
244246
reqs []jsonrpcCall
245247
batch bool
246248
)
249+
dec.UseNumber() // avoid float64s
247250
if rawReq[0] == '[' {
248251
batch = true
249-
json.Unmarshal(rawReq, &reqs)
252+
dec.Decode(&reqs)
250253
} else {
251254
batch = false
252255
reqs = make([]jsonrpcCall, 1)
253-
json.Unmarshal(rawReq, &reqs[0])
256+
dec.Decode(&reqs[0])
254257
}
255258

256259
// Execute the requests.

0 commit comments

Comments
 (0)