Skip to content

Commit

Permalink
fix Quantity parsing on 32-bit platform (#93)
Browse files Browse the repository at this point in the history
`parseHexInt` truncates to `int` but `Quantity` is `uint64`.
Parse using `fromHex` instead (also standard lib, but more general).
  • Loading branch information
etan-status authored Aug 3, 2023
1 parent 9dfeb01 commit 04f56c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web3/conversions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func fromJson*(n: JsonNode, argName: string, result: var Quantity) {.inline.} =
let hexStr = n.getStr
if hexStr.invalidQuantityPrefix:
raise newException(ValueError, "Parameter \"" & argName & "\" value has invalid leading 0")
result = Quantity(parseHexInt(hexStr))
static: doAssert sizeof(Quantity) == sizeof(uint64)
result = Quantity(fromHex[uint64](hexStr))

func getEnumStringTable(enumType: typedesc): Table[string, enumType]
{.compileTime.} =
Expand Down

0 comments on commit 04f56c5

Please sign in to comment.