"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDepositForBurnInstruction = void 0;
const anchor_1 = require("@project-serum/anchor");
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
const accounts_1 = require("../accounts");
const program_1 = require("../program");
function createDepositForBurnInstruction(messageTransmitterProgramId, tokenMessengerProgramId, tokenMint, destinationDomain, senderAddress, senderAssociatedTokenAccountAddress, recipient, amount) {
    // Find pdas
    const messageTransmitterAccount = (0, accounts_1.findProgramAddress)('message_transmitter', messageTransmitterProgramId);
    const tokenMessenger = (0, accounts_1.findProgramAddress)('token_messenger', tokenMessengerProgramId);
    const tokenMinter = (0, accounts_1.findProgramAddress)('token_minter', tokenMessengerProgramId);
    const localToken = (0, accounts_1.findProgramAddress)('local_token', tokenMessengerProgramId, [tokenMint]);
    const remoteTokenMessengerKey = (0, accounts_1.findProgramAddress)('remote_token_messenger', tokenMessengerProgramId, [destinationDomain.toString()]);
    const authorityPda = (0, accounts_1.findProgramAddress)('sender_authority', tokenMessengerProgramId);
    const tokenMessengerProgram = (0, program_1.createTokenMessengerProgramInterface)(tokenMessengerProgramId);
    return tokenMessengerProgram.methods
        .depositForBurn({
        amount: new anchor_1.BN(amount.toString()),
        destinationDomain,
        mintRecipient: new web3_js_1.PublicKey(recipient.toUint8Array()),
    })
        .accounts({
        owner: senderAddress,
        senderAuthorityPda: authorityPda.publicKey,
        burnTokenAccount: senderAssociatedTokenAccountAddress,
        messageTransmitter: messageTransmitterAccount.publicKey,
        tokenMessenger: tokenMessenger.publicKey,
        remoteTokenMessenger: remoteTokenMessengerKey.publicKey,
        tokenMinter: tokenMinter.publicKey,
        localToken: localToken.publicKey,
        burnTokenMint: tokenMint,
        messageTransmitterProgram: messageTransmitterProgramId,
        tokenMessengerMinterProgram: tokenMessengerProgramId,
        tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
    })
        .instruction();
}
exports.createDepositForBurnInstruction = createDepositForBurnInstruction;
//# sourceMappingURL=depositForBurn.js.map