diff --git a/contracts/InternalMarket/InternalMarket.sol b/contracts/InternalMarket/InternalMarket.sol index 9a5bb9e..8ecff95 100644 --- a/contracts/InternalMarket/InternalMarket.sol +++ b/contracts/InternalMarket/InternalMarket.sol @@ -50,6 +50,13 @@ contract InternalMarket is Initializable, HasRole, InternalMarketBase { * @param amount The amount of tokens to offer for sale. */ function makeOffer(uint256 amount) public virtual { + require( + _shareholderRegistry.isAtLeast( + _shareholderRegistry.CONTRIBUTOR_STATUS(), + msg.sender + ), + "InternalMarket: only contributors can make offers" + ); _makeOffer(_msgSender(), amount); } diff --git a/test/Integration.ts b/test/Integration.ts index 2960394..e50b1f2 100644 --- a/test/Integration.ts +++ b/test/Integration.ts @@ -679,6 +679,11 @@ describe("Integration", async () => { "Resolution: account cannot vote" ); + // user3 cannot offer tokens + await expect(internalMarket.connect(user3).makeOffer(10)).revertedWith( + "InternalMarket: only contributors can make offers" + ); + // ... and finally the world is saved. expect(await resolutionManager.getResolutionResult(resolutionId)).to.be .true; diff --git a/test/InternalMarket.ts b/test/InternalMarket.ts index 2e9f669..16e6b37 100644 --- a/test/InternalMarket.ts +++ b/test/InternalMarket.ts @@ -202,6 +202,13 @@ describe("InternalMarket", async () => { ); }); + it("should revert when called by a non-contributor", async () => { + registry.isAtLeast.returns(false); + await expect(internalMarket.makeOffer(1000)).revertedWith( + "InternalMarket: only contributors can make offers" + ); + }); + describe("redeem", async () => { describe("with some unlocked tokens", async () => { beforeEach(async () => { diff --git a/test/RedemptionController.ts b/test/RedemptionController.ts index 6957209..0a1d47c 100644 --- a/test/RedemptionController.ts +++ b/test/RedemptionController.ts @@ -202,7 +202,7 @@ describe("RedemptionController", () => { ); }); - describe.only("when 10 tokens are redeemable", async () => { + describe("when 10 tokens are redeemable", async () => { beforeEach(async () => { await redemptionController.afterMint(account.address, 10); await redemptionController.afterOffer(account.address, 10);