2022-05-09 13:15:23 +00:00
|
|
|
import std/json
|
|
|
|
import std/strutils
|
|
|
|
import pkg/stew/byteutils
|
|
|
|
import pkg/questionable/results
|
|
|
|
import ../sales
|
|
|
|
|
|
|
|
proc fromJson*(_: type Availability, bytes: seq[byte]): ?!Availability =
|
|
|
|
let json = ?catch parseJson(string.fromBytes(bytes))
|
|
|
|
let size = ?catch UInt256.fromHex(json["size"].getStr)
|
2022-05-09 14:51:08 +00:00
|
|
|
let duration = ?catch UInt256.fromHex(json["duration"].getStr)
|
|
|
|
let minPrice = ?catch UInt256.fromHex(json["minPrice"].getStr)
|
2022-05-09 13:15:23 +00:00
|
|
|
success Availability.init(size, duration, minPrice)
|