mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-17 23:36:33 +00:00
[marketplace] update to work with latest contracts
This commit is contained in:
parent
7a85350fad
commit
7eba2f46b3
@ -31,8 +31,8 @@ method getSigner*(market: OnChainMarket): Future[Address] {.async.} =
|
||||
method myRequests*(market: OnChainMarket): Future[seq[RequestId]] {.async.} =
|
||||
return await market.contract.myRequests
|
||||
|
||||
method mySlots*(market: OnChainMarket, requestId: RequestId): Future[seq[SlotId]] {.async.} =
|
||||
return await market.contract.mySlots(requestId)
|
||||
method mySlots*(market: OnChainMarket): Future[seq[SlotId]] {.async.} =
|
||||
return await market.contract.mySlots()
|
||||
|
||||
method requestStorage(market: OnChainMarket, request: StorageRequest){.async.} =
|
||||
await market.contract.requestStorage(request)
|
||||
|
@ -118,8 +118,8 @@ func solidityType*(_: type StorageRequest): string =
|
||||
func solidityType*(_: type Slot): string =
|
||||
solidityType(Slot.fieldTypes)
|
||||
|
||||
func solidityType*[T: RequestId | SlotId | Nonce](_: type T): string =
|
||||
solidityType(array[32, byte])
|
||||
# func solidityType*[T: RequestId | SlotId | Nonce](_: type T): string =
|
||||
# solidityType(array[32, byte])
|
||||
func encode*(encoder: var AbiEncoder, por: StoragePoR) =
|
||||
encoder.write(por.fieldValues)
|
||||
|
||||
@ -140,10 +140,10 @@ func encode*(encoder: var AbiEncoder, request: StorageRequest) =
|
||||
func encode*(encoder: var AbiEncoder, slot: Slot) =
|
||||
encoder.write(slot.fieldValues)
|
||||
|
||||
func decode*[T: RequestId | SlotId | Nonce](decoder: var AbiDecoder,
|
||||
_: type T): ?!T =
|
||||
let nonce = ?decoder.read(type array[32, byte])
|
||||
success T(nonce)
|
||||
# func decode*[T: RequestId | SlotId | Nonce](decoder: var AbiDecoder,
|
||||
# _: type T): ?!T =
|
||||
# let nonce = ?decoder.read(type array[32, byte])
|
||||
# success T(nonce)
|
||||
|
||||
func decode*(decoder: var AbiDecoder, T: type StoragePoR): ?!T =
|
||||
let tupl = ?decoder.read(StoragePoR.fieldTypes)
|
||||
|
@ -28,7 +28,7 @@ method requestStorage*(market: Market,
|
||||
method myRequests*(market: Market): Future[seq[RequestId]] {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
method mySlots*(market: Market, requestId: RequestId): Future[seq[SlotId]] {.base, async.} =
|
||||
method mySlots*(market: Market): Future[seq[SlotId]] {.base, async.} =
|
||||
raiseAssert("not implemented")
|
||||
|
||||
method getRequest*(market: Market,
|
||||
|
@ -89,11 +89,8 @@ proc load*(sales: Sales) {.async.} =
|
||||
|
||||
# TODO: restore availability from disk
|
||||
let requestIds = await market.myRequests()
|
||||
var slotIds: seq[SlotId]
|
||||
# TODO: this needs to be optimised
|
||||
for requestId in requestIds:
|
||||
let reqSlotIds = await market.mySlots(requestId)
|
||||
slotIds.add reqSlotIds
|
||||
let slotIds = await market.mySlots()
|
||||
|
||||
for slotId in slotIds:
|
||||
# TODO: this needs to be optimised
|
||||
if slot =? await market.getSlot(slotId):
|
||||
|
@ -74,7 +74,7 @@ method requestStorage*(market: MockMarket, request: StorageRequest) {.async.} =
|
||||
method myRequests*(market: MockMarket): Future[seq[RequestId]] {.async.} =
|
||||
return market.activeRequests[market.signer]
|
||||
|
||||
method mySlots*(market: MockMarket, requestId: RequestId): Future[seq[SlotId]] {.async.} =
|
||||
method mySlots*(market: MockMarket): Future[seq[SlotId]] {.async.} =
|
||||
return market.activeSlots[market.signer]
|
||||
|
||||
method getRequest(market: MockMarket,
|
||||
|
@ -82,10 +82,11 @@ ethersuite "Marketplace contracts":
|
||||
let requestEnd = await marketplace.requestEnd(request.id)
|
||||
await provider.advanceTimeTo(requestEnd.u256)
|
||||
let startBalance = await token.balanceOf(address)
|
||||
await marketplace.freeSlot(slotId)
|
||||
await storage.payoutSlot(request.id, 0.u256)
|
||||
let endBalance = await token.balanceOf(address)
|
||||
check endBalance == (startBalance + request.ask.duration * request.ask.reward)
|
||||
|
||||
|
||||
test "cannot mark proofs missing for cancelled request":
|
||||
await provider.advanceTimeTo(request.expiry + 1)
|
||||
switchAccount(client)
|
||||
|
Loading…
x
Reference in New Issue
Block a user