2023-07-20 09:56:28 +02:00
|
|
|
import pkg/metrics
|
2022-09-27 16:27:40 +02:00
|
|
|
import ../statemachine
|
2023-06-05 10:48:06 +02:00
|
|
|
import ./errorhandling
|
2022-09-27 16:27:40 +02:00
|
|
|
import ./submitted
|
|
|
|
|
2023-11-03 17:21:54 +02:00
|
|
|
declareCounter(codex_purchases_pending, "codex purchases pending")
|
2023-07-20 09:56:28 +02:00
|
|
|
|
2023-06-05 10:48:06 +02:00
|
|
|
type PurchasePending* = ref object of ErrorHandlingState
|
2022-09-27 16:27:40 +02:00
|
|
|
|
2023-06-05 10:48:06 +02:00
|
|
|
method `$`*(state: PurchasePending): string =
|
2022-11-08 02:10:17 -05:00
|
|
|
"pending"
|
2023-06-05 10:48:06 +02:00
|
|
|
|
|
|
|
method run*(state: PurchasePending, machine: Machine): Future[?State] {.async.} =
|
2023-11-03 17:21:54 +02:00
|
|
|
codex_purchases_pending.inc()
|
2023-06-05 10:48:06 +02:00
|
|
|
let purchase = Purchase(machine)
|
|
|
|
let request = !purchase.request
|
|
|
|
await purchase.market.requestStorage(request)
|
|
|
|
return some State(PurchaseSubmitted())
|