setContractURI
/**
* setContractURI function: Set the "contractURI" metadata for the specified contract
* @param {string} contractURI ContractURI for the contract
* (URI to a JSON file describing the contract's metadata)
* @notice Warning: This method will consume gas (35000 gas estimated)
* @returns {Promise<ethers.providers.TransactionResponse>} Transaction
*/
async setContractURI({ contractURI, gas = null }) {
if (!this.#contractDeployed && !this.contractAddress) {
// throw new Error(
// '[ERC721Mintable.setContractURI] A contract should be deployed or loaded first!',
// );
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setContractURI,
message: ERROR_LOG.message.contract_not_deployed_or_loaded,
}),
);
}
if (!contractURI) {
// throw new Error('[ERC721Mintable.setContractURI] A valid contract uri is required!');
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setContractURI,
message: ERROR_LOG.message.invalid_contractURI,
}),
);
}
/* eslint-disable no-console */
if (!isURI(contractURI)) {
console.warn(`WARNING: The ContractURI "${contractURI}" is not a link.`);
console.warn('WARNING: ContractURI should be a public link to a valid JSON metadata file');
}
try {
const options = this.#addGasPriceToOptions({}, gas);
return await this.#contractDeployed.setContractURI(contractURI, options);
} catch (error) {
const { message, type } = networkErrorHandler(error);
// throw new Error(`${type}[ERC721Mintable.setContractURI] An error occured: ${message}`);
throw new Error(
errorLogger({
location: ERROR_LOG.location.ERC721Mintable_setContractURI,
message: ERROR_LOG.message.an_error_occured,
options: `${type} ${message}`,
}),
);
}
}
Copy link