Skip to content

Commit

Permalink
chore: move eoa to blacklist and update submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMaharishi committed Jun 2, 2022
1 parent e7eefe9 commit 0fb7810
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
24 changes: 12 additions & 12 deletions contracts/AuraLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,12 @@ contract AuraLocker is ReentrancyGuard, Ownable, IAuraLocker {
}

modifier notBlacklisted(address _sender, address _receiver) {
uint256 csS;
uint256 csR;
// solhint-disable-next-line no-inline-assembly
assembly {
csS := extcodesize(_sender)
csR := extcodesize(_receiver)
}
if (csS != 0) {
require(!blacklist[_sender], "blacklisted");
}
if (csR != 0) {
require(_sender == _receiver || !blacklist[_receiver], "blacklisted");
require(!blacklist[_sender], "blacklisted");

if (_sender != _receiver) {
require(!blacklist[_receiver], "blacklisted");
}

_;
}

Expand All @@ -211,6 +204,13 @@ contract AuraLocker is ReentrancyGuard, Ownable, IAuraLocker {
****************************************/

function modifyBlacklist(address _account, bool _blacklisted) external onlyOwner {
uint256 cs;
// solhint-disable-next-line no-inline-assembly
assembly {
cs := extcodesize(_account)
}
require(cs != 0, "Must be contract");

blacklist[_account] = _blacklisted;
emit BlacklistModified(_account, _blacklisted);
}
Expand Down
2 changes: 1 addition & 1 deletion convex-platform
Submodule convex-platform updated 0 files
33 changes: 21 additions & 12 deletions test/AuraLocker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,29 @@ describe("AuraLocker", () => {
await lockor.connect(alice).lock(simpleToExactAmount(10));
await lockor.connect(alice).lockFor(aliceAddress, simpleToExactAmount(10));
});
it("allows blacklisting", async () => {
const tx = await auraLocker.connect(accounts[7]).modifyBlacklist(aliceAddress, true);
await expect(tx).to.emit(auraLocker, "BlacklistModified").withArgs(aliceAddress, true);
expect(await auraLocker.blacklist(aliceAddress)).eq(true);
it("allows blacklisting of contracts", async () => {
const tx = await auraLocker.connect(accounts[7]).modifyBlacklist(lockor.address, true);
await expect(tx).to.emit(auraLocker, "BlacklistModified").withArgs(lockor.address, true);
expect(await auraLocker.blacklist(lockor.address)).eq(true);
});
it("still allows blacklisted EOA's to lock", async () => {
it("blocks contracts from depositing when they are blacklisted", async () => {
await expect(lockor.connect(alice).lockFor(bobAddress, simpleToExactAmount(10))).to.be.revertedWith(
"blacklisted",
);
});
it("blocks users from depositing for blacklisted contracts", async () => {
await expect(auraLocker.connect(alice).lock(lockor.address, simpleToExactAmount(10))).to.be.revertedWith(
"blacklisted",
);
});
it("doesn't allow blacklisting of EOA's", async () => {
await expect(auraLocker.connect(accounts[7]).modifyBlacklist(aliceAddress, true)).to.be.revertedWith(
"Must be contract",
);
expect(await auraLocker.blacklist(aliceAddress)).eq(false);
await auraLocker.connect(alice).lock(aliceAddress, simpleToExactAmount(10));
});
it("blocks contracts from depositing for a blacklist smart contract", async () => {
it("blocks contracts from depositing for a blacklisted smart contract", async () => {
const mockToken = await deployContract<MockERC20>(
hre,
new MockERC20__factory(deployer),
Expand All @@ -529,17 +543,12 @@ describe("AuraLocker", () => {
{},
false,
);
await auraLocker.connect(accounts[7]).modifyBlacklist(lockor.address, false);
await auraLocker.connect(accounts[7]).modifyBlacklist(mockToken.address, true);
await expect(lockor.connect(alice).lockFor(mockToken.address, simpleToExactAmount(10))).to.be.revertedWith(
"blacklisted",
);
});
it("blocks contracts from depositing when they are blacklisted", async () => {
await auraLocker.connect(accounts[7]).modifyBlacklist(lockor.address, true);
await expect(lockor.connect(alice).lockFor(bobAddress, simpleToExactAmount(10))).to.be.revertedWith(
"blacklisted",
);
});
});

context("testing edge scenarios", () => {
Expand Down

0 comments on commit 0fb7810

Please sign in to comment.