Skip to content

Commit 6ab1cb6

Browse files
authored
Merge pull request #20 from VenusProtocol/governance/access-control
add integration docs on ACM
2 parents 3ab0fb2 + 89bb672 commit 6ab1cb6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Governance/Access Control Manager.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ For Admin roles a null address is hashed in place of the contract address (`kecc
2222

2323
In the previous example, giving account B the admin role, account B will have permissions to call the bar() function on any contract that is guarded by ACM, not only contract A.
2424

25+
### Protocol Integration
26+
All restricted functions in Venus Protocol use a hook to ACM in order to check if the caller has the right permission to call the guarded function. They call ACM's external method `isAllowedToCall(address caller, string functionSig)`.
27+
Here is an example of how `_setCollateralFactor` function in `Comptroller` is integrated with ACM:
28+
```
29+
bool isAllowedToCall = AccessControlManager(accessControl)
30+
.isAllowedToCall(
31+
msg.sender,
32+
"_setCollateralFactor(VToken,uint256,uint256)"
33+
);
34+
35+
if (!isAllowedToCall) {
36+
revert Unauthorized();
37+
}
38+
```
39+
40+
2541
# Solidity API
2642

2743

0 commit comments

Comments
 (0)