Kujira.Coin (kujira v0.1.80)

A Kujira.Token with an associated amount

Summary

Functions

Adds a single Coin to a list of Coins, increasing the amount value if already present

Sorts the coins alphabetically by denom string

Parses a single SDK coin string eg 100ukuji

Parses an SDK coins string eg 100ukuji,200ibc/FFA3D0E9C3CDE729559FB71A09E9E6CFA5A85AFABAC9F3CB5DD3942BFF935F9C

Creates a Decimal with the human value of the amount

Types

@type t() :: %Kujira.Coin{amount: integer(), token: Kujira.Token.t()}

Functions

Link to this function

add_coin(coin, coins)

@spec add_coin(t(), [t()]) :: [t()]

Adds a single Coin to a list of Coins, increasing the amount value if already present

Link to this function

normalize(coins)

@spec normalize([t()]) :: [t()]

Sorts the coins alphabetically by denom string

Link to this function

parse_coin(channel, string)

@spec parse_coin(GRPC.Channel.t(), binary()) ::
  {:ok, t()}
  | {:error, :invalid_denom}
  | {:error, :invalid_integer_amount}
  | {:error, GRPC.RPCError.t()}

Parses a single SDK coin string eg 100ukuji

Link to this function

parse_coins(channel, string)

@spec parse_coins(GRPC.Channel.t(), binary()) ::
  {:ok, [t()]}
  | {:error, :invalid_denom}
  | {:error, :invalid_integer_amount}
  | {:error, GRPC.RPCError.t()}

Parses an SDK coins string eg 100ukuji,200ibc/FFA3D0E9C3CDE729559FB71A09E9E6CFA5A85AFABAC9F3CB5DD3942BFF935F9C

Link to this function

to_decimal(coin)

@spec to_decimal(t()) :: Decimal.t()

Creates a Decimal with the human value of the amount