Blockchain Commons Uniform Resources TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Interface URCodable

    A type that can be both encoded to and decoded from a UR.

    This combines the UREncodable and URDecodable interfaces for types that support bidirectional UR conversion.

    class MyType implements URCodable {
    ur(): UR {
    // Encode to UR
    }

    urString(): string {
    // Return UR string
    }

    fromUR(ur: UR): MyType {
    // Decode from UR
    }

    fromURString(urString: string): MyType {
    // Decode from UR string (convenience method)
    return this.fromUR(UR.fromURString(urString));
    }
    }
    interface URCodable {
        fromUR(ur: UR): unknown;
        fromURString?(urString: string): unknown;
        ur(): UR;
        urString(): string;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Creates an instance of this type from a UR.

      Parameters

      • ur: UR

        The UR to decode from

      Returns unknown

      An instance of this type

      If the UR type is wrong or data is malformed

    • Creates an instance of this type from a UR string.

      This is a convenience method that parses the UR string and then calls fromUR().

      Parameters

      • urString: string

        The UR string to decode from (e.g., "ur:type/...")

      Returns unknown

      An instance of this type

      If the UR string is invalid or data is malformed