DRep.ts
DRep overview
Table of contents
- arbitrary
- constructors
- encoding
- model
- parsing
- pattern matching
- predicates
- schemas
- transformations
- type guards
- utils
arbitrary
arbitrary
FastCheck arbitrary for generating random DRep instances.
Signature
export declare const arbitrary: FastCheck.Arbitrary<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep
>Added in v2.0.0
constructors
alwaysAbstain
Create an AlwaysAbstainDRep.
Signature
export declare const alwaysAbstain: () => AlwaysAbstainDRepAdded in v2.0.0
alwaysNoConfidence
Create an AlwaysNoConfidenceDRep.
Signature
export declare const alwaysNoConfidence: () => AlwaysNoConfidenceDRepAdded in v2.0.0
fromKeyHash
Create a KeyHashDRep from a KeyHash.
Signature
export declare const fromKeyHash: (keyHash: KeyHash.KeyHash) => KeyHashDRepAdded in v2.0.0
fromScriptHash
Create a ScriptHashDRep from a ScriptHash.
Signature
export declare const fromScriptHash: (scriptHash: ScriptHash.ScriptHash) => ScriptHashDRepAdded in v2.0.0
encoding
toBech32
Encode DRep to Bech32 string (CIP-129 format).
Signature
export declare const toBech32: (
a: KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
overrideOptions?: ParseOptions
) => stringAdded in v2.0.0
toBytes
Encode DRep to CIP-129 bytes (KeyHashDRep or ScriptHashDRep only).
Signature
export declare const toBytes: (
a: KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
overrideOptions?: ParseOptions
) => anyAdded in v2.0.0
toCBORBytes
Encode DRep to CBOR bytes.
Signature
export declare const toCBORBytes: (
options?: CBOR.CodecOptions
) => (
a: KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
overrideOptions?: ParseOptions
) => anyAdded in v2.0.0
toCBORHex
Encode DRep to CBOR hex string.
Signature
export declare const toCBORHex: (
options?: CBOR.CodecOptions
) => (
a: KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
overrideOptions?: ParseOptions
) => stringAdded in v2.0.0
toHex
Encode DRep to hex string.
Signature
export declare const toHex: (
a: KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
overrideOptions?: ParseOptions
) => stringAdded in v2.0.0
model
AlwaysAbstainDRep (class)
AlwaysAbstainDRep variant of DRep. drep = [2]
Signature
export declare class AlwaysAbstainDRepAdded in v2.0.0
toJSON (method)
Signature
toJSON()toString (method)
Signature
toString(): string[Inspectable.NodeInspectSymbol] (method)
Signature
[Inspectable.NodeInspectSymbol](): unknown[Equal.symbol] (method)
Signature
[Equal.symbol](that: unknown): boolean[Hash.symbol] (method)
Signature
[Hash.symbol](): numberAlwaysNoConfidenceDRep (class)
AlwaysNoConfidenceDRep variant of DRep. drep = [3]
Signature
export declare class AlwaysNoConfidenceDRepAdded in v2.0.0
toJSON (method)
Signature
toJSON()toString (method)
Signature
toString(): string[Inspectable.NodeInspectSymbol] (method)
Signature
[Inspectable.NodeInspectSymbol](): unknown[Equal.symbol] (method)
Signature
[Equal.symbol](that: unknown): boolean[Hash.symbol] (method)
Signature
[Hash.symbol](): numberDRep (type alias)
Type alias for DRep.
Signature
export type DRep = typeof DRep.TypeAdded in v2.0.0
KeyHashDRep (class)
KeyHashDRep variant of DRep. drep = [0, addr_keyhash]
Signature
export declare class KeyHashDRepAdded in v2.0.0
toJSON (method)
Signature
toJSON()toString (method)
Signature
toString(): string[Inspectable.NodeInspectSymbol] (method)
Signature
[Inspectable.NodeInspectSymbol](): unknown[Equal.symbol] (method)
Signature
[Equal.symbol](that: unknown): boolean[Hash.symbol] (method)
Signature
[Hash.symbol](): numberScriptHashDRep (class)
ScriptHashDRep variant of DRep. drep = [1, script_hash]
Signature
export declare class ScriptHashDRepAdded in v2.0.0
toJSON (method)
Signature
toJSON()toString (method)
Signature
toString(): string[Inspectable.NodeInspectSymbol] (method)
Signature
[Inspectable.NodeInspectSymbol](): unknown[Equal.symbol] (method)
Signature
[Equal.symbol](that: unknown): boolean[Hash.symbol] (method)
Signature
[Hash.symbol](): numberparsing
fromCBORBytes
Parse DRep from CBOR bytes.
Signature
export declare const fromCBORBytes: (bytes: Uint8Array, options?: CBOR.CodecOptions) => DRepAdded in v2.0.0
fromCBORHex
Parse DRep from CBOR hex string.
Signature
export declare const fromCBORHex: (hex: string, options?: CBOR.CodecOptions) => DRepAdded in v2.0.0
pattern matching
match
Pattern match over DRep.
Signature
export declare const match: <A>(patterns: {
KeyHashDRep: (keyHash: KeyHash.KeyHash) => A
ScriptHashDRep: (scriptHash: ScriptHash.ScriptHash) => A
AlwaysAbstainDRep: () => A
AlwaysNoConfidenceDRep: () => A
}) => (drep: DRep) => AAdded in v2.0.0
predicates
isDRep
Check if the given value is a valid DRep
Signature
export declare const isDRep: (
u: unknown,
overrideOptions?: ParseOptions | number
) => u is KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRepAdded in v2.0.0
schemas
DRep
Union schema for DRep representing different DRep types.
drep = [0, addr_keyhash] / [1, script_hash] / [2] / [3]
Signature
export declare const DRep: Schema.Union<
[typeof KeyHashDRep, typeof ScriptHashDRep, typeof AlwaysAbstainDRep, typeof AlwaysNoConfidenceDRep]
>Added in v2.0.0
FromCDDL
CDDL schema for DRep with proper transformation. drep = [0, addr_keyhash] / [1, script_hash] / [2] / [3]
Signature
export declare const FromCDDL: Schema.transformOrFail<
Schema.Union<
[
Schema.Tuple2<Schema.Literal<[0n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple2<Schema.Literal<[1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple<[Schema.Literal<[2n]>]>,
Schema.Tuple<[Schema.Literal<[3n]>]>
]
>,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>Added in v2.0.0
transformations
FromBech32
Transform from Bech32 string to DRep following CIP-129. Bech32 prefix: "drep" for both KeyHash and ScriptHash
Signature
export declare const FromBech32: Schema.transformOrFail<
typeof Schema.String,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>Added in v2.0.0
FromBytes
Transform from raw bytes to DRep following CIP-129. CIP-129 format: [1-byte header][28-byte credential] Header byte: 0x22 = KeyHash, 0x23 = ScriptHash
Signature
export declare const FromBytes: Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>Added in v2.0.0
FromHex
Transform from hex string to DRep.
Signature
export declare const FromHex: Schema.transform<
Schema.Schema<Uint8Array, string, never>,
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>
>Added in v2.0.0
type guards
isAlwaysNoConfidenceDRep
Check if DRep is an AlwaysNoConfidenceDRep.
Signature
export declare const isAlwaysNoConfidenceDRep: (drep: DRep) => drep is AlwaysNoConfidenceDRepAdded in v2.0.0
utils
CDDLSchema
Signature
export declare const CDDLSchema: Schema.Union<
[
Schema.Tuple2<Schema.Literal<[0n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple2<Schema.Literal<[1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple<[Schema.Literal<[2n]>]>,
Schema.Tuple<[Schema.Literal<[3n]>]>
]
>FromCBORBytes
Signature
export declare const FromCBORBytes: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>,
Schema.transformOrFail<
Schema.Union<
[
Schema.Tuple2<Schema.Literal<[0n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple2<Schema.Literal<[1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple<[Schema.Literal<[2n]>]>,
Schema.Tuple<[Schema.Literal<[3n]>]>
]
>,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>
>FromCBORHex
Signature
export declare const FromCBORHex: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.Schema<Uint8Array, string, never>,
Schema.transform<
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>,
Schema.transformOrFail<
Schema.Union<
[
Schema.Tuple2<Schema.Literal<[0n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple2<Schema.Literal<[1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.Tuple<[Schema.Literal<[2n]>]>,
Schema.Tuple<[Schema.Literal<[3n]>]>
]
>,
Schema.SchemaClass<
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
KeyHashDRep | ScriptHashDRep | AlwaysAbstainDRep | AlwaysNoConfidenceDRep,
never
>,
never
>
>
>