Skip to content

Commit f57d3c6

Browse files
committed
test(rightassetcustodian): setMaxAllowed
1 parent e982427 commit f57d3c6

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

contracts/access/AccessManager.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ contract AccessManager is Initializable, UUPSUpgradeable, AccessManagerUpgradeab
3737
// - GOV_ROLE: Represents decentralized community governance.
3838
// Decisions are made through collective voting mechanisms (e.g., token-weighted, quadratic).
3939
//
40-
// Group/Sub-DAO Based Roles:
41-
// - ADMIN_ROLE: Managed by a smart account or sub-DAO.
40+
// Group/Council Based Roles:
41+
// - ADMIN_ROLE: Managed by a smart account or council.
4242
// Handles protocol upgrades, pause mechanisms, and operational role assignments.
43-
// - MOD_ROLE: Managed by a smart account or sub-DAO.
43+
// - MOD_ROLE: Managed by a smart account or council.
4444
// Approves policy submissions and moderates hook operations.
45-
// - REF_ROLE: Managed by a smart account or sub-DAO.
45+
// - REF_ROLE: Managed by a smart account or council.
4646
// Participates in governance referenda for content curation and distributor selection.
4747
//
4848
// Individual/Contract Based Roles:
@@ -52,15 +52,15 @@ contract AccessManager is Initializable, UUPSUpgradeable, AccessManagerUpgradeab
5252
// content uploads without conventional verification.
5353

5454
/*
55-
GOV_ROLE (Community Governance)
55+
GOV_ROLE (Community Governance)
5656
57-
├── ADMIN_ROLE (Smart Account / Sub-DAO)
57+
├── ADMIN_ROLE (Smart Account / Council)
5858
│ │
59-
│ ├── MOD_ROLE (Smart Account / Sub-DAO)
59+
│ ├── MOD_ROLE (Smart Account / Council)
6060
│ │
61-
│ └── OPS_ROLE (Internal Contract Role)
61+
│ └── OPS_ROLE (Internal Contract Role)
6262
63-
├── REF_ROLE (Smart Account / Sub-DAO)
63+
├── REF_ROLE (Smart Account / Council)
6464
6565
├── VER_ROLE (Individual Trusted Creator)
6666
*/

contracts/core/interfaces/rights/IRightsAssetCustodian.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
// NatSpec format convention - https://docs.soliditylang.org/en/v0.5.10/natspec-format.html
33
pragma solidity 0.8.26;
44

5+
import { IRightsAssetCustodianManager } from "@synaps3/core/interfaces/rights/IRightsAssetCustodianManager.sol";
56
import { IRightsAssetCustodianVerifiable } from "@synaps3/core/interfaces/rights/IRightsAssetCustodianVerifiable.sol";
67
import { IRightsAssetCustodianRegistrable } from "@synaps3/core/interfaces/rights/IRightsAssetCustodianRegistrable.sol";
78

89
/// @title IRightsAssetCustodian
910
/// @notice Unified interface for verifying, retrieving, and managing custodial rights over assets.
1011
/// @dev This interface extends both `IRightsAssetCustodianVerifiable` (which enables querying custodianship status)
1112
/// and `IRightsAssetCustodianRegistrable` (which handles granting and revoking custodial rights).
12-
interface IRightsAssetCustodian is IRightsAssetCustodianVerifiable, IRightsAssetCustodianRegistrable {}
13+
interface IRightsAssetCustodian is
14+
IRightsAssetCustodianManager,
15+
IRightsAssetCustodianRegistrable,
16+
IRightsAssetCustodianVerifiable
17+
{
18+
19+
}

