import { Buffer } from 'buffer';
import * as beet from '@metaplex-foundation/beet';
import { allowListBeet } from '@metaplex-foundation/mpl-candy-guard';
import { createSerializerFromBeet, mapSerializer } from '../../../types';
/** @internal */
export const allowListGuardManifest = {
    name: 'allowList',
    settingsBytes: 32,
    settingsSerializer: mapSerializer(createSerializerFromBeet(allowListBeet), (settings) => ({ merkleRoot: new Uint8Array(settings.merkleRoot) }), (settings) => ({ merkleRoot: Array.from(settings.merkleRoot) })),
    mintSettingsParser: ({ metaplex, settings, payer, candyMachine, candyGuard, }) => {
        return {
            arguments: Buffer.from([]),
            remainingAccounts: [
                {
                    isSigner: false,
                    isWritable: false,
                    address: metaplex.candyMachines().pdas().merkleProof({
                        merkleRoot: settings.merkleRoot,
                        user: payer.publicKey,
                        candyMachine,
                        candyGuard,
                    }),
                },
            ],
        };
    },
    routeSettingsParser: ({ metaplex, settings, routeSettings, programs, candyMachine, candyGuard, payer, }) => {
        const proof = routeSettings.merkleProof;
        const vectorSize = Buffer.alloc(4);
        beet.u32.write(vectorSize, 0, proof.length);
        return {
            arguments: Buffer.concat([vectorSize, ...proof]),
            remainingAccounts: [
                {
                    isSigner: false,
                    isWritable: true,
                    address: metaplex.candyMachines().pdas().merkleProof({
                        merkleRoot: settings.merkleRoot,
                        user: payer.publicKey,
                        candyMachine,
                        candyGuard,
                    }),
                },
                {
                    isSigner: false,
                    isWritable: false,
                    address: metaplex.programs().getSystem(programs).address,
                },
            ],
        };
    },
};
//# sourceMappingURL=allowList.js.map