Hey all,
I'm testing UUPS locally with hardhat. In my "version 2" .sol I'm adding a "withdraw" function that is intended to withdraw the contract funds to the owner. I have a slight issue that I'm hoping someone can shed some light on for me. The withdraw seems to be working without explicitly giving the owner address "payable". I don't see where it is happening in the imported "OwnableUpgradable.sol" either.
My withdraw function:
contract Domains_v2 is Domains_v1{
function withdraw() public virtual onlyOwner {
uint amount = address(this).balance;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Failed to withdraw Matic");
}
(There, I wouldn't expect the msg.sender.call to be working even though we're satisfying the onlyOwner condition.)
My initialize function looks like this:
contract Domains_v1 is Initializable, OwnableUpgradeable, UUPSUpgradeable, ERC721URIStorageUpgradeable {
// initializer replaces "constructor()"
function initialize(string memory _tld) public initializer payable {
__Ownable_init();
__ERC721_init("Pibble Name Service", "PNS");
tld = _tld;
//console.log("%s name service deployed", _tld);
// console.log("I am also an UPGRADEABLE contract!");
}
// authorizes upgrades NEVER LEAVE THIS FUNCTION OUT OR YOU LOSE UPGRADABILITY!
function _authorizeUpgrade(address newImplementation) internal
override
onlyOwner{}
It was my understanding that the owner has to be explicitly granted payable with something like this:
address payable public owner;
Then in the constructor (for non-upgradable contracts) you'd need something like this:
owner = payable(msg.sender);
But I'm not doing that anywhere in my code, nor am I seeing it in the openzeppelin code. I'm probably just missing it, but can someone explain how my owner is getting the permission to withdraw the funds?
Thanks!