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

export type ExecutedRelayerRefundRoot = {
  amountToReturn: bigint;
  chainId: bigint;
  refundAmounts: Array<bigint>;
  rootBundleId: number;
  leafId: number;
  l2TokenAddress: Address;
  refundAddresses: Array<Address>;
  deferredRefunds: boolean;
  caller: Address;
};

export type ExecutedRelayerRefundRootArgs = {
  amountToReturn: number | bigint;
  chainId: number | bigint;
  refundAmounts: Array<number | bigint>;
  rootBundleId: number;
  leafId: number;
  l2TokenAddress: Address;
  refundAddresses: Array<Address>;
  deferredRefunds: boolean;
  caller: Address;
};

export function getExecutedRelayerRefundRootEncoder(): Encoder<ExecutedRelayerRefundRootArgs> {
  return getStructEncoder([
    ["amountToReturn", getU64Encoder()],
    ["chainId", getU64Encoder()],
    ["refundAmounts", getArrayEncoder(getU64Encoder())],
    ["rootBundleId", getU32Encoder()],
    ["leafId", getU32Encoder()],
    ["l2TokenAddress", getAddressEncoder()],
    ["refundAddresses", getArrayEncoder(getAddressEncoder())],
    ["deferredRefunds", getBooleanEncoder()],
    ["caller", getAddressEncoder()],
  ]);
}

export function getExecutedRelayerRefundRootDecoder(): Decoder<ExecutedRelayerRefundRoot> {
  return getStructDecoder([
    ["amountToReturn", getU64Decoder()],
    ["chainId", getU64Decoder()],
    ["refundAmounts", getArrayDecoder(getU64Decoder())],
    ["rootBundleId", getU32Decoder()],
    ["leafId", getU32Decoder()],
    ["l2TokenAddress", getAddressDecoder()],
    ["refundAddresses", getArrayDecoder(getAddressDecoder())],
    ["deferredRefunds", getBooleanDecoder()],
    ["caller", getAddressDecoder()],
  ]);
}

export function getExecutedRelayerRefundRootCodec(): Codec<
  ExecutedRelayerRefundRootArgs,
  ExecutedRelayerRefundRoot
> {
  return combineCodec(
    getExecutedRelayerRefundRootEncoder(),
    getExecutedRelayerRefundRootDecoder(),
  );
}
