/**
 * 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 {
  addDecoderSizePrefix,
  addEncoderSizePrefix,
  combineCodec,
  getAddressDecoder,
  getAddressEncoder,
  getBytesDecoder,
  getBytesEncoder,
  getStructDecoder,
  getStructEncoder,
  getU32Decoder,
  getU32Encoder,
  type Address,
  type Codec,
  type Decoder,
  type Encoder,
  type ReadonlyUint8Array,
} from "@solana/kit";

export type ReclaimedUsedNonceAccount = {
  nonce: ReadonlyUint8Array;
  usedNonce: Address;
};

export type ReclaimedUsedNonceAccountArgs = ReclaimedUsedNonceAccount;

export function getReclaimedUsedNonceAccountEncoder(): Encoder<ReclaimedUsedNonceAccountArgs> {
  return getStructEncoder([
    ["nonce", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
    ["usedNonce", getAddressEncoder()],
  ]);
}

export function getReclaimedUsedNonceAccountDecoder(): Decoder<ReclaimedUsedNonceAccount> {
  return getStructDecoder([
    ["nonce", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
    ["usedNonce", getAddressDecoder()],
  ]);
}

export function getReclaimedUsedNonceAccountCodec(): Codec<
  ReclaimedUsedNonceAccountArgs,
  ReclaimedUsedNonceAccount
> {
  return combineCodec(
    getReclaimedUsedNonceAccountEncoder(),
    getReclaimedUsedNonceAccountDecoder(),
  );
}
