var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { createRemoveCreatorVerificationInstruction } from '@metaplex-solarti/mpl-token-metadata';
import { useOperation, } from '../../../types';
import { TransactionBuilder } from '../../../utils';
// -----------------
// Operation
// -----------------
const Key = 'UnverifyNftCreatorOperation';
/**
 * Unverifies the creator of an NFT or SFT.
 *
 * ```ts
 * await metaplex
 *   .nfts()
 *   .unverifyCreator({ mintAddress, creator };
 * ```
 *
 * @group Operations
 * @category Constructors
 */
export const unverifyNftCreatorOperation = useOperation(Key);
/**
 * @group Operations
 * @category Handlers
 */
export const unverifyNftCreatorOperationHandler = {
    handle: (operation, metaplex, scope) => __awaiter(void 0, void 0, void 0, function* () {
        return unverifyNftCreatorBuilder(metaplex, operation.input, scope).sendAndConfirm(metaplex, scope.confirmOptions);
    }),
};
/**
 * Unverifies the creator of an NFT or SFT.
 *
 * ```ts
 * const transactionBuilder = metaplex
 *   .nfts()
 *   .builders()
 *   .unverifyCreator({ mintAddress, creator });
 * ```
 *
 * @group Transaction Builders
 * @category Constructors
 */
export const unverifyNftCreatorBuilder = (metaplex, params, options = {}) => {
    var _a;
    const { programs, payer = metaplex.rpc().getDefaultFeePayer() } = options;
    const { mintAddress, creator = metaplex.identity() } = params;
    // Programs.
    const tokenMetadataProgram = metaplex.programs().getTokenMetadata(programs);
    return (TransactionBuilder.make()
        .setFeePayer(payer)
        // Verify the creator.
        .add({
        instruction: createRemoveCreatorVerificationInstruction({
            metadata: metaplex.nfts().pdas().metadata({
                mint: mintAddress,
                programs,
            }),
            creator: creator.publicKey,
        }, tokenMetadataProgram.address),
        signers: [creator],
        key: (_a = params.instructionKey) !== null && _a !== void 0 ? _a : 'unverifyCreator',
    }));
};
//# sourceMappingURL=unverifyNftCreator.js.map