Rujira.Coin (rujira_ex v0.0.1)

Copy Markdown View Source

Canonical coin type for Rujira.

Represents an asset + amount pair. Amount is always an integer in smallest units. Asset is always resolved at construction time.

Summary

Functions

Returns the native denom string for this coin's asset.

Parse a comma-separated coin string into a list of coins. Supports both "1000rune" and "1000 rune" formats.

Types

t()

@type t() :: %Rujira.Coin{amount: Rujira.Amount.t(), asset: Rujira.Assets.Asset.t()}

Functions

denom(coin)

@spec denom(t()) :: {:ok, String.t()} | {:error, term()}

Returns the native denom string for this coin's asset.

new(map)

@spec new(%{denom: String.t(), amount: String.t()}) :: {:ok, t()} | {:error, term()}

new(asset, amount)

@spec new(Rujira.Assets.Asset.t(), non_neg_integer()) :: t()
@spec new(String.t(), non_neg_integer()) :: {:ok, t()} | {:error, term()}
@spec new(String.t(), String.t()) :: {:ok, t()} | {:error, term()}

parse(str)

@spec parse(String.t()) :: {:ok, [t()]} | {:error, :invalid_coin_format}

Parse a comma-separated coin string into a list of coins. Supports both "1000rune" and "1000 rune" formats.