Following the tutorial here: OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat
I didn't see a way to pass the arguments for the initializer for another implementation, so I looked up the API: https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades
I may be able to use "upgradeProxy" and "verify" separately instead of "prepareUpgrade", since prepareUpgrade has no calls that I can pass with the implementation contract.
I'm not confident it will work, however, since "PaymentSplitterUpgradeable" doesn't actually have any functions that remove payees, change shares, or clear data. Unfortunately, I think effectively calling the initialize function again will either fail or append the data. If that's the case, someone with some real coding aptitude should PR that crap and add true upgradeability.
Add some version of this while you're at it:
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Get the number of payees
*/
function payeeCount() public view returns (uint256) {
return _payees.length;
}
/**
* @dev Release the owed amount of token to all of the payees.
*/
function distribute() public virtual {
uint256 count = payeeCount();
for (uint256 i = 0; i < count; i++) {
// note: `_release` should not fail because payee always has shares, protected by `_appPay`
_release(payable(payee(i)));
}
}
/**
* @dev Release owed amount of the `token` to all of the payees.
*/
function distribute(IERC20Upgradeable token) public virtual {
uint256 count = payeeCount();
for (uint256 i = 0; i < count; i++) {
// note: `_release` should not fail because payee always has shares, protected by `_appPay`
_release(token, payee(i));
}
}
Encourages gas token altruism. Stole it from the "Split" contract linked in a previous post.