Skip to content

Commit

Permalink
Merge pull request #24 from TogetherCrew/feat/close-23
Browse files Browse the repository at this point in the history
close #23
  • Loading branch information
mehdi-torabiv authored Jun 6, 2024
2 parents 153b6a4 + 12570b3 commit 749dcdf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions contracts/Engagement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ contract EngagementContract is IEngagement, ERC1155, AccessControl {
uint tokenId,
uint amount
) external override {
if (account != msg.sender) {
revert NotAllowed(account, tokenId);
}
_burn(account, tokenId, 1);
emit Burn(account, tokenId, 1);
}
Expand Down
1 change: 1 addition & 0 deletions contracts/IEngagement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface IEngagement {

error NotFound(uint tokenId);
error MintLimit(address account, uint tokenId);
error NotAllowed(address account, uint tokenId);

function counter() external view returns (uint);

Expand Down
17 changes: 16 additions & 1 deletion test/engagements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe("Engage", function () {
}
);
});
describe("Success", () => {
describe("Success", async function () {
it("Should have an account balance of 0", async function () {
const balance1 = await contract.read.balanceOf([
getAddress(otherAccount.account.address),
Expand Down Expand Up @@ -281,6 +281,21 @@ describe("Engage", function () {
);
});
});
describe("Revert", async function () {
it("Should revert with NotAllowed (msg.sender != account)", async function () {
await expect(
contract.write.burn([
getAddress(otherAccount.account.address),
tokenId,
amount,
])
).to.be.rejectedWith(
`NotAllowed("${getAddress(
otherAccount.account.address
)}", ${tokenId})`
);
});
});
});
});
});

0 comments on commit 749dcdf

Please sign in to comment.