{"version":3,"file":"SerializerInterface.mjs","sources":["../../src/SerializerInterface.ts"],"sourcesContent":["import type { Nullable, Option } from '@metaplex-foundation/umi-options';\nimport type {\n  PublicKey,\n  PublicKeyInput,\n} from '@metaplex-foundation/umi-public-keys';\nimport type {\n  ArraySerializerOptions,\n  BoolSerializerOptions,\n  BytesSerializerOptions,\n  DataEnumSerializerOptions,\n  DataEnumToSerializerTuple,\n  MapSerializerOptions,\n  NullableSerializerOptions,\n  NumberSerializerOptions,\n  OptionSerializerOptions,\n  PublicKeySerializerOptions,\n  ScalarEnumSerializerOptions,\n  Serializer,\n  SetSerializerOptions,\n  SingleByteNumberSerializerOptions,\n  StringSerializerOptions,\n  StructSerializerOptions,\n  StructToSerializerTuple,\n  TupleSerializerOptions,\n  UnitSerializerOptions,\n  WrapInSerializer,\n} from '@metaplex-foundation/umi-serializers';\nimport { DataEnum, ScalarEnum } from './Enums';\nimport { InterfaceImplementationMissingError } from './errors';\n\n/**\n * Defines the interface for a set of serializers\n * that can be used to serialize/deserialize any Serde types.\n *\n * @category Context and Interfaces\n * @deprecated This interface is deprecated.\n * You can now directly use `@metaplex-foundation/umi/serializers` instead.\n */\nexport interface SerializerInterface {\n  /**\n   * Creates a serializer for a tuple-like array.\n   *\n   * @param items - The serializers to use for each item in the tuple.\n   * @param options - A set of options for the serializer.\n   */\n  tuple: <T extends any[], U extends T = T>(\n    items: WrapInSerializer<[...T], [...U]>,\n    options?: TupleSerializerOptions\n  ) => Serializer<T, U>;\n\n  /**\n   * Creates a serializer for an array of items.\n   *\n   * @param item - The serializer to use for the array's items.\n   * @param options - A set of options for the serializer.\n   */\n  array: <T, U extends T = T>(\n    item: Serializer<T, U>,\n    options?: ArraySerializerOptions\n  ) => Serializer<T[], U[]>;\n\n  /**\n   * Creates a serializer for a map.\n   *\n   * @param key - The serializer to use for the map's keys.\n   * @param value - The serializer to use for the map's values.\n   * @param options - A set of options for the serializer.\n   */\n  map: <TK, TV, UK extends TK = TK, UV extends TV = TV>(\n    key: Serializer<TK, UK>,\n    value: Serializer<TV, UV>,\n    options?: MapSerializerOptions\n  ) => Serializer<Map<TK, TV>, Map<UK, UV>>;\n\n  /**\n   * Creates a serializer for a set.\n   *\n   * @param item - The serializer to use for the set's items.\n   * @param options - A set of options for the serializer.\n   */\n  set: <T, U extends T = T>(\n    item: Serializer<T, U>,\n    options?: SetSerializerOptions\n  ) => Serializer<Set<T>, Set<U>>;\n\n  /**\n   * Creates a serializer for an optional value using the {@link Option} type.\n   *\n   * @param item - The serializer to use for the value that may be present.\n   * @param options - A set of options for the serializer.\n   */\n  option: <T, U extends T = T>(\n    item: Serializer<T, U>,\n    options?: OptionSerializerOptions\n  ) => Serializer<Option<T> | Nullable<T>, Option<U>>;\n\n  /**\n   * Creates a serializer for an optional value using `null` as the `None` value.\n   *\n   * @param item - The serializer to use for the value that may be present.\n   * @param options - A set of options for the serializer.\n   */\n  nullable: <T, U extends T = T>(\n    item: Serializer<T, U>,\n    options?: NullableSerializerOptions\n  ) => Serializer<Nullable<T>, Nullable<U>>;\n\n  /**\n   * Creates a serializer for a custom object.\n   *\n   * @param fields - The name and serializer of each field.\n   * @param options - A set of options for the serializer.\n   */\n  struct: <T extends object, U extends T = T>(\n    fields: StructToSerializerTuple<T, U>,\n    options?: StructSerializerOptions\n  ) => Serializer<T, U>;\n\n  /**\n   * Creates a scalar enum serializer.\n   *\n   * @param constructor - The constructor of the scalar enum.\n   * @param options - A set of options for the serializer.\n   */\n  enum<T>(\n    constructor: ScalarEnum<T> & {},\n    options?: ScalarEnumSerializerOptions\n  ): Serializer<T>;\n\n  /**\n   * Creates a data enum serializer.\n   *\n   * @param variants - The variant serializers of the data enum.\n   * @param options - A set of options for the serializer.\n   */\n  dataEnum<T extends DataEnum, U extends T = T>(\n    variants: DataEnumToSerializerTuple<T, U>,\n    options?: DataEnumSerializerOptions\n  ): Serializer<T, U>;\n\n  /**\n   * Creates a string serializer.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  string: (options?: StringSerializerOptions) => Serializer<string>;\n\n  /**\n   * Creates a boolean serializer.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  bool: (options?: BoolSerializerOptions) => Serializer<boolean>;\n\n  /**\n   * Creates a void serializer.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  unit: (options?: UnitSerializerOptions) => Serializer<void>;\n\n  /**\n   * Creates a serializer for 1-byte unsigned integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  u8: (options?: SingleByteNumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 2-bytes unsigned integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  u16: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 4-bytes unsigned integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  u32: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 8-bytes unsigned integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  u64: (\n    options?: NumberSerializerOptions\n  ) => Serializer<number | bigint, bigint>;\n\n  /**\n   * Creates a serializer for 16-bytes unsigned integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  u128: (\n    options?: NumberSerializerOptions\n  ) => Serializer<number | bigint, bigint>;\n\n  /**\n   * Creates a serializer for 1-byte signed integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  i8: (options?: SingleByteNumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 2-bytes signed integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  i16: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 4-bytes signed integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  i32: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 8-bytes signed integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  i64: (\n    options?: NumberSerializerOptions\n  ) => Serializer<number | bigint, bigint>;\n\n  /**\n   * Creates a serializer for 16-bytes signed integers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  i128: (\n    options?: NumberSerializerOptions\n  ) => Serializer<number | bigint, bigint>;\n\n  /**\n   * Creates a serializer for 4-bytes floating point numbers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  f32: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer for 8-bytes floating point numbers.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  f64: (options?: NumberSerializerOptions) => Serializer<number>;\n\n  /**\n   * Creates a serializer that passes the buffer as-is.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  bytes: (options?: BytesSerializerOptions) => Serializer<Uint8Array>;\n\n  /**\n   * Creates a serializer for 32-bytes public keys.\n   *\n   * @param options - A set of options for the serializer.\n   */\n  publicKey: (\n    options?: PublicKeySerializerOptions\n  ) => Serializer<PublicKey | PublicKeyInput, PublicKey>;\n}\n\n/**\n * An implementation of the {@link SerializerInterface} that throws an error when called.\n * @category Serializers\n */\nexport function createNullSerializer(): SerializerInterface {\n  const errorHandler = () => {\n    throw new InterfaceImplementationMissingError(\n      'SerializerInterface',\n      'serializer'\n    );\n  };\n  return {\n    tuple: errorHandler,\n    array: errorHandler,\n    map: errorHandler,\n    set: errorHandler,\n    option: errorHandler,\n    nullable: errorHandler,\n    struct: errorHandler,\n    enum: errorHandler,\n    dataEnum: errorHandler,\n    string: errorHandler,\n    bool: errorHandler,\n    unit: errorHandler,\n    u8: errorHandler,\n    u16: errorHandler,\n    u32: errorHandler,\n    u64: errorHandler,\n    u128: errorHandler,\n    i8: errorHandler,\n    i16: errorHandler,\n    i32: errorHandler,\n    i64: errorHandler,\n    i128: errorHandler,\n    f32: errorHandler,\n    f64: errorHandler,\n    bytes: errorHandler,\n    publicKey: errorHandler,\n  };\n}\n"],"names":["createNullSerializer","errorHandler","InterfaceImplementationMissingError","tuple","array","map","set","option","nullable","struct","enum","dataEnum","string","bool","unit","u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64","bytes","publicKey"],"mappings":";;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyOA;AACA;AACA;AACA;AACO,SAASA,oBAAoB,GAAwB;EAC1D,MAAMC,YAAY,GAAG,MAAM;AACzB,IAAA,MAAM,IAAIC,mCAAmC,CAC3C,qBAAqB,EACrB,YAAY,CACb,CAAA;GACF,CAAA;EACD,OAAO;AACLC,IAAAA,KAAK,EAAEF,YAAY;AACnBG,IAAAA,KAAK,EAAEH,YAAY;AACnBI,IAAAA,GAAG,EAAEJ,YAAY;AACjBK,IAAAA,GAAG,EAAEL,YAAY;AACjBM,IAAAA,MAAM,EAAEN,YAAY;AACpBO,IAAAA,QAAQ,EAAEP,YAAY;AACtBQ,IAAAA,MAAM,EAAER,YAAY;AACpBS,IAAAA,IAAI,EAAET,YAAY;AAClBU,IAAAA,QAAQ,EAAEV,YAAY;AACtBW,IAAAA,MAAM,EAAEX,YAAY;AACpBY,IAAAA,IAAI,EAAEZ,YAAY;AAClBa,IAAAA,IAAI,EAAEb,YAAY;AAClBc,IAAAA,EAAE,EAAEd,YAAY;AAChBe,IAAAA,GAAG,EAAEf,YAAY;AACjBgB,IAAAA,GAAG,EAAEhB,YAAY;AACjBiB,IAAAA,GAAG,EAAEjB,YAAY;AACjBkB,IAAAA,IAAI,EAAElB,YAAY;AAClBmB,IAAAA,EAAE,EAAEnB,YAAY;AAChBoB,IAAAA,GAAG,EAAEpB,YAAY;AACjBqB,IAAAA,GAAG,EAAErB,YAAY;AACjBsB,IAAAA,GAAG,EAAEtB,YAAY;AACjBuB,IAAAA,IAAI,EAAEvB,YAAY;AAClBwB,IAAAA,GAAG,EAAExB,YAAY;AACjByB,IAAAA,GAAG,EAAEzB,YAAY;AACjB0B,IAAAA,KAAK,EAAE1B,YAAY;AACnB2B,IAAAA,SAAS,EAAE3B,YAAAA;GACZ,CAAA;AACH;;;;"}