From 3f91fab1fbc948430834fa752cb8254da2dd85a2 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 16 Sep 2024 00:47:02 +0200 Subject: [PATCH] fix: change role for functions access --- contracts/TreasuryRootstockCollective.sol | 8 ++++---- test/Treasury.test.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/TreasuryRootstockCollective.sol b/contracts/TreasuryRootstockCollective.sol index ad1ae9a..98705a8 100644 --- a/contracts/TreasuryRootstockCollective.sol +++ b/contracts/TreasuryRootstockCollective.sol @@ -123,10 +123,10 @@ contract TreasuryRootstockCollective is AccessControl, ReentrancyGuard, ITreasur /** * @dev Add to whitelist a new ERC20 token - * requires guardian role + * requires executor role * @param token ERC20 token */ - function addToWhitelist(address token) external onlyRole(GUARDIAN_ROLE) { + function addToWhitelist(address token) external onlyRole(EXECUTOR_ROLE) { _addToWhitelist(token); } @@ -141,10 +141,10 @@ contract TreasuryRootstockCollective is AccessControl, ReentrancyGuard, ITreasur /** * @dev Remove from whitelist an ERC20 token - * requires guardian role + * requires executor role * @param token ERC20 token */ - function removeFromWhitelist(address token) external onlyRole(GUARDIAN_ROLE) { + function removeFromWhitelist(address token) external onlyRole(EXECUTOR_ROLE) { _removeFromWhitelist(token); } diff --git a/test/Treasury.test.ts b/test/Treasury.test.ts index d9b4bb7..f225145 100644 --- a/test/Treasury.test.ts +++ b/test/Treasury.test.ts @@ -29,11 +29,11 @@ describe('Treasury Contract', () => { before(async () => { ;;[deployer, owner, beneficiary, guardian, collector, token1, token2, token3] = await ethers.getSigners() ;({ stRIF, rif, treasury, timelock } = await loadFixture(deployContracts)) - await treasury.addToWhitelist(rif) GuardianRole = await treasury.GUARDIAN_ROLE() ExecutorRole = await treasury.EXECUTOR_ROLE() const grantRoleTx = await treasury.grantRole(ExecutorRole, deployer) await grantRoleTx.wait() + await treasury.addToWhitelist(rif) }) describe('Withdraw token and RBTC to any account', () => { @@ -175,21 +175,21 @@ describe('Treasury Contract', () => { expect(flag).to.equal(true) }) - it('Only account with Guardian Role can add new token to whitelist', async () => { + it('Only account with Executor Role can add new token to whitelist', async () => { await treasury.connect(deployer).removeFromWhitelist(stRIF) expect(await treasury.whitelist(stRIF)).to.equal(false) const sentTx = treasury.connect(beneficiary).addToWhitelist(stRIF) await expect(sentTx) .to.be.revertedWithCustomError(treasury, 'AccessControlUnauthorizedAccount') - .withArgs(beneficiary.address, GuardianRole) + .withArgs(beneficiary.address, ExecutorRole) }) - it('Only account with Guardian Role can remove a token to whitelist', async () => { + it('Only account with Executor Role can remove a token to whitelist', async () => { const sentTx = treasury.connect(beneficiary).removeFromWhitelist(rif) await expect(sentTx) .to.be.revertedWithCustomError(treasury, 'AccessControlUnauthorizedAccount') - .withArgs(beneficiary.address, GuardianRole) + .withArgs(beneficiary.address, ExecutorRole) expect(await treasury.whitelist(rif)).to.equal(true) })