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:
Eric Mastro 2023-06-13 17:13:34 +10:00
parent 8b39ef8f4a
commit 440cc398a3
No known key found for this signature in database
4 changed files with 26 additions and 4 deletions

View File

@ -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(

View File

@ -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;

View File

@ -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 () {

View File

@ -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
}