I am trying to implement ERC2981 for royalties but want to use OpenZepplins Payment Splitter to split the royalty amount to two different addresses with two different amounts. I can't find any examples of both of these combined. I understand how to pass in the values to the constructor for the PaymentSplitter but not sure how to set those values for the royality methods. Here is an example of the code:
constructor(string memory _name, string memory _symbol, address[] memory _payees, uint256[] memory _shares
) ERC721(_name, _symbol) PaymentSplitter(_payees, _shares) payable {
//Need to figure out how to set _royalities.recipient to _payees and _royalties.salePrice to _shares
console.log("Testing test deploy", _name, _symbol);
}
function _setTokenRoyalty(uint256 tokenId, address recipient, uint256 salePrice) internal {
//This is so expected 'value' will be at most 10,000 which is 100%
require(salePrice <= 10000, "ERC2981Royalities: Too high");
//How can I set the recipient to use the array of _payees and _shares here?
_royalties[tokenId] = Royalty(recipient, salePrice);
}
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
require(_exists(tokenId), "Nonexistent token");
if(_royalties[tokenId].recipient != address(0)) {
return (_royalties[tokenId].recipient, salePrice * _royalties[tokenId].salePrice / 10000);
}
Royalty memory royalty = _royalties[tokenId];
if(royalty.recipient != address(0) && royalty.salePrice != 0) {
return (royalty.recipient, (salePrice * royalty.salePrice) / 10000);
}
return (address(0), 0);
}