/**
 * 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 {
  combineCodec,
  getDiscriminatedUnionDecoder,
  getDiscriminatedUnionEncoder,
  getStructDecoder,
  getStructEncoder,
  getU64Decoder,
  getU64Encoder,
  type FixedSizeCodec,
  type FixedSizeDecoder,
  type FixedSizeEncoder,
  type GetDiscriminatedUnionVariant,
  type GetDiscriminatedUnionVariantContent,
} from '@solana/kit';

export type BurnArgs = { __kind: 'V1'; amount: bigint };

export type BurnArgsArgs = { __kind: 'V1'; amount: number | bigint };

export function getBurnArgsEncoder(): FixedSizeEncoder<BurnArgsArgs> {
  return getDiscriminatedUnionEncoder([
    ['V1', getStructEncoder([['amount', getU64Encoder()]])],
  ]) as FixedSizeEncoder<BurnArgsArgs>;
}

export function getBurnArgsDecoder(): FixedSizeDecoder<BurnArgs> {
  return getDiscriminatedUnionDecoder([
    ['V1', getStructDecoder([['amount', getU64Decoder()]])],
  ]) as FixedSizeDecoder<BurnArgs>;
}

export function getBurnArgsCodec(): FixedSizeCodec<BurnArgsArgs, BurnArgs> {
  return combineCodec(
    getBurnArgsEncoder(),
    getBurnArgsDecoder()
  ) as FixedSizeCodec<BurnArgsArgs, BurnArgs>;
}

// Data Enum Helpers.
export function burnArgs(
  kind: 'V1',
  data: GetDiscriminatedUnionVariantContent<BurnArgsArgs, '__kind', 'V1'>
): GetDiscriminatedUnionVariant<BurnArgsArgs, '__kind', 'V1'>;
export function burnArgs<K extends BurnArgsArgs['__kind'], Data>(
  kind: K,
  data?: Data
) {
  return Array.isArray(data)
    ? { __kind: kind, fields: data }
    : { __kind: kind, ...(data ?? {}) };
}

export function isBurnArgs<K extends BurnArgs['__kind']>(
  kind: K,
  value: BurnArgs
): value is BurnArgs & { __kind: K } {
  return value.__kind === kind;
}
