text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.deprecatedRedeemParticipationBid = void 0;
  const web3_js_1 = require("@safecoin/web3.js");
  const borsh_1 = require("borsh");
  const _1 = require(".");
  const utils_1 = require("../../utils");
  const deprecatedStates_1 = require("./deprecatedStates");
  async function deprecatedRedeemParticipationBid(vault, safetyDepositTokenStore, destination, safetyDeposit, bidder, payer, instructions, participationPrintingAccount, transferAuthority, acceptPaymentAccount, tokenPaymentAccount) {
      const PROGRAM_IDS = (0, utils_1.programIds)();
      const store = PROGRAM_IDS.store;
      if (!store) {
          throw new Error('Store not initialized');
      }
      const { auctionKey, auctionManagerKey } = await (0, _1.getAuctionKeys)(vault);
      const { bidRedemption, bidMetadata } = await (0, _1.getBidderKeys)(auctionKey, bidder);
      const safetyDepositConfig = await (0, _1.getSafetyDepositConfig)(auctionManagerKey, safetyDeposit);
      const value = new deprecatedStates_1.DeprecatedRedeemParticipationBidArgs();
      const data = Buffer.from((0, borsh_1.serialize)(_1.SCHEMA, value));
      const keys = [
          {
              pubkey: (0, utils_1.toPublicKey)(auctionManagerKey),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(safetyDepositTokenStore),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(destination),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(bidRedemption),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(safetyDeposit),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(vault),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(safetyDepositConfig),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(auctionKey),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(bidMetadata),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(bidder),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(payer),
              isSigner: true,
              isWritable: false,
          },
          {
              pubkey: PROGRAM_IDS.token,
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(PROGRAM_IDS.vault),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(PROGRAM_IDS.metadata),
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: store,
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: web3_js_1.SystemProgram.programId,
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
              isSigner: false,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(transferAuthority),
              isSigner: true,
              isWritable: false,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(acceptPaymentAccount),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(tokenPaymentAccount),
              isSigner: false,
              isWritable: true,
          },
          {
              pubkey: (0, utils_1.toPublicKey)(participationPrintingAccount),
              isSigner: false,
              isWritable: true,
          },
      ];
      instructions.push(new web3_js_1.TransactionInstruction({
          keys,
          programId: (0, utils_1.toPublicKey)(PROGRAM_IDS.metaplex),
          data,
      }));
  }
  exports.deprecatedRedeemParticipationBid = deprecatedRedeemParticipationBid;
  //# sourceMappingURL=deprecatedRedeemParticipationBid.js.map