/**
 * 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,
  getAddressDecoder,
  getAddressEncoder,
  getBytesDecoder,
  getBytesEncoder,
  getStructDecoder,
  getStructEncoder,
  getU64Decoder,
  getU64Encoder,
  type Address,
  type FixedSizeCodec,
  type FixedSizeDecoder,
  type FixedSizeEncoder,
  type ReadonlyUint8Array,
} from "@solana/kit";
import {
  getFillTypeDecoder,
  getFillTypeEncoder,
  type FillType,
  type FillTypeArgs,
} from ".";

export type RelayExecutionEventInfo = {
  updatedRecipient: Address;
  updatedMessageHash: ReadonlyUint8Array;
  updatedOutputAmount: bigint;
  fillType: FillType;
};

export type RelayExecutionEventInfoArgs = {
  updatedRecipient: Address;
  updatedMessageHash: ReadonlyUint8Array;
  updatedOutputAmount: number | bigint;
  fillType: FillTypeArgs;
};

export function getRelayExecutionEventInfoEncoder(): FixedSizeEncoder<RelayExecutionEventInfoArgs> {
  return getStructEncoder([
    ["updatedRecipient", getAddressEncoder()],
    ["updatedMessageHash", fixEncoderSize(getBytesEncoder(), 32)],
    ["updatedOutputAmount", getU64Encoder()],
    ["fillType", getFillTypeEncoder()],
  ]);
}

export function getRelayExecutionEventInfoDecoder(): FixedSizeDecoder<RelayExecutionEventInfo> {
  return getStructDecoder([
    ["updatedRecipient", getAddressDecoder()],
    ["updatedMessageHash", fixDecoderSize(getBytesDecoder(), 32)],
    ["updatedOutputAmount", getU64Decoder()],
    ["fillType", getFillTypeDecoder()],
  ]);
}

export function getRelayExecutionEventInfoCodec(): FixedSizeCodec<
  RelayExecutionEventInfoArgs,
  RelayExecutionEventInfo
> {
  return combineCodec(
    getRelayExecutionEventInfoEncoder(),
    getRelayExecutionEventInfoDecoder(),
  );
}
