2023-09-01 15:44:41 +10:00
|
|
|
import pkg/questionable
|
2022-05-09 15:15:23 +02:00
|
|
|
import pkg/questionable/results
|
2023-09-01 15:44:41 +10:00
|
|
|
import pkg/stew/byteutils
|
2022-05-09 15:15:23 +02:00
|
|
|
import ../sales
|
2022-05-11 10:51:59 +02:00
|
|
|
import ../purchasing
|
2023-09-01 15:44:41 +10:00
|
|
|
import ../utils/json
|
2023-06-21 07:46:18 +02:00
|
|
|
|
|
|
|
export json
|
2022-05-09 15:15:23 +02:00
|
|
|
|
2022-05-10 14:13:39 +02:00
|
|
|
type
|
|
|
|
StorageRequestParams* = object
|
2023-09-01 15:44:41 +10: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 15:55:53 +10:00
|
|
|
|
2023-06-20 14:52:15 +02:00
|
|
|
func `%`*(obj: StorageRequest | Slot): JsonNode =
|
|
|
|
let jsonObj = newJObject()
|
|
|
|
for k, v in obj.fieldPairs: jsonObj[k] = %v
|
|
|
|
jsonObj["id"] = %(obj.id)
|
|
|
|
|
|
|
|
return jsonObj
|