/**
 * 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 { combineCodec, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, transformEncoder, } from "@solana/kit";
import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from "../programs";
import { getAccountMetaFactory } from "../shared";
export var DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR = new Uint8Array([
    167, 222, 19, 114, 85, 21, 14, 118,
]);
export function getDepositForBurnWithCallerDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR);
}
export function getDepositForBurnWithCallerInstructionDataEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["amount", getU64Encoder()],
        ["destinationDomain", getU32Encoder()],
        ["mintRecipient", getAddressEncoder()],
        ["destinationCaller", getAddressEncoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR })); });
}
export function getDepositForBurnWithCallerInstructionDataDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["amount", getU64Decoder()],
        ["destinationDomain", getU32Decoder()],
        ["mintRecipient", getAddressDecoder()],
        ["destinationCaller", getAddressDecoder()],
    ]);
}
export function getDepositForBurnWithCallerInstructionDataCodec() {
    return combineCodec(getDepositForBurnWithCallerInstructionDataEncoder(), getDepositForBurnWithCallerInstructionDataDecoder());
}
export function getDepositForBurnWithCallerInstruction(input, config) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
    // 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,
        },
        burnTokenAccount: {
            value: (_e = input.burnTokenAccount) !== null && _e !== void 0 ? _e : null,
            isWritable: true,
        },
        messageTransmitter: {
            value: (_f = input.messageTransmitter) !== null && _f !== void 0 ? _f : null,
            isWritable: true,
        },
        tokenMessenger: { value: (_g = input.tokenMessenger) !== null && _g !== void 0 ? _g : null, isWritable: false },
        remoteTokenMessenger: {
            value: (_h = input.remoteTokenMessenger) !== null && _h !== void 0 ? _h : null,
            isWritable: false,
        },
        tokenMinter: { value: (_j = input.tokenMinter) !== null && _j !== void 0 ? _j : null, isWritable: false },
        localToken: { value: (_k = input.localToken) !== null && _k !== void 0 ? _k : null, isWritable: true },
        burnTokenMint: { value: (_l = input.burnTokenMint) !== null && _l !== void 0 ? _l : null, isWritable: true },
        messageSentEventData: {
            value: (_m = input.messageSentEventData) !== null && _m !== void 0 ? _m : null,
            isWritable: true,
        },
        messageTransmitterProgram: {
            value: (_o = input.messageTransmitterProgram) !== null && _o !== void 0 ? _o : null,
            isWritable: false,
        },
        tokenMessengerMinterProgram: {
            value: (_p = input.tokenMessengerMinterProgram) !== null && _p !== void 0 ? _p : null,
            isWritable: false,
        },
        tokenProgram: { value: (_q = input.tokenProgram) !== null && _q !== void 0 ? _q : null, isWritable: false },
        systemProgram: { value: (_r = input.systemProgram) !== null && _r !== void 0 ? _r : null, isWritable: false },
        eventAuthority: { value: (_s = input.eventAuthority) !== null && _s !== void 0 ? _s : null, isWritable: false },
        program: { value: (_t = input.program) !== null && _t !== void 0 ? _t : null, isWritable: false },
    };
    var accounts = originalAccounts;
    // Original args.
    var args = __assign({}, input);
    // Resolve default values.
    if (!accounts.tokenProgram.value) {
        accounts.tokenProgram.value =
            "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
    }
    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.burnTokenAccount),
            getAccountMeta(accounts.messageTransmitter),
            getAccountMeta(accounts.tokenMessenger),
            getAccountMeta(accounts.remoteTokenMessenger),
            getAccountMeta(accounts.tokenMinter),
            getAccountMeta(accounts.localToken),
            getAccountMeta(accounts.burnTokenMint),
            getAccountMeta(accounts.messageSentEventData),
            getAccountMeta(accounts.messageTransmitterProgram),
            getAccountMeta(accounts.tokenMessengerMinterProgram),
            getAccountMeta(accounts.tokenProgram),
            getAccountMeta(accounts.systemProgram),
            getAccountMeta(accounts.eventAuthority),
            getAccountMeta(accounts.program),
        ],
        data: getDepositForBurnWithCallerInstructionDataEncoder().encode(args),
        programAddress: programAddress,
    });
}
export function parseDepositForBurnWithCallerInstruction(instruction) {
    if (instruction.accounts.length < 17) {
        // 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(),
            burnTokenAccount: getNextAccount(),
            messageTransmitter: getNextAccount(),
            tokenMessenger: getNextAccount(),
            remoteTokenMessenger: getNextAccount(),
            tokenMinter: getNextAccount(),
            localToken: getNextAccount(),
            burnTokenMint: getNextAccount(),
            messageSentEventData: getNextAccount(),
            messageTransmitterProgram: getNextAccount(),
            tokenMessengerMinterProgram: getNextAccount(),
            tokenProgram: getNextAccount(),
            systemProgram: getNextAccount(),
            eventAuthority: getNextAccount(),
            program: getNextAccount(),
        },
        data: getDepositForBurnWithCallerInstructionDataDecoder().decode(instruction.data),
    };
}
//# sourceMappingURL=depositForBurnWithCaller.js.map