a manifold extension to port fully onchain an existing collection minted with offchain content
clgsms/scripts/register-extension.js
JavaScript · 45 lines · 2 KBRAWDOWNLOAD
/**
* Register the redeem extension on the creator contract. Must be sent from the
* creator's owner/admin wallet (Manifold's `adminRequired`).
*
* npx hardhat run scripts/register-extension.js --network sepolia
*
* Env:
* CREATOR / EXTENSION default to deployments/<network>.json
*
* Until this runs, the extension cannot mint and the creator will not delegate
* tokenURI to it.
*/
import { addressFor, connect, creatorAt, main } from "./_lib.js";
main(async () => {
const { ethers, net, signer } = await connect();
const creatorAddress = addressFor("creator", net);
const extension = addressFor("extension", net);
const creator = creatorAt(ethers, creatorAddress, signer);
const owner = await creator.owner();
const isAdmin = owner === signer.address || (await creator.isAdmin(signer.address));
if (!isAdmin) {
throw new Error(
`${signer.address} is neither owner (${owner}) nor an admin of ${creatorAddress}.\n` +
` Send this from the Manifold admin wallet, or approveAdmin() it first.`,
);
}
const already = await creator.getExtensions();
if (already.includes(extension)) {
console.log(`extension ${extension} is already registered — nothing to do`);
return;
}
const tx = await creator.registerExtension(extension, "");
console.log(`registerExtension ${extension}\n tx ${tx.hash}`);
await tx.wait();
const now = await creator.getExtensions();
if (!now.includes(extension)) throw new Error("registration did not take effect");
console.log(`\nregistered. extensions on ${creatorAddress}:`);
for (const e of now) console.log(` ${e}${e === extension ? " <- this one" : ""}`);
});