Closed RamanSB closed 4 months ago
Alternatively with my own code (I've used a different set of variable names so apologies), we can define a custom error instead of re-using the modifier if that makes things clearer for students?
error DSCEngine__RequireAtleastOneFormOfCollateral();
constructor(
address[] memory validCollateral,
address[] memory priceFeeds,
address dscAddress
) moreThanZero(validCollateral.length) {
if (validCollateral.length != priceFeeds.length) {
revert DSCEngine__TokenAddressesAndPriceFeedAddressesMustBeSameLength();
}
if (!(validCollateral.length > 0)) {
revert DSCEngine__RequireAtleastOneFormOfCollateral();
}
}
This would be a great addition!
This was also called out in the audit report (you can see it in the audit folder).
I'm going to close this for now though to keep the code as similar to the video.
Hey @PatrickAlphaC - currently there is nothing stopping the deployer from deploying the contract with an empty address[] for both validCollateral and priceFeeds, this check is not sufficient:
This will prevent the deployer from erroneously deploying the DSCEngine without any form of valid collateral, in essence preventing the below script from successfully deploying: