/**
 * This code was GENERATED using the solita package.
 * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
 *
 * See: https://github.com/metaplex-foundation/solita
 */

import * as beet from '@metaplex-foundation/beet';
import * as web3 from '@solana/web3.js';

/**
 * @category Instructions
 * @category PickUpCar
 * @category generated
 */
export const PickUpCarStruct = new beet.BeetArgsStruct<{
  instructionDiscriminator: number;
}>([['instructionDiscriminator', beet.u8]], 'PickUpCarInstructionArgs');
/**
 * Accounts required by the _PickUpCar_ instruction
 *
 * @property [_writable_] rentalAccount The account representing the active rental
 * @property [] carAccount The account representing the Car being rented in this order
 * @property [_writable_] payer Fee payer
 * @category Instructions
 * @category PickUpCar
 * @category generated
 */
export type PickUpCarInstructionAccounts = {
  rentalAccount: web3.PublicKey;
  carAccount: web3.PublicKey;
  payer: web3.PublicKey;
};

export const pickUpCarInstructionDiscriminator = 2;

/**
 * Creates a _PickUpCar_ instruction.
 *
 * @param accounts that will be accessed while the instruction is processed
 * @category Instructions
 * @category PickUpCar
 * @category generated
 */
export function createPickUpCarInstruction(
  accounts: PickUpCarInstructionAccounts,
  programId = new web3.PublicKey('8avNGHVXDwsELJaWMSoUZ44CirQd4zyU9Ez4ZmP4jNjZ'),
) {
  const [data] = PickUpCarStruct.serialize({
    instructionDiscriminator: pickUpCarInstructionDiscriminator,
  });
  const keys: web3.AccountMeta[] = [
    {
      pubkey: accounts.rentalAccount,
      isWritable: true,
      isSigner: false,
    },
    {
      pubkey: accounts.carAccount,
      isWritable: false,
      isSigner: false,
    },
    {
      pubkey: accounts.payer,
      isWritable: true,
      isSigner: false,
    },
  ];

  const ix = new web3.TransactionInstruction({
    programId,
    keys,
    data,
  });
  return ix;
}
