[marketplace] Rename maxPrice -> reward

This commit is contained in:
Mark Spanbroek 2022-06-13 13:19:33 +02:00 committed by markspanbroek
parent 8d7b7aed1d
commit 389f5299d6
6 changed files with 15 additions and 15 deletions

View File

@ -38,9 +38,9 @@ contract Marketplace is Collateral, Proofs {
_createLock(id, request.expiry);
funds.received += request.ask.maxPrice;
funds.balance += request.ask.maxPrice;
transferFrom(msg.sender, request.ask.maxPrice);
funds.received += request.ask.reward;
funds.balance += request.ask.reward;
transferFrom(msg.sender, request.ask.reward);
emit StorageRequested(id, request.ask);
}
@ -102,7 +102,7 @@ contract Marketplace is Collateral, Proofs {
uint256 size; // size of requested storage in number of bytes
uint256 duration; // how long content should be stored (in seconds)
uint256 proofProbability; // how often storage proofs are required
uint256 maxPrice; // maximum price client will pay (in number of tokens)
uint256 reward; // reward that the client will pay (in number of tokens)
}
struct Content {

View File

@ -44,7 +44,7 @@ contract Storage is Collateral, Marketplace {
require(block.timestamp > proofEnd(id), "Contract has not ended yet");
contractFinished[id] = true;
require(
token.transfer(_host(id), _request(id).ask.maxPrice),
token.transfer(_host(id), _request(id).ask.reward),
"Payment failed"
);
}

View File

@ -57,7 +57,7 @@ describe("Marketplace", function () {
})
it("emits event when storage is requested", async function () {
await token.approve(marketplace.address, request.ask.maxPrice)
await token.approve(marketplace.address, request.ask.reward)
await expect(marketplace.requestStorage(request))
.to.emit(marketplace, "StorageRequested")
.withArgs(requestId(request), askToArray(request.ask))
@ -65,14 +65,14 @@ describe("Marketplace", function () {
it("rejects request with invalid client address", async function () {
let invalid = { ...request, client: host.address }
await token.approve(marketplace.address, invalid.ask.maxPrice)
await token.approve(marketplace.address, invalid.ask.reward)
await expect(marketplace.requestStorage(invalid)).to.be.revertedWith(
"Invalid client address"
)
})
it("rejects request with insufficient payment", async function () {
let insufficient = request.ask.maxPrice - 1
let insufficient = request.ask.reward - 1
await token.approve(marketplace.address, insufficient)
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
"ERC20: insufficient allowance"
@ -80,7 +80,7 @@ describe("Marketplace", function () {
})
it("rejects resubmission of request", async function () {
await token.approve(marketplace.address, request.ask.maxPrice * 2)
await token.approve(marketplace.address, request.ask.reward * 2)
await marketplace.requestStorage(request)
await expect(marketplace.requestStorage(request)).to.be.revertedWith(
"Request already exists"
@ -93,7 +93,7 @@ describe("Marketplace", function () {
beforeEach(async function () {
switchAccount(client)
await token.approve(marketplace.address, request.ask.maxPrice)
await token.approve(marketplace.address, request.ask.reward)
await marketplace.requestStorage(request)
switchAccount(host)
await token.approve(marketplace.address, collateral)
@ -150,7 +150,7 @@ describe("Marketplace", function () {
it("is rejected when request is expired", async function () {
switchAccount(client)
let expired = { ...request, expiry: now() - hours(1) }
await token.approve(marketplace.address, request.ask.maxPrice)
await token.approve(marketplace.address, request.ask.reward)
await marketplace.requestStorage(expired)
switchAccount(host)
await expect(

View File

@ -40,7 +40,7 @@ describe("Storage", function () {
id = requestId(request)
switchAccount(client)
await token.approve(storage.address, request.ask.maxPrice)
await token.approve(storage.address, request.ask.reward)
await storage.requestStorage(request)
switchAccount(host)
await token.approve(storage.address, collateralAmount)
@ -74,7 +74,7 @@ describe("Storage", function () {
const startBalance = await token.balanceOf(host.address)
await storage.finishContract(id)
const endBalance = await token.balanceOf(host.address)
expect(endBalance - startBalance).to.equal(request.ask.maxPrice)
expect(endBalance - startBalance).to.equal(request.ask.reward)
})
it("is only allowed when the contract has started", async function () {

View File

@ -8,7 +8,7 @@ const exampleRequest = () => ({
size: 1 * 1024 * 1024 * 1024, // 1 Gigabyte
duration: hours(10),
proofProbability: 4, // require a proof roughly once every 4 periods
maxPrice: 84,
reward: 84,
},
content: {
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",

View File

@ -12,7 +12,7 @@ function requestId(request) {
}
function askToArray(ask) {
return [ask.size, ask.duration, ask.proofProbability, ask.maxPrice]
return [ask.size, ask.duration, ask.proofProbability, ask.reward]
}
function erasureToArray(erasure) {