Fix for json conversion of hexstrings

This commit is contained in:
coffeepots 2018-07-31 17:46:40 +01:00 committed by zah
parent c5514155ee
commit 723ef3cf70
1 changed files with 4 additions and 4 deletions

View File

@ -90,14 +90,14 @@ proc fromJson*(n: JsonNode, argName: string, result: var HexQuantityStr) =
n.kind.expect(JString, argName)
let hexStr = n.getStr()
if not hexStr.validateHexQuantity:
raise newException(ValueError, "Parameter \"" & argName & "\" value is not valid as an Ethereum hex quantity \"" & hexStr & "\"")
result = hexStr[2..hexStr.high].hexQuantityStr
raise newException(ValueError, "Parameter \"" & argName & "\" is not valid as an Ethereum hex quantity \"" & hexStr & "\"")
result = hexStr.hexQuantityStr
proc fromJson*(n: JsonNode, argName: string, result: var HexDataStr) =
# Note that '0x' is stripped after validation
n.kind.expect(JString, argName)
let hexStr = n.getStr()
if not hexStr.validateHexData:
raise newException(ValueError, "Parameter \"" & argName & "\" value is not valid as a Ethereum data \"" & hexStr & "\"")
result = hexStr[2..hexStr.high].hexDataStr
raise newException(ValueError, "Parameter \"" & argName & "\" is not valid as a Ethereum data \"" & hexStr & "\"")
result = hexStr.hexDataStr