2018-05-15 19:06:51 +01:00
|
|
|
import json, stint, strutils
|
2018-05-09 13:07:32 +01:00
|
|
|
|
2018-05-15 19:06:51 +01:00
|
|
|
template stintStr(n: UInt256|Int256): JsonNode =
|
2018-05-17 19:11:47 +01:00
|
|
|
var s = n.toHex
|
2018-05-15 19:06:51 +01:00
|
|
|
if s.len mod 2 != 0: s = "0" & s
|
|
|
|
s = "0x" & s
|
|
|
|
%s
|
2018-05-09 13:07:32 +01:00
|
|
|
|
2018-05-15 19:06:51 +01:00
|
|
|
proc `%`*(n: UInt256): JsonNode = n.stintStr
|
2018-05-09 13:07:32 +01:00
|
|
|
|
2018-05-15 19:06:51 +01:00
|
|
|
proc `%`*(n: Int256): JsonNode = n.stintStr
|
2018-05-09 13:07:32 +01:00
|
|
|
|
2018-05-09 14:58:21 +01:00
|
|
|
proc `%`*(n: byte{not lit}): JsonNode =
|
2018-05-09 13:07:32 +01:00
|
|
|
result = newJInt(int(n))
|
|
|
|
|
2018-05-10 21:52:02 +01:00
|
|
|
proc `%`*(n: ref int|ref int64): JsonNode =
|
|
|
|
result = newJInt(int(n[]))
|