mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-09 20:45:38 +00:00
3181361658
* [state machine] Allow querying of state properties * [purchasing] use new state machine * [state machine] remove old state machine implementation * [purchasing] remove duplication in error handling
15 lines
486 B
Nim
15 lines
486 B
Nim
import ../statemachine
|
|
import ./errorhandling
|
|
import ./error
|
|
|
|
type PurchaseCancelled* = ref object of ErrorHandlingState
|
|
|
|
method `$`*(state: PurchaseCancelled): string =
|
|
"cancelled"
|
|
|
|
method run*(state: PurchaseCancelled, machine: Machine): Future[?State] {.async.} =
|
|
let purchase = Purchase(machine)
|
|
await purchase.market.withdrawFunds(purchase.requestId)
|
|
let error = newException(Timeout, "Purchase cancelled due to timeout")
|
|
return some State(PurchaseErrored(error: error))
|