feat: update StorageRequest params emitted
Params emitted were not suitable for sorting the RequestQueue, but after this change, should be.
This commit is contained in:
parent
8b39ef8f4a
commit
440cc398a3
|
@ -65,7 +65,10 @@ contract Marketplace is Proofs, StateRetrieval {
|
|||
_funds.balance += amount;
|
||||
_transferFrom(msg.sender, amount);
|
||||
|
||||
emit StorageRequested(id, request.ask);
|
||||
emit StorageRequested(id, Requested(request.ask.collateral,
|
||||
request.expiry,
|
||||
request.content.erasure.totalChunks,
|
||||
request.ask.slots));
|
||||
}
|
||||
|
||||
function fillSlot(
|
||||
|
@ -297,7 +300,7 @@ contract Marketplace is Proofs, StateRetrieval {
|
|||
require(token.transferFrom(sender, receiver, amount), "Transfer failed");
|
||||
}
|
||||
|
||||
event StorageRequested(RequestId requestId, Ask ask);
|
||||
event StorageRequested(RequestId requestId, Requested requested);
|
||||
event RequestFulfilled(RequestId indexed requestId);
|
||||
event RequestFailed(RequestId indexed requestId);
|
||||
event SlotFilled(
|
||||
|
|
|
@ -4,6 +4,13 @@ pragma solidity ^0.8.8;
|
|||
type RequestId is bytes32;
|
||||
type SlotId is bytes32;
|
||||
|
||||
struct Requested {
|
||||
uint256 collateral;
|
||||
uint256 expiry;
|
||||
uint64 totalChunks;
|
||||
uint64 slots;
|
||||
}
|
||||
|
||||
struct Request {
|
||||
address client;
|
||||
Ask ask;
|
||||
|
|
|
@ -5,7 +5,7 @@ const { BigNumber } = ethers
|
|||
const { expect } = require("chai")
|
||||
const { exampleConfiguration, exampleRequest } = require("./examples")
|
||||
const { periodic, hours } = require("./time")
|
||||
const { requestId, slotId, askToArray } = require("./ids")
|
||||
const { requestId, slotId, requestedToArray } = require("./ids")
|
||||
const {
|
||||
RequestState,
|
||||
SlotState,
|
||||
|
@ -81,9 +81,13 @@ describe("Marketplace", function () {
|
|||
|
||||
it("emits event when storage is requested", async function () {
|
||||
await token.approve(marketplace.address, price(request))
|
||||
console.log("collateral", request.ask.collateral)
|
||||
console.log("expiry", request.expiry)
|
||||
console.log("totalChunks", request.content.erasure.totalChunks)
|
||||
console.log("slots", request.ask.slots)
|
||||
await expect(marketplace.requestStorage(request))
|
||||
.to.emit(marketplace, "StorageRequested")
|
||||
.withArgs(requestId(request), askToArray(request.ask))
|
||||
.withArgs(requestId(request), requestedToArray(request))
|
||||
})
|
||||
|
||||
it("allows retrieval of request details", async function () {
|
||||
|
|
|
@ -23,6 +23,13 @@ function askToArray(ask) {
|
|||
]
|
||||
}
|
||||
|
||||
function requestedToArray(request) {
|
||||
return [request.ask.collateral,
|
||||
request.expiry,
|
||||
request.content.erasure.totalChunks,
|
||||
request.ask.slots]
|
||||
}
|
||||
|
||||
function erasureToArray(erasure) {
|
||||
return [erasure.totalChunks]
|
||||
}
|
||||
|
@ -59,4 +66,5 @@ module.exports = {
|
|||
slotId,
|
||||
requestToArray,
|
||||
askToArray,
|
||||
requestedToArray
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue