From 03a87636e7ce0314121bc77a87c82b86dcd202dd Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Tue, 7 Feb 2023 17:12:00 +1100 Subject: [PATCH] [marketplace] support slotIndex no longer optional Previously, SalesAgent.slotIndex had been moved to not optional. However, there were still many places where optionality was assumed. This commit removes those assumuptions. --- codex/sales/salesagent.nim | 9 ++++----- codex/sales/states/downloading.nim | 5 +---- codex/sales/states/filled.nim | 5 +---- codex/sales/states/filling.nim | 5 +---- codex/sales/states/proving.nim | 5 +---- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/codex/sales/salesagent.nim b/codex/sales/salesagent.nim index bfeb8530..c352f125 100644 --- a/codex/sales/salesagent.nim +++ b/codex/sales/salesagent.nim @@ -87,16 +87,15 @@ proc subscribeFailure*(agent: SalesAgent) {.async.} = proc subscribeSlotFilled*(agent: SalesAgent) {.async.} = let market = agent.sales.market - without slotIndex =? agent.slotIndex: - raiseAssert "no slot selected" - proc onSlotFilled(requestId: RequestId, slotIndex: UInt256) {.async.} = without state =? (agent.state as SaleState): return await agent.slotFilled.unsubscribe() - await state.onSlotFilled(requestId, slotIndex) + await state.onSlotFilled(requestId, agent.slotIndex) agent.slotFilled = - await market.subscribeSlotFilled(agent.requestId, slotIndex, onSlotFilled) + await market.subscribeSlotFilled(agent.requestId, + agent.slotIndex, + onSlotFilled) diff --git a/codex/sales/states/downloading.nim b/codex/sales/states/downloading.nim index 4d2a9a5f..a7cd1d6e 100644 --- a/codex/sales/states/downloading.nim +++ b/codex/sales/states/downloading.nim @@ -34,16 +34,13 @@ method enterAsync(state: SaleDownloading) {.async.} = without onStore =? agent.sales.onStore: raiseAssert "onStore callback not set" - without slotIndex =? agent.slotIndex: - raiseAssert "no slot selected" - without request =? agent.request: raiseAssert "no sale request" if availability =? agent.availability: agent.sales.remove(availability) - await onStore(request, slotIndex, agent.availability) + await onStore(request, agent.slotIndex, agent.availability) await state.switchAsync(SaleProving()) except CancelledError: diff --git a/codex/sales/states/filled.nim b/codex/sales/states/filled.nim index 19a17342..ea83ae5b 100644 --- a/codex/sales/states/filled.nim +++ b/codex/sales/states/filled.nim @@ -24,10 +24,7 @@ method enterAsync(state: SaleFilled) {.async.} = try: let market = agent.sales.market - without slotIndex =? agent.slotIndex: - raiseAssert "no slot selected" - - let host = await market.getHost(agent.requestId, slotIndex) + let host = await market.getHost(agent.requestId, agent.slotIndex) let me = await market.getSigner() if host == me.some: await state.switchAsync(SaleFinished()) diff --git a/codex/sales/states/filling.nim b/codex/sales/states/filling.nim index ed5ca209..d1aa5f8e 100644 --- a/codex/sales/states/filling.nim +++ b/codex/sales/states/filling.nim @@ -30,10 +30,7 @@ method enterAsync(state: SaleFilling) {.async.} = try: let market = agent.sales.market - without slotIndex =? agent.slotIndex: - raiseAssert "no slot selected" - - await market.fillSlot(agent.requestId, slotIndex, state.proof) + await market.fillSlot(agent.requestId, agent.slotIndex, state.proof) except CancelledError: discard diff --git a/codex/sales/states/proving.nim b/codex/sales/states/proving.nim index 647a2adb..81d2adb7 100644 --- a/codex/sales/states/proving.nim +++ b/codex/sales/states/proving.nim @@ -29,13 +29,10 @@ method enterAsync(state: SaleProving) {.async.} = without request =? agent.request: raiseAssert "no sale request" - without slotIndex =? agent.slotIndex: - raiseAssert "no slot selected" - without onProve =? agent.sales.onProve: raiseAssert "onProve callback not set" - let proof = await onProve(request, slotIndex) + let proof = await onProve(request, agent.slotIndex) await state.switchAsync(SaleFilling(proof: proof)) except CancelledError: