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

    Interface URDecodable

    A type that can be decoded from a UR (Uniform Resource).

    Types implementing this interface should be able to create themselves from a UR containing their data.

    class MyType implements URDecodable {
    fromUR(ur: UR): MyType {
    const cbor = ur.cbor();
    // Decode from CBOR and return MyType instance
    }

    fromURString(urString: string): MyType {
    return this.fromUR(UR.fromURString(urString));
    }
    }
    interface URDecodable {
        fromUR(ur: UR): unknown;
        fromURString?(urString: string): unknown;
    }

    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