Umi — API References - v1.3.0
    Preparing search index...

    Interface SerializerInterface

    Defines the interface for a set of serializers that can be used to serialize/deserialize any Serde types.

    This interface is deprecated. You can now directly use @metaplex-foundation/umi/serializers instead.

    interface SerializerInterface {
        array: <T, U = T>(
            item: Serializer<T, U>,
            options?: ArraySerializerOptions,
        ) => Serializer<T[], U[]>;
        bool: (options?: BoolSerializerOptions) => Serializer<boolean>;
        bytes: (
            options?: BytesSerializerOptions,
        ) => Serializer<Uint8Array<ArrayBufferLike>>;
        f32: (options?: NumberSerializerOptions) => Serializer<number>;
        f64: (options?: NumberSerializerOptions) => Serializer<number>;
        i128: (
            options?: NumberSerializerOptions,
        ) => Serializer<number | bigint, bigint>;
        i16: (options?: NumberSerializerOptions) => Serializer<number>;
        i32: (options?: NumberSerializerOptions) => Serializer<number>;
        i64: (
            options?: NumberSerializerOptions,
        ) => Serializer<number | bigint, bigint>;
        i8: (options?: BaseSerializerOptions) => Serializer<number>;
        map: <TK, TV, UK = TK, UV = TV>(
            key: Serializer<TK, UK>,
            value: Serializer<TV, UV>,
            options?: MapSerializerOptions,
        ) => Serializer<Map<TK, TV>, Map<UK, UV>>;
        nullable: <T, U = T>(
            item: Serializer<T, U>,
            options?: NullableSerializerOptions,
        ) => Serializer<Nullable<T>, Nullable<U>>;
        option: <T, U = T>(
            item: Serializer<T, U>,
            options?: OptionSerializerOptions,
        ) => Serializer<Option<T> | Nullable<T>, Option<U>>;
        publicKey: (
            options?: BaseSerializerOptions,
        ) => Serializer<PublicKey | PublicKeyInput, PublicKey>;
        set: <T, U = T>(
            item: Serializer<T, U>,
            options?: SetSerializerOptions,
        ) => Serializer<Set<T>, Set<U>>;
        string: (options?: StringSerializerOptions) => Serializer<string>;
        struct: <T extends object, U extends object = T>(
            fields: StructToSerializerTuple<T, U>,
            options?: BaseSerializerOptions,
        ) => Serializer<T, U>;
        tuple: <T extends any[], U extends any[] = T>(
            items: [...WrapInSerializer<T, [...U[]]>[]],
            options?: BaseSerializerOptions,
        ) => Serializer<T, U>;
        u128: (
            options?: NumberSerializerOptions,
        ) => Serializer<number | bigint, bigint>;
        u16: (options?: NumberSerializerOptions) => Serializer<number>;
        u32: (options?: NumberSerializerOptions) => Serializer<number>;
        u64: (
            options?: NumberSerializerOptions,
        ) => Serializer<number | bigint, bigint>;
        u8: (options?: BaseSerializerOptions) => Serializer<number>;
        unit: (options?: BaseSerializerOptions) => Serializer<void>;
        dataEnum<T extends DataEnum, U extends DataEnum = T>(
            variants: DataEnumToSerializerTuple<T, U>,
            options?: DataEnumSerializerOptions,
        ): Serializer<T, U>;
        enum<T>(
            constructor: ScalarEnum<T> & {},
            options?: ScalarEnumSerializerOptions,
        ): Serializer<T>;
    }
    Index

    Properties

    array: <T, U = T>(
        item: Serializer<T, U>,
        options?: ArraySerializerOptions,
    ) => Serializer<T[], U[]>

    Creates a serializer for an array of items.

    Type Declaration

      • <T, U = T>(
            item: Serializer<T, U>,
            options?: ArraySerializerOptions,
        ): Serializer<T[], U[]>
      • Type Parameters

        • T
        • U = T

        Parameters

        • item: Serializer<T, U>

          The serializer to use for the array's items.

        • Optionaloptions: ArraySerializerOptions

          A set of options for the serializer.

        Returns Serializer<T[], U[]>

    bool: (options?: BoolSerializerOptions) => Serializer<boolean>

    Creates a boolean serializer.

    Type Declaration

      • (options?: BoolSerializerOptions): Serializer<boolean>
      • Parameters

        • Optionaloptions: BoolSerializerOptions

          A set of options for the serializer.

        Returns Serializer<boolean>

    bytes: (
        options?: BytesSerializerOptions,
    ) => Serializer<Uint8Array<ArrayBufferLike>>

    Creates a serializer that passes the buffer as-is.

    Type Declaration

      • (options?: BytesSerializerOptions): Serializer<Uint8Array<ArrayBufferLike>>
      • Parameters

        • Optionaloptions: BytesSerializerOptions

          A set of options for the serializer.

        Returns Serializer<Uint8Array<ArrayBufferLike>>

    f32: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 4-bytes floating point numbers.

    Type Declaration

    f64: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 8-bytes floating point numbers.

    Type Declaration

    i128: (options?: NumberSerializerOptions) => Serializer<number | bigint, bigint>

    Creates a serializer for 16-bytes signed integers.

    Type Declaration

    i16: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 2-bytes signed integers.

    Type Declaration

    i32: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 4-bytes signed integers.

    Type Declaration

    i64: (options?: NumberSerializerOptions) => Serializer<number | bigint, bigint>

    Creates a serializer for 8-bytes signed integers.

    Type Declaration

    i8: (options?: BaseSerializerOptions) => Serializer<number>

    Creates a serializer for 1-byte signed integers.

    Type Declaration

    map: <TK, TV, UK = TK, UV = TV>(
        key: Serializer<TK, UK>,
        value: Serializer<TV, UV>,
        options?: MapSerializerOptions,
    ) => Serializer<Map<TK, TV>, Map<UK, UV>>

    Creates a serializer for a map.

    Type Declaration

      • <TK, TV, UK = TK, UV = TV>(
            key: Serializer<TK, UK>,
            value: Serializer<TV, UV>,
            options?: MapSerializerOptions,
        ): Serializer<Map<TK, TV>, Map<UK, UV>>
      • Type Parameters

        • TK
        • TV
        • UK = TK
        • UV = TV

        Parameters

        • key: Serializer<TK, UK>

          The serializer to use for the map's keys.

        • value: Serializer<TV, UV>

          The serializer to use for the map's values.

        • Optionaloptions: MapSerializerOptions

          A set of options for the serializer.

        Returns Serializer<Map<TK, TV>, Map<UK, UV>>

    nullable: <T, U = T>(
        item: Serializer<T, U>,
        options?: NullableSerializerOptions,
    ) => Serializer<Nullable<T>, Nullable<U>>

    Creates a serializer for an optional value using null as the None value.

    Type Declaration

    option: <T, U = T>(
        item: Serializer<T, U>,
        options?: OptionSerializerOptions,
    ) => Serializer<Option<T> | Nullable<T>, Option<U>>

    Creates a serializer for an optional value using the Option type.

    Type Declaration

    publicKey: (
        options?: BaseSerializerOptions,
    ) => Serializer<PublicKey | PublicKeyInput, PublicKey>

    Creates a serializer for 32-bytes public keys.

    Type Declaration

    set: <T, U = T>(
        item: Serializer<T, U>,
        options?: SetSerializerOptions,
    ) => Serializer<Set<T>, Set<U>>

    Creates a serializer for a set.

    Type Declaration

      • <T, U = T>(
            item: Serializer<T, U>,
            options?: SetSerializerOptions,
        ): Serializer<Set<T>, Set<U>>
      • Type Parameters

        • T
        • U = T

        Parameters

        • item: Serializer<T, U>

          The serializer to use for the set's items.

        • Optionaloptions: SetSerializerOptions

          A set of options for the serializer.

        Returns Serializer<Set<T>, Set<U>>

    string: (options?: StringSerializerOptions) => Serializer<string>

    Creates a string serializer.

    Type Declaration

      • (options?: StringSerializerOptions): Serializer<string>
      • Parameters

        • Optionaloptions: StringSerializerOptions

          A set of options for the serializer.

        Returns Serializer<string>

    struct: <T extends object, U extends object = T>(
        fields: StructToSerializerTuple<T, U>,
        options?: BaseSerializerOptions,
    ) => Serializer<T, U>

    Creates a serializer for a custom object.

    Type Declaration

      • <T extends object, U extends object = T>(
            fields: StructToSerializerTuple<T, U>,
            options?: BaseSerializerOptions,
        ): Serializer<T, U>
      • Type Parameters

        • T extends object
        • U extends object = T

        Parameters

        • fields: StructToSerializerTuple<T, U>

          The name and serializer of each field.

        • Optionaloptions: BaseSerializerOptions

          A set of options for the serializer.

        Returns Serializer<T, U>

    tuple: <T extends any[], U extends any[] = T>(
        items: [...WrapInSerializer<T, [...U[]]>[]],
        options?: BaseSerializerOptions,
    ) => Serializer<T, U>

    Creates a serializer for a tuple-like array.

    Type Declaration

    u128: (options?: NumberSerializerOptions) => Serializer<number | bigint, bigint>

    Creates a serializer for 16-bytes unsigned integers.

    Type Declaration

    u16: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 2-bytes unsigned integers.

    Type Declaration

    u32: (options?: NumberSerializerOptions) => Serializer<number>

    Creates a serializer for 4-bytes unsigned integers.

    Type Declaration

    u64: (options?: NumberSerializerOptions) => Serializer<number | bigint, bigint>

    Creates a serializer for 8-bytes unsigned integers.

    Type Declaration

    u8: (options?: BaseSerializerOptions) => Serializer<number>

    Creates a serializer for 1-byte unsigned integers.

    Type Declaration

    unit: (options?: BaseSerializerOptions) => Serializer<void>

    Creates a void serializer.

    Type Declaration

    Methods

    • Creates a data enum serializer.

      Type Parameters

      • T extends DataEnum
      • U extends DataEnum = T

      Parameters

      • variants: DataEnumToSerializerTuple<T, U>

        The variant serializers of the data enum.

      • Optionaloptions: DataEnumSerializerOptions

        A set of options for the serializer.

      Returns Serializer<T, U>

    • Creates a scalar enum serializer.

      Type Parameters

      • T

      Parameters

      • constructor: ScalarEnum<T> & {}

        The constructor of the scalar enum.

      • Optionaloptions: ScalarEnumSerializerOptions

        A set of options for the serializer.

      Returns Serializer<T>