Closed jacob-tucker closed 1 month ago
Hi @jacob-tucker , If the user should be able to pass address(0), I think a good practice is to add a condition like the one below:
if(payerId !== address(0)){
const isPayerRegistered = await this.ipAssetRegistryClient.isRegistered({
id: getAddress(request.payerIpId, "request.payerIpId"),
});
if (!isPayerRegistered) {
throw new Error(`The payer IP with id ${request.payerIpId} is not registered.`);
}
}
This is because the isRegistered method's logic not only includes checking for a zero address but also other logic:
function _isRegistered(address id) internal view override returns (bool) {
if (id == address(0)) return false;
if (id.code.length == 0) return false;
if (!ERC165Checker.supportsInterface(id, type(IIPAccount).interfaceId)) return false;
(uint chainId, address tokenContract, uint tokenId) = IIPAccount(payable(id)).token();
if (id != ipAccount(chainId, tokenContract, tokenId)) return false;
return bytes(IIPAccount(payable(id)).getString("NAME")).length != 0;
}
When using royalty.payRoyaltyOnBehalf, user should be able to pass address(0) as the payerIpId
In the SDK, you can see here that it is checking if the payer IP ID exists. However I believe we should remove this line.