/**
 * 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 {
  assertIsInstructionWithAccounts,
  containsBytes,
  fixEncoderSize,
  getBytesEncoder,
  type Address,
  type Instruction,
  type InstructionWithData,
  type ReadonlyUint8Array,
} from "@solana/kit";
import {
  parseAcceptOwnershipInstruction,
  parseAddLocalTokenInstruction,
  parseAddRemoteTokenMessengerInstruction,
  parseBurnTokenCustodyInstruction,
  parseDenylistAccountInstruction,
  parseDepositForBurnInstruction,
  parseDepositForBurnWithHookInstruction,
  parseHandleReceiveFinalizedMessageInstruction,
  parseHandleReceiveUnfinalizedMessageInstruction,
  parseInitializeInstruction,
  parseLinkTokenPairInstruction,
  parsePauseInstruction,
  parseRemoveLocalTokenInstruction,
  parseRemoveRemoteTokenMessengerInstruction,
  parseSetFeeRecipientInstruction,
  parseSetMaxBurnAmountPerMessageInstruction,
  parseSetMinFeeControllerInstruction,
  parseSetMinFeeInstruction,
  parseSetTokenControllerInstruction,
  parseTransferOwnershipInstruction,
  parseUndenylistAccountInstruction,
  parseUnlinkTokenPairInstruction,
  parseUnpauseInstruction,
  parseUpdateDenylisterInstruction,
  parseUpdatePauserInstruction,
  type ParsedAcceptOwnershipInstruction,
  type ParsedAddLocalTokenInstruction,
  type ParsedAddRemoteTokenMessengerInstruction,
  type ParsedBurnTokenCustodyInstruction,
  type ParsedDenylistAccountInstruction,
  type ParsedDepositForBurnInstruction,
  type ParsedDepositForBurnWithHookInstruction,
  type ParsedHandleReceiveFinalizedMessageInstruction,
  type ParsedHandleReceiveUnfinalizedMessageInstruction,
  type ParsedInitializeInstruction,
  type ParsedLinkTokenPairInstruction,
  type ParsedPauseInstruction,
  type ParsedRemoveLocalTokenInstruction,
  type ParsedRemoveRemoteTokenMessengerInstruction,
  type ParsedSetFeeRecipientInstruction,
  type ParsedSetMaxBurnAmountPerMessageInstruction,
  type ParsedSetMinFeeControllerInstruction,
  type ParsedSetMinFeeInstruction,
  type ParsedSetTokenControllerInstruction,
  type ParsedTransferOwnershipInstruction,
  type ParsedUndenylistAccountInstruction,
  type ParsedUnlinkTokenPairInstruction,
  type ParsedUnpauseInstruction,
  type ParsedUpdateDenylisterInstruction,
  type ParsedUpdatePauserInstruction,
} from "../instructions";

export const TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS =
  "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" as Address<"CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe">;

export enum TokenMessengerMinterV2Account {
  DenylistedAccount,
  LocalToken,
  MessageTransmitter,
  RemoteTokenMessenger,
  TokenMessenger,
  TokenMinter,
  TokenPair,
}

export function identifyTokenMessengerMinterV2Account(
  account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): TokenMessengerMinterV2Account {
  const data = "data" in account ? account.data : account;
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([186, 58, 212, 239, 102, 131, 157, 146]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.DenylistedAccount;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([159, 131, 58, 170, 193, 84, 128, 182]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.LocalToken;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.MessageTransmitter;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([105, 115, 174, 34, 95, 233, 138, 252]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.RemoteTokenMessenger;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([162, 4, 242, 52, 147, 243, 221, 96]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.TokenMessenger;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([122, 133, 84, 63, 57, 159, 171, 206]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.TokenMinter;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([17, 214, 45, 176, 229, 149, 197, 71]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Account.TokenPair;
  }
  throw new Error(
    "The provided account could not be identified as a tokenMessengerMinterV2 account.",
  );
}

export enum TokenMessengerMinterV2Instruction {
  AcceptOwnership,
  AddLocalToken,
  AddRemoteTokenMessenger,
  BurnTokenCustody,
  DenylistAccount,
  DepositForBurn,
  DepositForBurnWithHook,
  HandleReceiveFinalizedMessage,
  HandleReceiveUnfinalizedMessage,
  Initialize,
  LinkTokenPair,
  Pause,
  RemoveLocalToken,
  RemoveRemoteTokenMessenger,
  SetFeeRecipient,
  SetMaxBurnAmountPerMessage,
  SetMinFee,
  SetMinFeeController,
  SetTokenController,
  TransferOwnership,
  UndenylistAccount,
  UnlinkTokenPair,
  Unpause,
  UpdateDenylister,
  UpdatePauser,
}

export function identifyTokenMessengerMinterV2Instruction(
  instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
): TokenMessengerMinterV2Instruction {
  const data = "data" in instruction ? instruction.data : instruction;
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.AcceptOwnership;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([213, 199, 205, 18, 98, 124, 73, 198]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.AddLocalToken;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([12, 149, 172, 165, 111, 202, 24, 33]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([233, 136, 180, 175, 112, 41, 62, 71]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.BurnTokenCustody;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([101, 116, 197, 112, 81, 249, 75, 194]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.DenylistAccount;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.DepositForBurn;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([111, 245, 62, 131, 204, 108, 223, 155]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.DepositForBurnWithHook;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([186, 252, 239, 70, 86, 180, 110, 95]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([200, 169, 175, 20, 200, 58, 182, 61]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.Initialize;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([68, 162, 24, 104, 125, 46, 130, 12]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.LinkTokenPair;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.Pause;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([27, 43, 66, 170, 188, 44, 109, 97]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.RemoveLocalToken;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([65, 114, 66, 85, 169, 98, 177, 146]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([227, 18, 215, 42, 237, 246, 151, 66]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.SetFeeRecipient;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([30, 128, 145, 240, 70, 237, 109, 207]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([114, 198, 35, 3, 41, 196, 194, 246]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.SetMinFee;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([195, 142, 74, 84, 234, 94, 180, 113]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.SetMinFeeController;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([88, 6, 98, 10, 79, 59, 15, 24]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.SetTokenController;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.TransferOwnership;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([57, 36, 43, 168, 62, 172, 33, 39]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.UndenylistAccount;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([52, 198, 100, 114, 104, 174, 85, 58]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.UnlinkTokenPair;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.Unpause;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([193, 66, 198, 201, 84, 57, 14, 222]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.UpdateDenylister;
  }
  if (
    containsBytes(
      data,
      fixEncoderSize(getBytesEncoder(), 8).encode(
        new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]),
      ),
      0,
    )
  ) {
    return TokenMessengerMinterV2Instruction.UpdatePauser;
  }
  throw new Error(
    "The provided instruction could not be identified as a tokenMessengerMinterV2 instruction.",
  );
}

export type ParsedTokenMessengerMinterV2Instruction<
  TProgram extends string = "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe",
> =
  | ({
      instructionType: TokenMessengerMinterV2Instruction.AcceptOwnership;
    } & ParsedAcceptOwnershipInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.AddLocalToken;
    } & ParsedAddLocalTokenInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger;
    } & ParsedAddRemoteTokenMessengerInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.BurnTokenCustody;
    } & ParsedBurnTokenCustodyInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.DenylistAccount;
    } & ParsedDenylistAccountInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.DepositForBurn;
    } & ParsedDepositForBurnInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.DepositForBurnWithHook;
    } & ParsedDepositForBurnWithHookInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage;
    } & ParsedHandleReceiveFinalizedMessageInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage;
    } & ParsedHandleReceiveUnfinalizedMessageInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.Initialize;
    } & ParsedInitializeInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.LinkTokenPair;
    } & ParsedLinkTokenPairInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.Pause;
    } & ParsedPauseInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.RemoveLocalToken;
    } & ParsedRemoveLocalTokenInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger;
    } & ParsedRemoveRemoteTokenMessengerInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.SetFeeRecipient;
    } & ParsedSetFeeRecipientInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage;
    } & ParsedSetMaxBurnAmountPerMessageInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.SetMinFee;
    } & ParsedSetMinFeeInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.SetMinFeeController;
    } & ParsedSetMinFeeControllerInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.SetTokenController;
    } & ParsedSetTokenControllerInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.TransferOwnership;
    } & ParsedTransferOwnershipInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.UndenylistAccount;
    } & ParsedUndenylistAccountInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.UnlinkTokenPair;
    } & ParsedUnlinkTokenPairInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.Unpause;
    } & ParsedUnpauseInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.UpdateDenylister;
    } & ParsedUpdateDenylisterInstruction<TProgram>)
  | ({
      instructionType: TokenMessengerMinterV2Instruction.UpdatePauser;
    } & ParsedUpdatePauserInstruction<TProgram>);

export function parseTokenMessengerMinterV2Instruction<TProgram extends string>(
  instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
): ParsedTokenMessengerMinterV2Instruction<TProgram> {
  const instructionType =
    identifyTokenMessengerMinterV2Instruction(instruction);
  switch (instructionType) {
    case TokenMessengerMinterV2Instruction.AcceptOwnership: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.AcceptOwnership,
        ...parseAcceptOwnershipInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.AddLocalToken: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.AddLocalToken,
        ...parseAddLocalTokenInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger,
        ...parseAddRemoteTokenMessengerInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.BurnTokenCustody: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.BurnTokenCustody,
        ...parseBurnTokenCustodyInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.DenylistAccount: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.DenylistAccount,
        ...parseDenylistAccountInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.DepositForBurn: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.DepositForBurn,
        ...parseDepositForBurnInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.DepositForBurnWithHook: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.DepositForBurnWithHook,
        ...parseDepositForBurnWithHookInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage,
        ...parseHandleReceiveFinalizedMessageInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage,
        ...parseHandleReceiveUnfinalizedMessageInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.Initialize: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.Initialize,
        ...parseInitializeInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.LinkTokenPair: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.LinkTokenPair,
        ...parseLinkTokenPairInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.Pause: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.Pause,
        ...parsePauseInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.RemoveLocalToken: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.RemoveLocalToken,
        ...parseRemoveLocalTokenInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger,
        ...parseRemoveRemoteTokenMessengerInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.SetFeeRecipient: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.SetFeeRecipient,
        ...parseSetFeeRecipientInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType:
          TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage,
        ...parseSetMaxBurnAmountPerMessageInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.SetMinFee: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.SetMinFee,
        ...parseSetMinFeeInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.SetMinFeeController: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.SetMinFeeController,
        ...parseSetMinFeeControllerInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.SetTokenController: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.SetTokenController,
        ...parseSetTokenControllerInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.TransferOwnership: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.TransferOwnership,
        ...parseTransferOwnershipInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.UndenylistAccount: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.UndenylistAccount,
        ...parseUndenylistAccountInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.UnlinkTokenPair: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.UnlinkTokenPair,
        ...parseUnlinkTokenPairInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.Unpause: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.Unpause,
        ...parseUnpauseInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.UpdateDenylister: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.UpdateDenylister,
        ...parseUpdateDenylisterInstruction(instruction),
      };
    }
    case TokenMessengerMinterV2Instruction.UpdatePauser: {
      assertIsInstructionWithAccounts(instruction);
      return {
        instructionType: TokenMessengerMinterV2Instruction.UpdatePauser,
        ...parseUpdatePauserInstruction(instruction),
      };
    }
    default:
      throw new Error(
        `Unrecognized instruction type: ${instructionType as string}`,
      );
  }
}
