Skip to content

Commit

Permalink
fix: change role for functions access
Browse files Browse the repository at this point in the history
  • Loading branch information
shenshin committed Sep 15, 2024
1 parent fc48e59 commit 3f91fab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions contracts/TreasuryRootstockCollective.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
10 changes: 5 additions & 5 deletions test/Treasury.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Treasury Contract', () => {
before(async () => {
;;[deployer, owner, beneficiary, guardian, collector, token1, token2, token3] = await ethers.getSigners()

Check warning on line 30 in test/Treasury.test.ts

View workflow job for this annotation

GitHub Actions / test

Delete `;`
;({ 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', () => {
Expand Down Expand Up @@ -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)
})

Expand Down

0 comments on commit 3f91fab

Please sign in to comment.