/**
 * 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,
  getU8Decoder,
  getU8Encoder,
  type Address,
  type Codec,
  type Decoder,
  type Encoder,
  type ReadonlyUint8Array,
} from "@solana/kit";

export type SponsoredCCTPQuote = {
  sourceDomain: number;
  destinationDomain: number;
  mintRecipient: Address;
  amount: bigint;
  burnToken: Address;
  destinationCaller: Address;
  maxFee: bigint;
  minFinalityThreshold: number;
  nonce: ReadonlyUint8Array;
  deadline: bigint;
  maxBpsToSponsor: bigint;
  maxUserSlippageBps: bigint;
  finalRecipient: Address;
  finalToken: Address;
  destinationDex: number;
  accountCreationMode: number;
  executionMode: number;
  actionData: ReadonlyUint8Array;
};

export type SponsoredCCTPQuoteArgs = {
  sourceDomain: number;
  destinationDomain: number;
  mintRecipient: Address;
  amount: number | bigint;
  burnToken: Address;
  destinationCaller: Address;
  maxFee: number | bigint;
  minFinalityThreshold: number;
  nonce: ReadonlyUint8Array;
  deadline: number | bigint;
  maxBpsToSponsor: number | bigint;
  maxUserSlippageBps: number | bigint;
  finalRecipient: Address;
  finalToken: Address;
  destinationDex: number;
  accountCreationMode: number;
  executionMode: number;
  actionData: ReadonlyUint8Array;
};

export function getSponsoredCCTPQuoteEncoder(): Encoder<SponsoredCCTPQuoteArgs> {
  return getStructEncoder([
    ["sourceDomain", getU32Encoder()],
    ["destinationDomain", getU32Encoder()],
    ["mintRecipient", getAddressEncoder()],
    ["amount", getU64Encoder()],
    ["burnToken", getAddressEncoder()],
    ["destinationCaller", getAddressEncoder()],
    ["maxFee", getU64Encoder()],
    ["minFinalityThreshold", getU32Encoder()],
    ["nonce", fixEncoderSize(getBytesEncoder(), 32)],
    ["deadline", getU64Encoder()],
    ["maxBpsToSponsor", getU64Encoder()],
    ["maxUserSlippageBps", getU64Encoder()],
    ["finalRecipient", getAddressEncoder()],
    ["finalToken", getAddressEncoder()],
    ["destinationDex", getU32Encoder()],
    ["accountCreationMode", getU8Encoder()],
    ["executionMode", getU8Encoder()],
    ["actionData", addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())],
  ]);
}

export function getSponsoredCCTPQuoteDecoder(): Decoder<SponsoredCCTPQuote> {
  return getStructDecoder([
    ["sourceDomain", getU32Decoder()],
    ["destinationDomain", getU32Decoder()],
    ["mintRecipient", getAddressDecoder()],
    ["amount", getU64Decoder()],
    ["burnToken", getAddressDecoder()],
    ["destinationCaller", getAddressDecoder()],
    ["maxFee", getU64Decoder()],
    ["minFinalityThreshold", getU32Decoder()],
    ["nonce", fixDecoderSize(getBytesDecoder(), 32)],
    ["deadline", getU64Decoder()],
    ["maxBpsToSponsor", getU64Decoder()],
    ["maxUserSlippageBps", getU64Decoder()],
    ["finalRecipient", getAddressDecoder()],
    ["finalToken", getAddressDecoder()],
    ["destinationDex", getU32Decoder()],
    ["accountCreationMode", getU8Decoder()],
    ["executionMode", getU8Decoder()],
    ["actionData", addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())],
  ]);
}

export function getSponsoredCCTPQuoteCodec(): Codec<
  SponsoredCCTPQuoteArgs,
  SponsoredCCTPQuote
> {
  return combineCodec(
    getSponsoredCCTPQuoteEncoder(),
    getSponsoredCCTPQuoteDecoder(),
  );
}
