ForgeSdk v0.26.0 ForgeSdk.Util View Source

Get configuration, server setup, etc.

Link to this section Summary

Functions

Find the first configuration file in the following locations

Load the configuration file and merge it with default configuration forge_default.toml

Generate address for asset. Use owner's address + owner's nonce when creating this asset

Convert datetime or iso8601 datetime string to google protobuf timestamp

Generate stake address. Use sender's address + receiver's address as pseudo public key. Use ed25519 as pseudo key type. Use sha3 and base58 by default

Generate address for tx

Update few config env from forge state

Link to this section Functions

Link to this function

find_config_file!() View Source
find_config_file!() :: String.t()

Find the first configuration file in the following locations:

  • system env FORGE_CONFIG
  • ~/.forge/forge.toml
  • forge-elixir-sdk/priv/forge[_test].toml
Link to this function

gen_config(params) View Source
gen_config(map()) :: String.t()

Link to this function

init(otp_app, app_hash \\ "", filename \\ nil) View Source
init(atom(), String.t(), String.t() | nil) :: [module() | {module(), term()}]

Initialize the ForgeSdk.

Setting up basic config and return child spec for:

  • ABI server
  • RPC client conn

For a forge app build with Elixir sdk, application shall put these servers into their supervision tree.

filename = "/path/to/forge.toml"
servers = ForgeSdk.init(:app_name, app_hash, filename)
children = servers ++ other_children
Supervisor.start_link(children, opts)
Link to this function

load_config_file!(filename) View Source
load_config_file!(String.t() | nil) :: map()

Load the configuration file and merge it with default configuration forge_default.toml.

Link to this function

parse(type, file \\ "") View Source
parse(atom(), String.t() | map()) :: map()

Link to this function

to_asset_address(address, itx) View Source
to_asset_address(String.t(), map()) :: String.t()

Generate address for asset. Use owner's address + owner's nonce when creating this asset.

Convert datetime or iso8601 datetime string to google protobuf timestamp.

Link to this function

to_stake_address(addr1, addr2) View Source
to_stake_address(String.t(), String.t()) :: String.t()

Generate stake address. Use sender's address + receiver's address as pseudo public key. Use ed25519 as pseudo key type. Use sha3 and base58 by default.

Link to this function

to_tether_address(hash) View Source
to_tether_address(String.t()) :: String.t()

Link to this function

to_tx_address(itx) View Source
to_tx_address(map()) :: String.t()

Generate address for tx.

Link to this function

update_config(forge_state) View Source

Update few config env from forge state.

- token
- tx_config
- stake_config
- poke_config

This function needs to be called after ForgeSdk.init was called.