2023-09-01 05:44:41 +00:00
|
|
|
import pkg/questionable
|
2022-05-09 13:15:23 +00:00
|
|
|
import pkg/questionable/results
|
2023-09-01 05:44:41 +00:00
|
|
|
import pkg/stew/byteutils
|
2022-05-09 13:15:23 +00:00
|
|
|
import ../sales
|
2022-05-11 08:51:59 +00:00
|
|
|
import ../purchasing
|
2023-09-01 05:44:41 +00:00
|
|
|
import ../utils/json
|
2023-06-21 05:46:18 +00:00
|
|
|
|
|
|
|
export json
|
2022-05-09 13:15:23 +00:00
|
|
|
|
2022-05-10 12:13:39 +00:00
|
|
|
type
|
|
|
|
StorageRequestParams* = object
|
2023-09-01 05:44:41 +00:00
|
|
|
duration* {.serialize.}: UInt256
|
|
|
|
proofProbability* {.serialize.}: UInt256
|
|
|
|
reward* {.serialize.}: UInt256
|
|
|
|
collateral* {.serialize.}: UInt256
|
|
|
|
expiry* {.serialize.}: ?UInt256
|
|
|
|
nodes* {.serialize.}: ?uint
|
|
|
|
tolerance* {.serialize.}: ?uint
|
|
|
|
|
|
|
|
RestPurchase* = object
|
|
|
|
requestId* {.serialize.}: RequestId
|
|
|
|
request* {.serialize.}: ?StorageRequest
|
|
|
|
state* {.serialize.}: string
|
|
|
|
error* {.serialize.}: ?string
|
|
|
|
|
|
|
|
RestAvailability* = object
|
|
|
|
size* {.serialize.}: UInt256
|
|
|
|
duration* {.serialize.}: UInt256
|
|
|
|
minPrice* {.serialize.}: UInt256
|
|
|
|
maxCollateral* {.serialize.}: UInt256
|
2022-08-18 05:55:53 +00:00
|
|
|
|
2023-06-20 12:52:15 +00:00
|
|
|
func `%`*(obj: StorageRequest | Slot): JsonNode =
|
|
|
|
let jsonObj = newJObject()
|
|
|
|
for k, v in obj.fieldPairs: jsonObj[k] = %v
|
|
|
|
jsonObj["id"] = %(obj.id)
|
|
|
|
|
|
|
|
return jsonObj
|