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

export type RelayData = {
  depositor: Address;
  recipient: Address;
  exclusiveRelayer: Address;
  inputToken: Address;
  outputToken: Address;
  inputAmount: ReadonlyUint8Array;
  outputAmount: bigint;
  originChainId: bigint;
  depositId: ReadonlyUint8Array;
  fillDeadline: number;
  exclusivityDeadline: number;
  message: ReadonlyUint8Array;
};

export type RelayDataArgs = {
  depositor: Address;
  recipient: Address;
  exclusiveRelayer: Address;
  inputToken: Address;
  outputToken: Address;
  inputAmount: ReadonlyUint8Array;
  outputAmount: number | bigint;
  originChainId: number | bigint;
  depositId: ReadonlyUint8Array;
  fillDeadline: number;
  exclusivityDeadline: number;
  message: ReadonlyUint8Array;
};

export function getRelayDataEncoder(): Encoder<RelayDataArgs> {
  return getStructEncoder([
    ["depositor", getAddressEncoder()],
    ["recipient", getAddressEncoder()],
    ["exclusiveRelayer", getAddressEncoder()],
    ["inputToken", getAddressEncoder()],
    ["outputToken", getAddressEncoder()],
    ["inputAmount", fixEncoderSize(getBytesEncoder(), 32)],
    ["outputAmount", getU64Encoder()],
    ["originChainId", getU64Encoder()],
    ["depositId", fixEncoderSize(getBytesEncoder(), 32)],
    ["fillDeadline", getU32Encoder()],
    ["exclusivityDeadline", getU32Encoder()],
    ["message", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
  ]);
}

export function getRelayDataDecoder(): Decoder<RelayData> {
  return getStructDecoder([
    ["depositor", getAddressDecoder()],
    ["recipient", getAddressDecoder()],
    ["exclusiveRelayer", getAddressDecoder()],
    ["inputToken", getAddressDecoder()],
    ["outputToken", getAddressDecoder()],
    ["inputAmount", fixDecoderSize(getBytesDecoder(), 32)],
    ["outputAmount", getU64Decoder()],
    ["originChainId", getU64Decoder()],
    ["depositId", fixDecoderSize(getBytesDecoder(), 32)],
    ["fillDeadline", getU32Decoder()],
    ["exclusivityDeadline", getU32Decoder()],
    ["message", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
  ]);
}

export function getRelayDataCodec(): Codec<RelayDataArgs, RelayData> {
  return combineCodec(getRelayDataEncoder(), getRelayDataDecoder());
}
