Skip to content

Commit c8f36f5

Browse files
authored
Resolve ambiguous call (#181)
* Resolve ambiguous call * uint64 encoding only for JrpcConv
1 parent 2a8bebb commit c8f36f5

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

web3/conversions.nim

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,6 @@ proc writeValue*[F: CommonJsonFlavors](w: var JsonWriter[F], v: RlpEncodedBytes)
203203
{.gcsafe, raises: [IOError].} =
204204
writeHexValue w, distinctBase(v)
205205

206-
proc writeValue*[F: CommonJsonFlavors](
207-
w: var JsonWriter[F], v: uint64
208-
) {.gcsafe, raises: [IOError].} =
209-
w.stream.write "\"0x"
210-
w.stream.toHex(v)
211-
w.stream.write "\""
212-
213206
proc writeValue*[F: CommonJsonFlavors](
214207
w: var JsonWriter[F], v: Quantity
215208
) {.gcsafe, raises: [IOError].} =
@@ -260,29 +253,21 @@ proc readValue*[F: CommonJsonFlavors](r: var JsonReader[F], val: var RlpEncodedB
260253
# skip empty hex
261254
val = RlpEncodedBytes hexToSeqByte(hexStr)
262255

263-
proc readValue*[F: CommonJsonFlavors](r: var JsonReader[F], val: var uint64)
264-
{.gcsafe, raises: [IOError, JsonReaderError].} =
265-
let hexStr = r.parseString()
266-
if hexStr.invalidQuantityPrefix:
267-
r.raiseUnexpectedValue("Uint64 value has invalid leading 0")
268-
wrapValueError:
269-
val = fromHex[uint64](hexStr)
270-
271256
proc readValue*[F: CommonJsonFlavors](r: var JsonReader[F], val: var Quantity)
272257
{.gcsafe, raises: [IOError, JsonReaderError].} =
273258
let hexStr = r.parseString()
274259
if hexStr.invalidQuantityPrefix:
275260
r.raiseUnexpectedValue("Quantity value has invalid leading 0")
276261
wrapValueError:
277-
val = Quantity fromHex[uint64](hexStr)
262+
val = Quantity strutils.fromHex[uint64](hexStr)
278263

279264
proc readValue*[F: CommonJsonFlavors](r: var JsonReader[F], val: var ChainId)
280265
{.gcsafe, raises: [IOError, JsonReaderError].} =
281266
let hexStr = r.parseString()
282267
if hexStr.invalidQuantityPrefix:
283268
r.raiseUnexpectedValue("ChainId value has invalid leading 0")
284269
wrapValueError:
285-
val = ChainId fromHex[uint64](hexStr)
270+
val = ChainId strutils.fromHex[uint64](hexStr)
286271

287272
proc readValue*[F: CommonJsonFlavors](r: var JsonReader[F], val: var PayloadExecutionStatus)
288273
{.gcsafe, raises: [IOError, JsonReaderError].} =
@@ -305,6 +290,20 @@ proc writeValue*[F: CommonJsonFlavors](w: var JsonWriter[F], v: PayloadExecution
305290
# Exclusive to JrpcConv
306291
#------------------------------------------------------------------------------
307292

293+
proc writeValue*(w: var JsonWriter[JrpcConv], v: uint64)
294+
{.gcsafe, raises: [IOError].} =
295+
w.stream.write "\"0x"
296+
w.stream.toHex(v)
297+
w.stream.write "\""
298+
299+
proc readValue*(r: var JsonReader[JrpcConv], val: var uint64)
300+
{.gcsafe, raises: [IOError, JsonReaderError].} =
301+
let hexStr = r.parseString()
302+
if hexStr.invalidQuantityPrefix:
303+
r.raiseUnexpectedValue("Uint64 value has invalid leading 0")
304+
wrapValueError:
305+
val = strutils.fromHex[uint64](hexStr)
306+
308307
proc writeValue*(w: var JsonWriter[JrpcConv], val: UInt256)
309308
{.gcsafe, raises: [IOError].} =
310309
w.writeValue("0x" & val.toHex)

0 commit comments

Comments
 (0)