I'm working with an Upgradeable Beacon Proxy factory design.
I'm creating a new proxy and using abi.encodeWithSelector to call the initializer of the implementation function, the only parameters that are expected from the initializer function in the implementation contract is for the inherited UpgradeablePaymentSplitter of (address _payees, uint _shares). I'm creating a memory array of address and a memory array of uint256 within the function. When I call the function to create new proxy, I'm getting error "PaymentSplitter: account already has shares". I have successfully created a proxy with an array of only one account and an array of only one shares value, got return of contract address. So I must be creating the array improperly.
Also tried creating storage arrays for each parameters, pushing to the array and popping indexes out of the arrays that aren't needed after creating a new proxy. Still got the same error from PaymentSplitter.
I simplified the code a bit here as the issue seems to be the way that I'm creating the array.
Factory contract
function cloneContract() external returns (address) {
uint256 factorySlice = 10;
uint256 callerSlice = 90;
address[] memory _payees = new address[](2);
uint256[] memory _shares = new uint256[](2);
_shares[0] = factorySlice;
_shares[1] = callerSlice;
_payees[0] = factoryAddress;
_payees[1] = msg.sender;
BeaconProxy proxy = new BeaconProxy(address(beacon),
abi.encodeWithSelector(implementation.initialize.selector, _payees, _shares)
);
return address(proxy);
Implementation contract is ERC1155URIStorageUpgradeable, OwnableUpgradeable, PaymentSplitterUpgradeable, PausableUpgradeable
function initialize(address[] memory _payees, uint256[] memory _shares) initializer public {
__ERC1155URIStorage_init();
_setBaseURI("https://ipfs.io/ipfs/");
__PaymentSplitter_init(_payees, _shares);
}
Using hardhat local chain