I have an upgradable contract that inherits from ERC20BurnableUpgradeable and I want to change the value of one of its contants (NAME), something like this:
// Original Contract
contract Token is ERC20BurnableUpgradeable {
string private constant NAME = "Token Name";
string private constant SYMBOL = "TOKEN";
uint8 private constant DECIMAL = 18;
function initialize() public override initializer {
super.initialize(NAME, SYMBOL, DECIMAL);
}
}
// New version Contract
contract Token is ERC20BurnableUpgradeable {
string private constant NAME = "NEW Token Name";
string private constant SYMBOL = "TOKEN";
uint8 private constant DECIMAL = 18;
function initialize() public override initializer {
super.initialize(NAME, SYMBOL, DECIMAL);
}
}
I created a unit test to check it but the changes are not reflected when I call the name() function. No errors, I am just getting the original value.
So I added a new overrided name() function and it worked
// New version Contract
contract Token is ERC20BurnableUpgradeable {
string private constant NAME = "NEW Token Name";
string private constant SYMBOL = "TOKEN";
uint8 private constant DECIMAL = 18;
function initialize() public override initializer {
super.initialize(NAME, SYMBOL, DECIMAL);
}
function name() override public view returns(string memory){
return NAME;
}
}
So the questions that comes to my mind are: is it the correct way to change the value of a Constant? , that could eopardize the storage layout?.
Thank you, I would really appreciate your opinion.