Is it possible to call function (from another contract) the same name as in current ?
contract TestA {
function init() {}
}
Contract TestB {
function init() {
init(); // call form contract A
}
}

Apr 5, 2022, 2:39 PM
are you talking about one contract inheriting the other, or two separately deployed contracts?
Apr 5, 2022, 3:36 PM
yeah, You're right, it is my fault
contract TestB is TestA {}
Apr 5, 2022, 3:37 PM
hmm yeah if they have the same signature, I don't think so, since you'd have to mark them as virtual/override. If they have different signature (same name but different params), it should be fine
Apr 5, 2022, 3:42 PM
contract A_Upgradeable {
function _init() {}
}
contract B_Upgradeable is A_Upgradeable {
_init() {
_init(); // call in contract A_Upgradeable
}
}
Apr 5, 2022, 3:44 PM
yeah I don't think that will compile since they are not marked override/virtual
Apr 5, 2022, 3:47 PM
😯
Apr 5, 2022, 3:48 PM
can you just name them differently? Or give them different params?
then you're golden
or just use virtual/override and call super.init()
Apr 5, 2022, 3:50 PM
It causes recursion, and eventually an error
You might either override function _init() inside of B_Upgradable or make a call to the A_Upgradable if that function's been marked external/public
Buddy, is there any difference between A.foo{gas:10000}() and address("").call{gas:10000}("foo")?
Apr 5, 2022, 3:55 PM
yes, in the second one you're not calling a specific function, whereas in the first you are calling the foo() function.
Apr 5, 2022, 4:13 PM
I specified the foo) in the second one
Apr 5, 2022, 4:15 PM
its just a string though, not an encoded call
Apr 5, 2022, 4:15 PM
gosh, forgot to add abi.encodeWithSignature
Apr 5, 2022, 4:16 PM
yeah then I guess its the same
details are important 😉
Apr 5, 2022, 4:16 PM
Did you consider ERC721 in detail?
Apr 5, 2022, 4:17 PM
hmm?
what do you mean?
Apr 5, 2022, 4:17 PM
I've spotted this strange thing in override
They added IERC165
Apr 5, 2022, 4:17 PM
yes because both of those specify the same function sig, wont compile without it probably
Apr 5, 2022, 4:18 PM
But when we override ERC20 functions, we don't specify IERC20)
Apr 5, 2022, 4:18 PM
yeah I dunno, maybe it works without it? Haven't tried it
Apr 5, 2022, 4:19 PM
Me too
Apr 5, 2022, 4:19 PM

© 2024 Draquery.com All rights reserved.