AmazingAng / WTF-Solidity

WTF Solidity 极简入门教程,供小白们使用。Now supports English! 官网: https://wtf.academy
https://wtf.academy
Other
11.74k stars 2.04k forks source link

[Improvement][45_Timelock] question regarding visibility setting of changeAdmin function #806

Closed smallfu6 closed 3 weeks ago

smallfu6 commented 1 month ago

Description

In the Timelock contract, the changeAdmin function is currently set to public, and it uses the onlyTimelock modifier to ensure that only the contract itself can call this function. I believe it would be more appropriate to set the changeAdmin function to private.

/**
 * @dev 改变管理员地址,调用者必须是Timelock合约。
 */
function changeAdmin(address newAdmin) public onlyTimelock {
        admin = newAdmin;

        emit NewAdmin(newAdmin);
 }

Are you willing to submit a PR?(你愿意提交PR吗?)

XdpCs commented 3 weeks ago

public onlyTimelock == private I think public onlyTimelock will be clearer, private needs more info to explain why it is private.

XdpCs commented 3 weeks ago

If you have any questions, you can reopen this issue.