diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index 202c681..faba153 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -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 { diff --git a/contracts/Storage.sol b/contracts/Storage.sol index 9f6fbd6..4658905 100644 --- a/contracts/Storage.sol +++ b/contracts/Storage.sol @@ -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" ); } diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index c774d75..0a28692 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -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( diff --git a/test/Storage.test.js b/test/Storage.test.js index 9f56df8..fba232a 100644 --- a/test/Storage.test.js +++ b/test/Storage.test.js @@ -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 () { diff --git a/test/examples.js b/test/examples.js index 22b23ac..1e88077 100644 --- a/test/examples.js +++ b/test/examples.js @@ -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", diff --git a/test/ids.js b/test/ids.js index 56ba3ec..4455f8a 100644 --- a/test/ids.js +++ b/test/ids.js @@ -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) {