Skip to content

Commit eb9ffd4

Browse files
authored
Merge pull request #344 from vzotova/tg-roles
Update permissions related to TG in subscription and coordinator
2 parents 98792f9 + c321bac commit eb9ffd4

File tree

5 files changed

+16
-21
lines changed

5 files changed

+16
-21
lines changed

contracts/contracts/coordination/Coordinator.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable
9393
}
9494

9595
bytes32 public constant TREASURY_ROLE = keccak256("TREASURY_ROLE");
96+
bytes32 public constant FEE_MODEL_MANAGER_ROLE = keccak256("FEE_MODEL_MANAGER_ROLE");
9697

9798
ITACoChildApplication public immutable application;
9899
uint96 private immutable minAuthorization; // TODO use child app for checking eligibility
@@ -651,7 +652,7 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable
651652
}
652653
}
653654

654-
function approveFeeModel(IFeeModel feeModel) external onlyRole(TREASURY_ROLE) {
655+
function approveFeeModel(IFeeModel feeModel) external onlyRole(FEE_MODEL_MANAGER_ROLE) {
655656
require(!feeModelsRegistry[feeModel], "Fee model already approved");
656657
feeModelsRegistry[feeModel] = true;
657658
emit FeeModelApproved(feeModel);

contracts/contracts/coordination/subscription/StandardSubscription.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ contract StandardSubscription is EncryptorSlotsSubscription, Initializable, Owna
248248

249249
/**
250250
* @notice Withdraws the contract balance to the treasury
251-
* @param amount The amount to withdraw
252251
*/
253-
function withdrawToTreasury(uint256 amount) external onlyOwner {
254-
require(amount <= feeToken.balanceOf(address(this)), "Insufficient balance available");
255-
feeToken.safeTransfer(msg.sender, amount);
256-
emit WithdrawalToTreasury(msg.sender, amount);
252+
function withdrawToTreasury() external {
253+
uint256 amount = feeToken.balanceOf(address(this));
254+
require(amount > 0, "Insufficient balance available");
255+
feeToken.safeTransfer(owner(), amount);
256+
emit WithdrawalToTreasury(owner(), amount);
257257
}
258258

259259
function processRitualPayment(

tests/test_coordinator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ def fee_model(project, deployer, coordinator, erc20, treasury):
8181
contract = project.FlatRateFeeModel.deploy(
8282
coordinator.address, erc20.address, FEE_RATE, sender=deployer
8383
)
84-
coordinator.grantRole(coordinator.TREASURY_ROLE(), treasury, sender=deployer)
84+
coordinator.grantRole(coordinator.FEE_MODEL_MANAGER_ROLE(), treasury, sender=deployer)
8585
coordinator.approveFeeModel(contract.address, sender=treasury)
86+
coordinator.grantRole(coordinator.TREASURY_ROLE(), treasury, sender=deployer)
8687
return contract
8788

8889

tests/test_global_allow_list.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from enum import IntEnum
32

43
import ape
54
import pytest
@@ -80,7 +79,7 @@ def fee_model(project, deployer, coordinator, erc20, treasury):
8079
contract = project.FlatRateFeeModel.deploy(
8180
coordinator.address, erc20.address, FEE_RATE, sender=deployer
8281
)
83-
coordinator.grantRole(coordinator.TREASURY_ROLE(), treasury, sender=deployer)
82+
coordinator.grantRole(coordinator.FEE_MODEL_MANAGER_ROLE(), treasury, sender=deployer)
8483
coordinator.approveFeeModel(contract.address, sender=treasury)
8584
return contract
8685

@@ -120,12 +119,12 @@ def initiate_ritual(coordinator, fee_model, erc20, authority, nodes, allow_logic
120119
return authority, tx
121120

122121

123-
# Using normal and upgradeable versions of global_allow_list.
122+
# Using normal and upgradeable versions of global_allow_list.
124123
# Since both are fixtures, we need a small workaround to use them as parameters.
125-
# See https://engineeringfordatascience.com/posts/pytest_fixtures_with_parameterize/#using-requestgetfixturevalue-
124+
# See https://engineeringfordatascience.com/posts/pytest_fixtures_with_parameterize/#using-requestgetfixturevalue-
126125
@pytest.mark.parametrize(
127-
'allow_list_contract',
128-
('global_allow_list', 'upgradeable_global_allow_list'),
126+
"allow_list_contract",
127+
("global_allow_list", "upgradeable_global_allow_list"),
129128
)
130129
def test_authorize_using_global_allow_list(
131130
coordinator, nodes, deployer, initiator, erc20, fee_model, allow_list_contract, request

tests/test_standard_subscription.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,13 @@ def test_withdraw(erc20, subscription, adopter, adopter_setter, treasury, global
356356
erc20.approve(subscription.address, ERC20_SUPPLY, sender=adopter)
357357
subscription.setAdopter(adopter, sender=adopter_setter)
358358

359-
with ape.reverts():
360-
subscription.withdrawToTreasury(1, sender=adopter)
361-
362359
with ape.reverts("Insufficient balance available"):
363-
subscription.withdrawToTreasury(1, sender=treasury)
360+
subscription.withdrawToTreasury(sender=adopter)
364361

365362
subscription.payForSubscription(0, sender=adopter)
366363

367364
current_base_fee = base_fee(0)
368-
with ape.reverts("Insufficient balance available"):
369-
subscription.withdrawToTreasury(current_base_fee + 1, sender=treasury)
370-
371-
tx = subscription.withdrawToTreasury(current_base_fee, sender=treasury)
365+
tx = subscription.withdrawToTreasury(sender=adopter)
372366
assert erc20.balanceOf(treasury) == current_base_fee
373367
assert erc20.balanceOf(subscription.address) == 0
374368

0 commit comments

Comments
 (0)