circlefin/stablecoin-evm

function `setMinterManager` should verify the input

Opened this issue · 0 comments

The function setMinterManager does not verify if the input parameter _newMinterManager implements MinterManagementInterface now. So the variable minterManager maybe set to the wrong value by accident.

    function setMinterManager(address _newMinterManager) public onlyOwner {
        emit MinterManagerSet(address(minterManager), _newMinterManager);
        minterManager = MinterManagementInterface(_newMinterManager);
    }

I suggest the following new codes:

    function setMinterManager(address _newMinterManager) public onlyOwner {
        require(
            !MinterManagementInterface(_newMinterManager).isMinter(address(0)),
            "invalid minter mangaer"
        );
        emit MinterManagerSet(address(minterManager), _newMinterManager);
        minterManager = MinterManagementInterface(_newMinterManager);
    }

Or check it by ERC-165.