ModulesAssets
Assets/Unit.ts
Unit overview
Table of contents
conversions
fromUnit
Parse a Unit string into its components. Extracts policy ID, asset name, and CIP-67 label if present.
Signature
export declare const fromUnit: (unit: Unit) => UnitDetailsAdded in v2.0.0
toUnit
Construct a Unit string from components. Combines policy ID, optional CIP-67 label, and asset name.
Signature
export declare const toUnit: (
policyId: PolicyId.PolicyId,
name?: AssetName.AssetName | string | null,
label?: number | null
) => UnitAdded in v2.0.0
model
Unit (type alias)
Unit represents the concatenation of PolicyId and AssetName as a single hex string. Format: policyId (56 chars) + assetName (0-64 chars) Special case: "lovelace" represents ADA
Signature
export type Unit = stringAdded in v2.0.0
UnitDetails (interface)
Result of parsing a Unit string.
Signature
export interface UnitDetails {
policyId: PolicyId.PolicyId
assetName: AssetName.AssetName | null
name: AssetName.AssetName | null
label: number | null
}Added in v2.0.0
predicates
isLovelace
Check if a value is the special "lovelace" unit.
Signature
export declare const isLovelace: (unit: Unit) => booleanAdded in v2.0.0
schemas
UnitSchema
Schema for validating Unit strings.
Signature
export declare const UnitSchema: Schema.refine<string, typeof Schema.String>Added in v2.0.0