GajuDesk/include/gmc.hrl
2025-01-08 14:49:22 +09:00

97 lines
3.2 KiB
Erlang

%% Node, Chain and Net represent the physical network.
-record(node,
{ip = {161,97,102,143} :: string() | inet:ip_address(),
external = 3013 :: none | inet:port_number(), % 3013
internal = none :: none | inet:port_number(), % 3113
rosetta = none :: none | inet:port_number(), % 8080
channel = none :: none | inet:port_number(), % 3014
mdw = none :: none | inet:port_number()}). % 4000
-record(chain,
{id = <<"groot.devnet">> :: binary(),
coins = ["gaju"] :: [string()],
nodes = [#node{}] :: [#node{}]}).
-record(net,
{id = <<"devnet">> :: binary(),
chains = [#chain{}] :: [#chain{}]}).
%% AC and Coin represent the financial authority graph for a given coin.
-record(ac,
{id = none :: string(),
acs = [] :: [#ac{}]}).
-record(coin,
{id = "gaju" :: string(),
mint = <<"groot.devnet">> :: binary(),
acs = [#ac{}] :: [#ac{}]}).
%% Balance, POA, Key, TXs, all culminate in capturing a complete Wallet view.
-record(balance,
{coin = "gaju" :: string(),
total = 0 :: non_neg_integer(),
dist = [{<<"groot.devnet">>, 0}] :: [{Chain :: binary(), non_neg_integer()}]}).
-record(poa,
{name = "" :: string(),
id = <<>> :: clutch:id(),
balances = [#balance{}] :: [#balance{}],
history = [] :: [clutch:tx()],
checked = never :: never | clutch:ts()}).
-record(key,
{name = "" :: string(),
id = <<>> :: clutch:id(),
pair = #{} :: #{public := binary(), secret := binary()},
type = {{eddsa, ed25519}, 256} :: {Cipher :: term(), Size :: pos_integer()}}).
-record(tx,
{id = none :: none | clutch:id(),
amount = 0 :: non_neg_integer(),
type = spend :: atom(),
status = submitted :: submitted | mined | rejected | failed,
meta = "" :: string()}).
-record(spend_tx,
{sender_id = <<>> :: clutch:id(),
recipient_id = <<>> :: clutch:id(),
amount = 0 :: non_neg_integer(),
gas_price = 0 :: non_neg_integer(),
gas = 0 :: non_neg_integer(),
ttl = 1 :: pos_integer(),
nonce = 0 :: non_neg_integer(),
payload = <<>> :: binary()}).
-record(wallet,
{version = 1 :: integer(),
name = "" :: string(),
poas = [] :: [#poa{}],
keys = [] :: [#key{}],
chain_id = <<"groot.devnet">> :: binary(),
endpoint = #node{} :: #node{},
nets = [#net{}] :: [#net{}]}).
%% Niche registered elements
% WR: Wallet Registration
-record(wr,
{name = "" :: string(),
path = "" :: file:filename(),
pass = false :: boolean()}).