|
|
|
@ -40,6 +40,8 @@ defmodule ExW3 do |
|
|
|
|
@unit_map |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@spec to_wei(integer(), keyword()) :: integer() |
|
|
|
|
@doc "Converts the value to whatever unit key is provided. See unit map for details." |
|
|
|
|
def to_wei(num, key) do |
|
|
|
|
if @unit_map[key] do |
|
|
|
|
num * @unit_map[key] |
|
|
|
@ -48,6 +50,8 @@ defmodule ExW3 do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@spec from_wei(integer(), keyword()) :: integer() |
|
|
|
|
@doc "Converts the value to whatever unit key is provided. See unit map for details." |
|
|
|
|
def from_wei(num, key) do |
|
|
|
|
if @unit_map[key] do |
|
|
|
|
num / @unit_map[key] |
|
|
|
|