mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-13 19:13:11 +00:00
Add check for UInt256 strings being too long
This commit is contained in:
parent
e19aa96755
commit
1a062f0946
@ -79,7 +79,10 @@ proc fromJson(n: JsonNode, argName: string, result: var byte) =
|
||||
proc fromJson(n: JsonNode, argName: string, result: var UInt256) =
|
||||
# expects base 16 string, starting with "0x"
|
||||
n.kind.expect(JString, argName)
|
||||
result = n.getStr().parse(StUint[256], 16) # TODO: Handle errors
|
||||
let hexStr = n.getStr()
|
||||
if hexStr.len > 64 + 2: # including "0x"
|
||||
raise newException(ValueError, "Parameter \"" & argName & "\" value too long for UInt256: " & $hexStr.len)
|
||||
result = hexStr.parse(StUint[256], 16) # TODO: Handle errors
|
||||
|
||||
proc fromJson(n: JsonNode, argName: string, result: var float) =
|
||||
n.kind.expect(JFloat, argName)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user