Skip to content

Commit

Permalink
remove multi-whitelist method
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Oct 18, 2024
1 parent 02f3f55 commit 507a74d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 53 deletions.
15 changes: 0 additions & 15 deletions contracts/network/BancorNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -925,21 +925,6 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
_addToWhitelist(addr);
}

/**
* @dev adds multiple addresses to the fee exemption whitelist
*
* requirements:
*
* - the caller must be the admin of the contract
*/
function addAddressesToWhitelist(address[] calldata addrs) external onlyAdmin {
uint256 length = addrs.length;

for (uint256 i = 0; i < length; ++i) {
_addToWhitelist(addrs[i]);
}
}

/**
* @dev removes an address from the fee exemption whitelist
*
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const config: HardhatUserConfig = {
settings: {
optimizer: {
enabled: true,
runs: 180
runs: 200
},
metadata: {
bytecodeHash: 'none'
Expand Down
37 changes: 0 additions & 37 deletions test/network/BancorNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3378,43 +3378,6 @@ describe('BancorNetwork', () => {
expect(await network.isWhitelisted(user1.address)).to.be.true;
expect(await network.feeExemptionWhitelist()).to.include(user1.address);
});

it('should revert when a non-admin attempts to add addresses', async () => {
await expect(
network.connect(nonOwner).addAddressesToWhitelist([user1.address])
).to.be.revertedWithError('AccessDenied');
});

it('should revert when adding invalid addresses', async () => {
await expect(network.addAddressesToWhitelist([ZERO_ADDRESS])).to.be.revertedWithError(
'InvalidExternalAddress'
);
});

it('should revert when adding already whitelisted addresses in the same transaction', async () => {
await expect(network.addAddressesToWhitelist([user1.address, user1.address])).to.be.revertedWithError(
'AlreadyExists'
);
});

it('should revert when adding already whitelisted addresses in different transactions', async () => {
await network.addAddressesToWhitelist([user1.address]);
await expect(network.addAddressesToWhitelist([user1.address])).to.be.revertedWithError('AlreadyExists');
});

it('should whitelist addresses', async () => {
expect(await network.isWhitelisted(user1.address)).to.be.false;
expect(await network.isWhitelisted(user2.address)).to.be.false;
expect(await network.feeExemptionWhitelist()).not.to.have.members([user1.address, user2.address]);

const res = await network.addAddressesToWhitelist([user1.address, user2.address]);
await expect(res).to.emit(network, 'AddressAddedToWhitelist').withArgs(user1.address);
await expect(res).to.emit(network, 'AddressAddedToWhitelist').withArgs(user2.address);

expect(await network.isWhitelisted(user1.address)).to.be.true;
expect(await network.isWhitelisted(user2.address)).to.be.true;
expect(await network.feeExemptionWhitelist()).to.have.members([user1.address, user2.address]);
});
});

describe('removing', () => {
Expand Down

0 comments on commit 507a74d

Please sign in to comment.