"use strict";
/**
 * This code was AUTOGENERATED using the kinobi library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun kinobi to update it.
 *
 * @see https://github.com/metaplex-foundation/kinobi
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.recoverNestedAssociatedToken = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const shared_1 = require("../shared");
// Instruction.
function recoverNestedAssociatedToken(context, input) {
    // Program ID.
    const programId = context.programs.getPublicKey('splAssociatedToken', 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
    // Accounts.
    const resolvedAccounts = {
        nestedAssociatedAccountAddress: {
            index: 0,
            isWritable: true,
            value: input.nestedAssociatedAccountAddress ?? null,
        },
        nestedTokenMintAddress: {
            index: 1,
            isWritable: false,
            value: input.nestedTokenMintAddress ?? null,
        },
        destinationAssociatedAccountAddress: {
            index: 2,
            isWritable: true,
            value: input.destinationAssociatedAccountAddress ?? null,
        },
        ownerAssociatedAccountAddress: {
            index: 3,
            isWritable: false,
            value: input.ownerAssociatedAccountAddress ?? null,
        },
        ownerTokenMintAddress: {
            index: 4,
            isWritable: false,
            value: input.ownerTokenMintAddress ?? null,
        },
        walletAddress: {
            index: 5,
            isWritable: true,
            value: input.walletAddress ?? null,
        },
        tokenProgram: {
            index: 6,
            isWritable: false,
            value: input.tokenProgram ?? null,
        },
    };
    // Default values.
    if (!resolvedAccounts.tokenProgram.value) {
        resolvedAccounts.tokenProgram.value = context.programs.getPublicKey('splToken', 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
        resolvedAccounts.tokenProgram.isWritable = false;
    }
    // Accounts in order.
    const orderedAccounts = Object.values(resolvedAccounts).sort((a, b) => a.index - b.index);
    // Keys and Signers.
    const [keys, signers] = (0, shared_1.getAccountMetasAndSigners)(orderedAccounts, 'programId', programId);
    // Data.
    const data = new Uint8Array();
    // Bytes Created On Chain.
    const bytesCreatedOnChain = 0;
    return (0, umi_1.transactionBuilder)([
        { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
    ]);
}
exports.recoverNestedAssociatedToken = recoverNestedAssociatedToken;
//# sourceMappingURL=recoverNestedAssociatedToken.js.map