/**
 * 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,
  fixDecoderSize,
  fixEncoderSize,
  getBytesDecoder,
  getBytesEncoder,
  getStructDecoder,
  getStructEncoder,
  getU32Decoder,
  getU32Encoder,
  type FixedSizeCodec,
  type FixedSizeDecoder,
  type FixedSizeEncoder,
  type ReadonlyUint8Array,
} from "@solana/kit";

export type RelayedRootBundle = {
  rootBundleId: number;
  relayerRefundRoot: ReadonlyUint8Array;
  slowRelayRoot: ReadonlyUint8Array;
};

export type RelayedRootBundleArgs = RelayedRootBundle;

export function getRelayedRootBundleEncoder(): FixedSizeEncoder<RelayedRootBundleArgs> {
  return getStructEncoder([
    ["rootBundleId", getU32Encoder()],
    ["relayerRefundRoot", fixEncoderSize(getBytesEncoder(), 32)],
    ["slowRelayRoot", fixEncoderSize(getBytesEncoder(), 32)],
  ]);
}

export function getRelayedRootBundleDecoder(): FixedSizeDecoder<RelayedRootBundle> {
  return getStructDecoder([
    ["rootBundleId", getU32Decoder()],
    ["relayerRefundRoot", fixDecoderSize(getBytesDecoder(), 32)],
    ["slowRelayRoot", fixDecoderSize(getBytesDecoder(), 32)],
  ]);
}

export function getRelayedRootBundleCodec(): FixedSizeCodec<
  RelayedRootBundleArgs,
  RelayedRootBundle
> {
  return combineCodec(
    getRelayedRootBundleEncoder(),
    getRelayedRootBundleDecoder(),
  );
}
