Skip to content

Commit b5ee57a

Browse files
authored
feat(slot-reservations): Support reserving slots (#907)
* feat(slot-reservations): Support reserving slots Closes #898. Wire up reserveSlot and canReserveSlot contract calls, but don't call them * Remove return value from `reserveSlot` * convert EthersError to MarketError * Move convertEthersError to reserveSlot * bump codex-contracts-eth after rebase * change `canReserveSlot` and `reserveSlot` parameters Parameters for `canReserveSlot` and `reserveSlot` were changed from `SlotId` to `RequestId` and `UInt256 slotIndex`. * bump codex-contracts-eth after rebase * bump codex-contracts-eth to master after codex-contracts-eth/pull/177 merged
1 parent b491906 commit b5ee57a

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

codex/contracts/market.nim

+15
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,21 @@ method canProofBeMarkedAsMissing*(
247247
trace "Proof cannot be marked as missing", msg = e.msg
248248
return false
249249

250+
method reserveSlot*(
251+
market: OnChainMarket,
252+
requestId: RequestId,
253+
slotIndex: UInt256) {.async.} =
254+
255+
convertEthersError:
256+
discard await market.contract.reserveSlot(requestId, slotIndex).confirm(0)
257+
258+
method canReserveSlot*(
259+
market: OnChainMarket,
260+
requestId: RequestId,
261+
slotIndex: UInt256): Future[bool] {.async.} =
262+
263+
await market.contract.canReserveSlot(requestId, slotIndex)
264+
250265
method subscribeRequests*(market: OnChainMarket,
251266
callback: OnRequest):
252267
Future[MarketSubscription] {.async.} =

codex/contracts/marketplace.nim

+3
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ proc getPointer*(marketplace: Marketplace, id: SlotId): uint8 {.contract, view.}
5151

5252
proc submitProof*(marketplace: Marketplace, id: SlotId, proof: Groth16Proof): ?TransactionResponse {.contract.}
5353
proc markProofAsMissing*(marketplace: Marketplace, id: SlotId, period: UInt256): ?TransactionResponse {.contract.}
54+
55+
proc reserveSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256): ?TransactionResponse {.contract.}
56+
proc canReserveSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256): bool {.contract, view.}

codex/market.nim

+14
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ method canProofBeMarkedAsMissing*(market: Market,
161161
period: Period): Future[bool] {.base, async.} =
162162
raiseAssert("not implemented")
163163

164+
method reserveSlot*(
165+
market: Market,
166+
requestId: RequestId,
167+
slotIndex: UInt256) {.base, async.} =
168+
169+
raiseAssert("not implemented")
170+
171+
method canReserveSlot*(
172+
market: Market,
173+
requestId: RequestId,
174+
slotIndex: UInt256): Future[bool] {.base, async.} =
175+
176+
raiseAssert("not implemented")
177+
164178
method subscribeFulfillment*(market: Market,
165179
callback: OnFulfillment):
166180
Future[Subscription] {.base, async.} =

0 commit comments

Comments
 (0)