I know there’s a similar question, but it doesn’t address the case of multi-level inheritance. I even commented on the answer, and the original respondent (i.e., Lauri Peltonen) recommended that I post a new question. That’s why I’m posting this one.
So, in the case of multi-level inheritance (A -> B -> C
), for the contract that is in the middle of the hierarchy (i.e., B
in this case), should it use onlyInitializing
or initializer
?
I mean, should it be like this:
contract A is Initializable {
function __A_init() onlyInitializing {}
}
contract B is Initializable, A {
function __B_init() initializer {
__A_init();
}
}
contract C is Initializable, B {
function __C_init() initializer {
__B_init();
}
}
Or, this?
contract A is Initializable {
function __A_init() onlyInitializing {}
}
contract B is Initializable, A {
function __B_init() onlyInitializing {
__A_init();
}
}
contract C is Initializable, B {
function __C_init() initializer {
__B_init();
}
}