setRoyalties
/**
* Set royalties information for the receiver address with the provided fee
* @param {string} - address
* @param {number} - fee
* @notice Warning: This method will consume gas (49000 gas estimated)
* @returns {Promise<ethers.providers.TransactionResponse>} - Transaction
*/
async setRoyalties({ publicAddress, fee, gas = null }) {
if (!this.#contractDeployed && !this.contractAddress) {
// throw new Error('[ERC721Mintable.setRoyalties] Contract needs to be deployed');
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setRoyalties,
message: ERROR_LOG.message.contract_not_deployed,
}),
);
}
if (!publicAddress || !utils.isAddress(publicAddress)) {
// throw new Error('[ERC721Mintable.setRoyalties] Address is required');
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setRoyalties,
message: ERROR_LOG.message.no_address_supplied,
}),
);
}
if (!fee || !Number.isInteger(fee) || !(fee > 0 && fee < 10000)) {
// throw new Error(
// '[ERC721Mintable.setRoyalties] Fee as numeric value between 0 and 10000 is required',
// );
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setRoyalties,
message: ERROR_LOG.message.fee_must_be_between_0_and_10000,
}),
);
}
try {
let options = { gasLimit: this.#gasLimit };
options = this.#addGasPriceToOptions(options, gas);
return await this.#contractDeployed.setRoyalties(publicAddress, fee, options);
} catch (error) {
const { message, type } = networkErrorHandler(error);
// throw new Error(`${type}[ERC721Mintable.setRoyalties] An error occured: ${message}`);
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setRoyalties,
message: ERROR_LOG.message.an_error_occured,
options: `${type} ${message}`,
}),
);
}
}
Copy link