contracts/core/interfaces/rights/IRightsAssetCustodianRegistrable.sol

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ pragma solidity 0.8.26;
66
/// @notice Interface for registering and managing custodial rights over assets.
77
/// @dev This interface provides functions for granting and revoking custodial rights.
88
interface IRightsAssetCustodianRegistrable {
9+
910
/// @notice Assigns custodial rights over the caller's content to a specified custodian.
1011
/// @param custodian The address of the custodian to assign.
1112
function grantCustody(address custodian) external;
1213

1314
/// @notice Revokes custodial rights of a custodian for the caller's assets.
1415
/// @param custodian The address of the custodian to revoke custody from.
1516
function revokeCustody(address custodian) external;
16-
17-
/// @notice Sets a custom priority value for a specific custodian assigned to the caller.
18-
/// @dev Influences the weighting in the balancing algorithm used to select custodians.
19-
/// @param custodian The custodian whose priority is being set.
20-
/// @param priority The priority value to assign. Must be >= 1.
21-
function setPriority(address custodian, uint256 priority) external;
2217
}

contracts/core/interfaces/rights/IRightsAssetCustodianVerifiable.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface IRightsAssetCustodianVerifiable {
2525
/// @param custodian The custodian address to query.
2626
/// @return The number of holders currently assigned to the custodian.
2727
function getCustodyCount(address custodian) external view returns (uint256);
28-
28+
2929
/// @notice Calculates the weighted score of a custodian for a specific holder and currency.
3030
/// @dev Used to externally query the score that influences custodian selection.
3131
/// @param custodian The address of the custodian.

contracts/rights/RightsAssetCustodian.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ contract RightsAssetCustodian is Initializable, UUPSUpgradeable, AccessControlle
117117
_maxRedundancy = value;
118118
}
119119

120+
/// @notice Returns the maximum allowed number of custodians per holder.
121+
function getMaxAllowedRedundancy() external view returns (uint256) {
122+
return _maxRedundancy;
123+
}
124+
120125
/// @notice Revokes custodial rights of a custodian for the caller's assets.
121126
/// @param custodian The custodian to revoke custody from.
122127
function revokeCustody(address custodian) external {

test/rights/RightAssetCustodian.t.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: MIT
66
pragma solidity 0.8.26;
77

8+
import { IRightsAssetCustodianManager } from "contracts/core/interfaces/rights/IRightsAssetCustodianManager.sol";
89
import { IRightsAssetCustodianVerifiable } from "contracts/core/interfaces/rights/IRightsAssetCustodianVerifiable.sol";
910
import { IRightsAssetCustodianRegistrable } from "contracts/core/interfaces/rights/IRightsAssetCustodianRegistrable.sol";
1011
import { ICustodianVerifiable } from "contracts/core/interfaces/custody/ICustodianVerifiable.sol";
@@ -24,6 +25,23 @@ contract RightAssetCustodianTest is CustodianShared {
2425
deployRightsAssetCustodian();
2526
}
2627

28+
function test_SetMaxAllowedRedundancy_ValidValue() public {
29+
vm.startPrank(admin);
30+
uint256 newMaxRedundancy = 5;
31+
IRightsAssetCustodianManager(rightAssetCustodian).setMaxAllowedRedundancy(newMaxRedundancy);
32+
uint256 maxRedundancy = IRightsAssetCustodianManager(rightAssetCustodian).getMaxAllowedRedundancy();
33+
assertEq(maxRedundancy, newMaxRedundancy, "Max allowed redundancy should be updated");
34+
vm.stopPrank();
35+
}
36+
37+
function test_SetMaxAllowedRedundancy_RevertIf_NotAuthorized() public {
38+
vm.startPrank(user);
39+
uint256 newMaxRedundancy = 5;
40+
vm.expectRevert(abi.encodeWithSignature("AccessManagedUnauthorized(address)", user));
41+
IRightsAssetCustodianManager(rightAssetCustodian).setMaxAllowedRedundancy(newMaxRedundancy);
42+
vm.stopPrank();
43+
}
44+
2745
function test_GrantCustody_ValidCustodian() public {
2846
vm.prank(user);
2947
IRightsAssetCustodianRegistrable(rightAssetCustodian).grantCustody(custodian);

0 commit comments

Comments
 (0)