diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index ae01a31..e406cd4 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -150,7 +150,7 @@ contract Marketplace is Proofs, Validation, StateRetrieval, Endian { _addToMySlots(slot.host, slotId); uint16 groupIdx = _getValidatorIndex(slotId); - _addToValidationSlots(groupIdx, slotId); + _addToMyValidationSlots(groupIdx, slotId); emit SlotFilled(requestId, slotIndex); if (context.slotsFilled == request.ask.slots) { @@ -173,7 +173,7 @@ contract Marketplace is Proofs, Validation, StateRetrieval, Endian { } else if (state == SlotState.Failed) { _removeFromMySlots(msg.sender, slotId); uint16 groupIdx = _getValidatorIndex(slotId); - _removeFromValidationSlots(groupIdx, slotId); + _removeFromMyValidationSlots(groupIdx, slotId); } else if (state == SlotState.Filled) { _forciblyFreeSlot(slotId); } @@ -242,7 +242,7 @@ contract Marketplace is Proofs, Validation, StateRetrieval, Endian { _removeFromMySlots(slot.host, slotId); uint16 groupIdx = _getValidatorIndex(slotId); - _removeFromValidationSlots(groupIdx, slotId); + _removeFromMyValidationSlots(groupIdx, slotId); uint256 slotIndex = slot.slotIndex; delete _slots[slotId]; @@ -276,7 +276,7 @@ contract Marketplace is Proofs, Validation, StateRetrieval, Endian { _removeFromMySlots(slot.host, slotId); uint16 groupIdx = _getValidatorIndex(slotId); - _removeFromValidationSlots(groupIdx, slotId); + _removeFromMyValidationSlots(groupIdx, slotId); uint256 amount = _requests[requestId].pricePerSlot() + slot.currentCollateral; @@ -292,7 +292,7 @@ contract Marketplace is Proofs, Validation, StateRetrieval, Endian { Slot storage slot = _slots[slotId]; _removeFromMySlots(slot.host, slotId); uint16 groupIdx = _getValidatorIndex(slotId); - _removeFromValidationSlots(groupIdx, slotId); + _removeFromMyValidationSlots(groupIdx, slotId); uint256 amount = _expiryPayoutAmount(requestId, slot.filledAt) + slot.currentCollateral; diff --git a/contracts/StateRetrieval.sol b/contracts/StateRetrieval.sol index 6c72e0b..ea47299 100644 --- a/contracts/StateRetrieval.sol +++ b/contracts/StateRetrieval.sol @@ -20,7 +20,7 @@ contract StateRetrieval { return _slotsPerHost[msg.sender].values().toSlotIds(); } - function validationSlots( + function myValidationSlots( uint16 groupIdx ) public view returns (SlotId[] memory) { return _slotsPerValidator[groupIdx].values().toSlotIds(); @@ -38,7 +38,7 @@ contract StateRetrieval { _slotsPerHost[host].add(SlotId.unwrap(slotId)); } - function _addToValidationSlots(uint16 groupIdx, SlotId slotId) internal { + function _addToMyValidationSlots(uint16 groupIdx, SlotId slotId) internal { _slotsPerValidator[groupIdx].add(SlotId.unwrap(slotId)); } @@ -50,7 +50,7 @@ contract StateRetrieval { _slotsPerHost[host].remove(SlotId.unwrap(slotId)); } - function _removeFromValidationSlots(uint16 groupIdx, SlotId slotId) internal { + function _removeFromMyValidationSlots(uint16 groupIdx, SlotId slotId) internal { _slotsPerValidator[groupIdx].remove(SlotId.unwrap(slotId)); } } diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index 91356b3..3a29734 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -1129,9 +1129,9 @@ describe("Marketplace", function () { let slot1 = { ...slot, index: slot.index + 1 } await token.approve(marketplace.address, request.ask.collateral) await marketplace.fillSlot(slot.request, slot1.index, proof) - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.have.members([slotId(slot), slotId(slot1)]) }) @@ -1142,9 +1142,9 @@ describe("Marketplace", function () { await marketplace.fillSlot(slot.request, slot1.index, proof) await token.approve(marketplace.address, request.ask.collateral) await marketplace.freeSlot(slotId(slot)) - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.not.have.members([slotId(slot)]) expect(allSlots).to.have.members([slotId(slot1)]) }) @@ -1157,9 +1157,9 @@ describe("Marketplace", function () { await marketplace.fillSlot(slot.request, slot1.index, proof) await waitUntilCancelled(request) await mine() - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.have.members([slotId(slot), slotId(slot1)]) }) @@ -1167,9 +1167,9 @@ describe("Marketplace", function () { await waitUntilStarted(marketplace, request, proof, token) await waitUntilFinished(marketplace, requestId(request)) await marketplace.freeSlot(slotId(slot)) - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.not.contain(slotId(slot)) }) @@ -1177,9 +1177,9 @@ describe("Marketplace", function () { await marketplace.fillSlot(slot.request, slot.index, proof) await waitUntilCancelled(request) await marketplace.freeSlot(slotId(slot)) - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.not.contain(slotId(slot)) }) @@ -1187,9 +1187,9 @@ describe("Marketplace", function () { await waitUntilStarted(marketplace, request, proof, token) await waitUntilSlotFailed(marketplace, request, slot) await marketplace.freeSlot(slotId(slot)) - const allSlots = (await marketplace.validationSlots(0)) - .concat(await marketplace.validationSlots(1)) - .concat(await marketplace.validationSlots(2)) + const allSlots = (await marketplace.myValidationSlots(0)) + .concat(await marketplace.myValidationSlots(1)) + .concat(await marketplace.myValidationSlots(2)) expect(allSlots).to.not.contain(slotId(slot)) }) })