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

export type RelayerRefundLeaf = {
  amountToReturn: bigint;
  chainId: bigint;
  refundAmounts: Array<bigint>;
  leafId: number;
  mintPublicKey: Address;
  refundAddresses: Array<Address>;
};

export type RelayerRefundLeafArgs = {
  amountToReturn: number | bigint;
  chainId: number | bigint;
  refundAmounts: Array<number | bigint>;
  leafId: number;
  mintPublicKey: Address;
  refundAddresses: Array<Address>;
};

export function getRelayerRefundLeafEncoder(): Encoder<RelayerRefundLeafArgs> {
  return getStructEncoder([
    ["amountToReturn", getU64Encoder()],
    ["chainId", getU64Encoder()],
    ["refundAmounts", getArrayEncoder(getU64Encoder())],
    ["leafId", getU32Encoder()],
    ["mintPublicKey", getAddressEncoder()],
    ["refundAddresses", getArrayEncoder(getAddressEncoder())],
  ]);
}

export function getRelayerRefundLeafDecoder(): Decoder<RelayerRefundLeaf> {
  return getStructDecoder([
    ["amountToReturn", getU64Decoder()],
    ["chainId", getU64Decoder()],
    ["refundAmounts", getArrayDecoder(getU64Decoder())],
    ["leafId", getU32Decoder()],
    ["mintPublicKey", getAddressDecoder()],
    ["refundAddresses", getArrayDecoder(getAddressDecoder())],
  ]);
}

export function getRelayerRefundLeafCodec(): Codec<
  RelayerRefundLeafArgs,
  RelayerRefundLeaf
> {
  return combineCodec(
    getRelayerRefundLeafEncoder(),
    getRelayerRefundLeafDecoder(),
  );
}
