ForgeSdk v0.27.1 ForgeSdk.Util View Source
Get configuration, server setup, etc.
Link to this section Summary
Functions
Find the first configuration file in the following locations
Get the gRPC connection channel
Initialize the ForgeSdk
Load the configuration file and merge it with default configuration forge_default.toml
Generate address for asset. We only use itx.data to generate asset address. Thus same itx.data would be treated as duplicate 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
datetime_to_proto(dt) View Source
find_config_file!()
View Source
find_config_file!() :: String.t()
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
gen_config(params) View Source
get_chan()
View Source
get_chan() :: GRPC.Channel.t() | {:error, any()}
get_chan() :: GRPC.Channel.t() | {:error, any()}
Get the gRPC connection channel.
init(otp_app, app_hash \\ "", filename \\ nil) View Source
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)
load_config_file!(filename) View Source
Load the configuration file and merge it with default configuration forge_default.toml
.
parse(type, file \\ "") View Source
proto_to_datetime(map) View Source
to_asset_address(itx) View Source
Generate address for asset. We only use itx.data to generate asset address. Thus same itx.data would be treated as duplicate asset.
to_proto_ts(s)
View Source
to_proto_ts(String.t() | DateTime.t()) :: Google.Protobuf.Timestamp.t()
to_proto_ts(String.t() | DateTime.t()) :: Google.Protobuf.Timestamp.t()
Convert datetime or iso8601 datetime string to google protobuf timestamp.
to_stake_address(addr1, addr2) View Source
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.
to_tether_address(hash) View Source
to_tx_address(itx) View Source
Generate address for tx.
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.