/**
 * This code was AUTOGENERATED using the Codama library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun Codama to update it.
 *
 * @see https://github.com/codama-idl/codama
 */
import { __assign } from "tslib";
import { addDecoderSizePrefix, addEncoderSizePrefix, combineCodec, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, transformEncoder, } from "@solana/kit";
import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from "../programs";
import { getAccountMetaFactory } from "../shared";
export var REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([
    7, 27, 93, 132, 1, 80, 19, 163,
]);
export function getReplaceDepositForBurnDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR);
}
export function getReplaceDepositForBurnInstructionDataEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        [
            "originalMessage",
            addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()),
        ],
        [
            "originalAttestation",
            addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()),
        ],
        ["newDestinationCaller", getAddressEncoder()],
        ["newMintRecipient", getAddressEncoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR })); });
}
export function getReplaceDepositForBurnInstructionDataDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        [
            "originalMessage",
            addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()),
        ],
        [
            "originalAttestation",
            addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()),
        ],
        ["newDestinationCaller", getAddressDecoder()],
        ["newMintRecipient", getAddressDecoder()],
    ]);
}
export function getReplaceDepositForBurnInstructionDataCodec() {
    return combineCodec(getReplaceDepositForBurnInstructionDataEncoder(), getReplaceDepositForBurnInstructionDataDecoder());
}
export function getReplaceDepositForBurnInstruction(input, config) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
    // Program address.
    var programAddress = (_a = config === null || config === void 0 ? void 0 : config.programAddress) !== null && _a !== void 0 ? _a : TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS;
    // Original accounts.
    var originalAccounts = {
        owner: { value: (_b = input.owner) !== null && _b !== void 0 ? _b : null, isWritable: false },
        eventRentPayer: { value: (_c = input.eventRentPayer) !== null && _c !== void 0 ? _c : null, isWritable: true },
        senderAuthorityPda: {
            value: (_d = input.senderAuthorityPda) !== null && _d !== void 0 ? _d : null,
            isWritable: false,
        },
        messageTransmitter: {
            value: (_e = input.messageTransmitter) !== null && _e !== void 0 ? _e : null,
            isWritable: true,
        },
        tokenMessenger: { value: (_f = input.tokenMessenger) !== null && _f !== void 0 ? _f : null, isWritable: false },
        messageSentEventData: {
            value: (_g = input.messageSentEventData) !== null && _g !== void 0 ? _g : null,
            isWritable: true,
        },
        messageTransmitterProgram: {
            value: (_h = input.messageTransmitterProgram) !== null && _h !== void 0 ? _h : null,
            isWritable: false,
        },
        tokenMessengerMinterProgram: {
            value: (_j = input.tokenMessengerMinterProgram) !== null && _j !== void 0 ? _j : null,
            isWritable: false,
        },
        systemProgram: { value: (_k = input.systemProgram) !== null && _k !== void 0 ? _k : null, isWritable: false },
        eventAuthority: { value: (_l = input.eventAuthority) !== null && _l !== void 0 ? _l : null, isWritable: false },
        program: { value: (_m = input.program) !== null && _m !== void 0 ? _m : null, isWritable: false },
    };
    var accounts = originalAccounts;
    // Original args.
    var args = __assign({}, input);
    // Resolve default values.
    if (!accounts.systemProgram.value) {
        accounts.systemProgram.value =
            "11111111111111111111111111111111";
    }
    var getAccountMeta = getAccountMetaFactory(programAddress, "programId");
    return Object.freeze({
        accounts: [
            getAccountMeta(accounts.owner),
            getAccountMeta(accounts.eventRentPayer),
            getAccountMeta(accounts.senderAuthorityPda),
            getAccountMeta(accounts.messageTransmitter),
            getAccountMeta(accounts.tokenMessenger),
            getAccountMeta(accounts.messageSentEventData),
            getAccountMeta(accounts.messageTransmitterProgram),
            getAccountMeta(accounts.tokenMessengerMinterProgram),
            getAccountMeta(accounts.systemProgram),
            getAccountMeta(accounts.eventAuthority),
            getAccountMeta(accounts.program),
        ],
        data: getReplaceDepositForBurnInstructionDataEncoder().encode(args),
        programAddress: programAddress,
    });
}
export function parseReplaceDepositForBurnInstruction(instruction) {
    if (instruction.accounts.length < 11) {
        // TODO: Coded error.
        throw new Error("Not enough accounts");
    }
    var accountIndex = 0;
    var getNextAccount = function () {
        var accountMeta = instruction.accounts[accountIndex];
        accountIndex += 1;
        return accountMeta;
    };
    return {
        programAddress: instruction.programAddress,
        accounts: {
            owner: getNextAccount(),
            eventRentPayer: getNextAccount(),
            senderAuthorityPda: getNextAccount(),
            messageTransmitter: getNextAccount(),
            tokenMessenger: getNextAccount(),
            messageSentEventData: getNextAccount(),
            messageTransmitterProgram: getNextAccount(),
            tokenMessengerMinterProgram: getNextAccount(),
            systemProgram: getNextAccount(),
            eventAuthority: getNextAccount(),
            program: getNextAccount(),
        },
        data: getReplaceDepositForBurnInstructionDataDecoder().decode(instruction.data),
    };
}
//# sourceMappingURL=replaceDepositForBurn.js.map