22 lines
499 B
Nim
Raw Normal View History

2022-01-18 12:42:58 +01:00
import std/json
import ../../basics
2022-01-18 14:26:41 +01:00
# Address
2022-01-18 12:42:58 +01:00
func `%`*(address: Address): JsonNode =
%($address)
2022-01-18 14:26:41 +01:00
func fromJson*(json: JsonNode, name: string, result: var Address) =
2022-01-18 12:42:58 +01:00
if address =? Address.init(json.getStr()):
result = address
else:
2022-01-18 14:26:41 +01:00
raise newException(ValueError, "\"" & name & "\"is not an Address")
# UInt256
func `%`*(integer: UInt256): JsonNode =
%toHex(integer)
func fromJson*(json: JsonNode, name: string, result: var UInt256) =
result = UInt256.fromHex(json.getStr())