From b5ee57afd776a3d148f258dc1559567fef5d0aaa Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:21:51 +1000 Subject: [PATCH] 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 --- codex/contracts/market.nim | 15 +++++++++++++++ codex/contracts/marketplace.nim | 3 +++ codex/market.nim | 14 ++++++++++++++ vendor/codex-contracts-eth | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/codex/contracts/market.nim b/codex/contracts/market.nim index 1595b449..3ca0d0e6 100644 --- a/codex/contracts/market.nim +++ b/codex/contracts/market.nim @@ -247,6 +247,21 @@ method canProofBeMarkedAsMissing*( trace "Proof cannot be marked as missing", msg = e.msg return false +method reserveSlot*( + market: OnChainMarket, + requestId: RequestId, + slotIndex: UInt256) {.async.} = + + convertEthersError: + discard await market.contract.reserveSlot(requestId, slotIndex).confirm(0) + +method canReserveSlot*( + market: OnChainMarket, + requestId: RequestId, + slotIndex: UInt256): Future[bool] {.async.} = + + await market.contract.canReserveSlot(requestId, slotIndex) + method subscribeRequests*(market: OnChainMarket, callback: OnRequest): Future[MarketSubscription] {.async.} = diff --git a/codex/contracts/marketplace.nim b/codex/contracts/marketplace.nim index f98b9a80..6425bfa0 100644 --- a/codex/contracts/marketplace.nim +++ b/codex/contracts/marketplace.nim @@ -51,3 +51,6 @@ proc getPointer*(marketplace: Marketplace, id: SlotId): uint8 {.contract, view.} proc submitProof*(marketplace: Marketplace, id: SlotId, proof: Groth16Proof): ?TransactionResponse {.contract.} proc markProofAsMissing*(marketplace: Marketplace, id: SlotId, period: UInt256): ?TransactionResponse {.contract.} + +proc reserveSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256): ?TransactionResponse {.contract.} +proc canReserveSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256): bool {.contract, view.} diff --git a/codex/market.nim b/codex/market.nim index 245c28d5..89e6231a 100644 --- a/codex/market.nim +++ b/codex/market.nim @@ -161,6 +161,20 @@ method canProofBeMarkedAsMissing*(market: Market, period: Period): Future[bool] {.base, async.} = raiseAssert("not implemented") +method reserveSlot*( + market: Market, + requestId: RequestId, + slotIndex: UInt256) {.base, async.} = + + raiseAssert("not implemented") + +method canReserveSlot*( + market: Market, + requestId: RequestId, + slotIndex: UInt256): Future[bool] {.base, async.} = + + raiseAssert("not implemented") + method subscribeFulfillment*(market: Market, callback: OnFulfillment): Future[Subscription] {.base, async.} = diff --git a/vendor/codex-contracts-eth b/vendor/codex-contracts-eth index 558bf645..33010bd2 160000 --- a/vendor/codex-contracts-eth +++ b/vendor/codex-contracts-eth @@ -1 +1 @@ -Subproject commit 558bf645c3dc385437a3e695bba57e7dba1375fb +Subproject commit 33010bd20cfdc3d589be25782052796af580ca83