mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-20 17:58:53 +00:00
2cf892c467
* Smart contracts update: Groth16Proof instead of bytes * Use dummy verifier for now, until we can create ZK proofs * Fix tests: submit proof only when slot is filled * Submit dummy proofs for now * More detailed log when proof submission failed * Use dummy verifier for integration tests For now at least * Fix mistake in blanket renaming to ethProvider * Update to latest codex-contracts-eth * feat: zkey-hash from chain * Fix zkeyHash --------- Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
37 lines
1.1 KiB
Nim
37 lines
1.1 KiB
Nim
import ../../logutils
|
|
import ../../market
|
|
import ../statemachine
|
|
import ../salesagent
|
|
import ./errorhandling
|
|
import ./filled
|
|
import ./cancelled
|
|
import ./failed
|
|
|
|
logScope:
|
|
topics = "marketplace sales filling"
|
|
|
|
type
|
|
SaleFilling* = ref object of ErrorHandlingState
|
|
proof*: Groth16Proof
|
|
|
|
method `$`*(state: SaleFilling): string = "SaleFilling"
|
|
|
|
method onCancelled*(state: SaleFilling, request: StorageRequest): ?State =
|
|
return some State(SaleCancelled())
|
|
|
|
method onFailed*(state: SaleFilling, request: StorageRequest): ?State =
|
|
return some State(SaleFailed())
|
|
|
|
method onSlotFilled*(state: SaleFilling, requestId: RequestId,
|
|
slotIndex: UInt256): ?State =
|
|
return some State(SaleFilled())
|
|
|
|
method run(state: SaleFilling, machine: Machine): Future[?State] {.async.} =
|
|
let data = SalesAgent(machine).data
|
|
let market = SalesAgent(machine).context.market
|
|
without (collateral =? data.request.?ask.?collateral):
|
|
raiseAssert "Request not set"
|
|
|
|
debug "Filling slot", requestId = data.requestId, slotIndex = data.slotIndex
|
|
await market.fillSlot(data.requestId, data.slotIndex, state.proof, collateral)
|