1 Commits

Author SHA1 Message Date
zxq9 feae15740a WIP 2025-12-31 01:06:20 +09:00
16 changed files with 1257 additions and 3742 deletions
+2 -2
View File
@@ -8,9 +8,9 @@ cancer
erl_crash.dump erl_crash.dump
ebin/*.beam ebin/*.beam
doc/*.html doc/*.html
doc/erlang.png doc/*.css
doc/stylesheet.css
doc/edoc-info doc/edoc-info
doc/erlang.png
rel/example_project rel/example_project
.concrete/DEV_MODE .concrete/DEV_MODE
.rebar .rebar
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

-75
View File
@@ -1,75 +0,0 @@
/* standard EDoc style sheet */
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
margin-left: .25in;
margin-right: .2in;
margin-top: 0.2in;
margin-bottom: 0.2in;
color: #696969;
background-color: #ffffff;
}
a:link{
color: #000000;
}
a:visited{
color: #000000;
}
a:hover{
color: #d8613c;
}
h1,h2 {
margin-left: -0.2in;
}
div.navbar {
background-color: #000000;
padding: 0.2em;
}
h2.indextitle {
padding: 0.4em;
color: #dfdfdf;
background-color: #000000;
}
div.navbar a:link {
color: #dfdfdf;
}
div.navbar a:visited {
color: #dfdfdf;
}
div.navbar a:hover {
color: #d8613c;
}
h3.function,h3.typedecl {
background-color: #000000;
color: #dfdfdf;
padding-left: 1em;
}
div.spec {
margin-left: 2em;
background-color: #eeeeee;
}
a.module {
text-decoration:none
}
a.module:hover {
background-color: #eeeeee;
}
ul.definitions {
list-style-type: none;
}
ul.index {
list-style-type: none;
background-color: #eeeeee;
}
/*
* Minor style tweaks
*/
ul {
list-style-type: square;
}
table {
border-collapse: collapse;
}
td {
padding: 3
}
+3 -4
View File
@@ -1,6 +1,5 @@
@author Craig Everett <craigeverett@qpq.swiss> [https://zxq9.com] @author Craig Everett <craigeverett@qpq.swiss> [https://git.qpq.swiss/QPQ-AG/hakuzaru]
@author Jarvis Carrol <jarviscarrol@qpq.swiss> [https://jarviscarroll.net/] @version 0.8.0
@version 0.9.2
@title Hakuzaru: Gajumaru blockchain bindings for Erlang @title Hakuzaru: Gajumaru blockchain bindings for Erlang
@doc @doc
@@ -22,7 +21,7 @@ After startup `hz_man' must be given the address and port of a list of Gajumaru
Note that the service nodes will need to have the dry-run endpoint enabled and the internal service query port made available in order to provide dry-runs and transaction submission. Note that the service nodes will need to have the dry-run endpoint enabled and the internal service query port made available in order to provide dry-runs and transaction submission.
When configuring chain nodes a list of nodes should be provided. When configuring chain nodes a list of nodes should be provided.
To avoid sync issues in the case of fast transaction formation/submission to the chain, only one node from the list of chain nodes is used for submitting transactions and querying `next_nonce/1'. To avoid sync issues in the case of fast transaction formation/submission to the chain, only one node from the list of chain nodes is used for submitting transactions and querying `next_nonce/1`.
This node is called "the sticky node". This node is called "the sticky node".
The first node in the list of chain nodes provided during configuration is designated as the sticky node. The first node in the list of chain nodes provided during configuration is designated as the sticky node.
+3 -3
View File
@@ -3,7 +3,7 @@
{included_applications,[]}, {included_applications,[]},
{applications,[stdlib,kernel]}, {applications,[stdlib,kernel]},
{description,"Gajumaru interoperation library"}, {description,"Gajumaru interoperation library"},
{vsn,"0.9.2"}, {vsn,"0.8.2"},
{modules,[hakuzaru,hz,hz_aaci,hz_fetcher,hz_format,hz_grids, {modules,[hakuzaru,hz,hz_fetcher,hz_format,hz_grids,
hz_key_master,hz_man,hz_sophia,hz_sup]}, hz_key_master,hz_man,hz_sup]},
{mod,{hakuzaru,[]}}]}. {mod,{hakuzaru,[]}}]}.
+1 -1
View File
@@ -6,7 +6,7 @@
%%% @end %%% @end
-module(hakuzaru). -module(hakuzaru).
-vsn("0.9.2"). -vsn("0.8.2").
-author("Craig Everett <ceverett@tsuriai.jp>"). -author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>"). -copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
+1193 -289
View File
File diff suppressed because it is too large Load Diff
-1628
View File
File diff suppressed because it is too large Load Diff
+1 -9
View File
@@ -1,13 +1,5 @@
%%% @private
%%% Hakuzaru Request Fetcher
%%%
%%% This module defines the request workers.
%%% Each request to a remote chain node is handled by a worker that is spawned
%%% to handle it and terminates on completion.
%%% @end
-module(hz_fetcher). -module(hz_fetcher).
-vsn("0.9.2"). -vsn("0.8.2").
-author("Craig Everett <ceverett@tsuriai.jp>"). -author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>"). -copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("MIT"). -license("MIT").
+1 -18
View File
@@ -21,7 +21,7 @@
%%% @end %%% @end
-module(hz_format). -module(hz_format).
-vsn("0.9.2"). -vsn("0.8.2").
-author("Craig Everett <ceverett@tsuriai.jp>"). -author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>"). -copyright("Craig Everett <ceverett@tsuriai.jp>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@@ -462,26 +462,9 @@ ranks(heresy) ->
["k ", "m ", "b ", "t ", "q ", "e ", "z ", "y ", "r ", "Q "]. ["k ", "m ", "b ", "t ", "q ", "e ", "z ", "y ", "r ", "Q "].
-spec mark(Unit) -> Mark
when Unit :: gaju | puck,
Mark :: $木 | $本.
%% @doc
%% Retrieve the unicode codepoint for the `gaju' mark (木) or the `puck' mark (本).
mark(gaju) -> $木; mark(gaju) -> $木;
mark(puck) -> $本. mark(puck) -> $本.
-spec one(Unit) -> Pucks
when Unit :: gaju | puck,
Pucks :: 1_000_000_000_000_000_000 | 1.
%% @doc
%% Quickly resolve the number of pucks in a given unit.
%%
%% The number of pucks in a gaju is so large that it can be a little bit annoying
%% to remember the exact amount. This is a helper to simplify this when writing
%% an app against the hakuzaru library when dealing in either unit.
one(gaju) -> 1_000_000_000_000_000_000; one(gaju) -> 1_000_000_000_000_000_000;
one(puck) -> 1. one(puck) -> 1.
+42 -44
View File
@@ -37,8 +37,8 @@
%%% @end %%% @end
-module(hz_grids). -module(hz_grids).
-vsn("0.9.2"). -vsn("0.8.2").
-export([url/2, url/3, url/4, parse/1, req/2, req/3, req/4]). -export([url/2, url/3, url/4, parse/1, req/2, req/3]).
-spec url(Instruction, HTTP) -> Result -spec url(Instruction, HTTP) -> Result
@@ -47,7 +47,7 @@
Result :: {ok, GRIDS} | uri_string:uri_error(), Result :: {ok, GRIDS} | uri_string:uri_error(),
GRIDS :: uri_string:uri_string(). GRIDS :: uri_string:uri_string().
%% @doc %% @doc
%% Takes an instruction and an HTTP endpoint location and forms a GRIDS URL. %% Takes
url(Instruction, HTTP) -> url(Instruction, HTTP) ->
case uri_string:parse(HTTP) of case uri_string:parse(HTTP) of
@@ -134,8 +134,6 @@ qwargs(Amount, Payload) ->
Amount :: non_neg_integer(), Amount :: non_neg_integer(),
Payload :: binary(), Payload :: binary(),
URL :: string(). URL :: string().
%% @doc
%% Translate a GRIDS URL into an Erlang terms instruction.
parse(GRIDS) -> parse(GRIDS) ->
case uri_string:parse(GRIDS) of case uri_string:parse(GRIDS) of
@@ -192,61 +190,61 @@ l_to_i(S) ->
end. end.
-spec req(Type, Message) -> Format -spec req(Type, Message) -> RequestMap
when Type :: sign | tx | ack, when Type :: {sign, message | binary | bitcoin}
Message :: string() | binary(), | tx
Format :: map(). | ack
| sign,
Message :: binary(),
RequestMap :: map().
%% @doc %% @doc
%% @equiv req(Type, Message, false) %% GRIDS maps always contain the following keys:
%% ```
%% #{"grids" => 1,
%% "chain" => "gajumaru",
%% "network_id" => "groot.mainnet.gajumaru.io",
%% "type" => "message" | "binary" | "binary" | "tx" | "ack"
%% "public_id" => term(),
%% "payload" => string()};
%% '''
req(Type, Message) -> req(Type, Message) ->
req(Type, Message, false). req(Type, Message, false).
req({sign, message}, Message, ID) ->
-spec req(Type, Message, ID) -> Format
when Type :: sign | tx | ack,
Message :: string() | binary(),
ID :: false | string() | binary(),
Format :: map().
%% @doc
%% Creates a GRIDS message format with the current `NetworkID'.
%%
%% The `ID' parameter indicates which key the requestee should sign with or
%% is `false' to indicate that which key to sign with is up to the requestee.
%% @equiv req(Type, Message, ID, CurrentNetworkID)
req(Type, Message, ID) ->
{ok, NetworkID} = hz:network_id(),
req(Type, Message, ID, NetworkID).
-spec req(Type, Message, ID, NetworkID) -> Format
when Type :: sign | tx | ack,
Message :: string() | binary(),
ID :: false | string() | binary(),
NetworkID :: string() | binary(),
Format :: map().
%% @doc
%% Creates a GRIDS message format.
req(sign, Message, ID, NetworkID) ->
#{"grids" => 1, #{"grids" => 1,
"chain" => "gajumaru", "chain" => "gajumaru",
"network_id" => NetworkID, "network_id" => hz:network_id(),
"type" => "message", "type" => "message",
"public_id" => ID, "public_id" => ID,
"payload" => Message}; "payload" => Message};
req(tx, Data, ID, NetworkID) -> req({sign, binary}, Binary, ID) ->
#{"grids" => 1, #{"grids" => 1,
"chain" => "gajumaru", "chain" => "gajumaru",
"network_id" => NetworkID, "network_id" => hz:network_id(),
"type" => "binary",
"public_id" => ID,
"payload" => base64:encode(Binary)};
req({sign, bitcoin}, Binary, ID) ->
#{"grids" => 1,
"chain" => "gajumaru",
"network_id" => hz:network_id(),
"type" => "bitcoin",
"public_id" => ID,
"payload" => base64:encode(Binary)};
req(tx, Data, ID) ->
#{"grids" => 1,
"chain" => "gajumaru",
"network_id" => hz:network_id(),
"type" => "tx", "type" => "tx",
"public_id" => ID, "public_id" => ID,
"payload" => Data}; "payload" => Data};
req(ack, Message, ID, NetworkID) -> req(ack, Message, ID) ->
#{"grids" => 1, #{"grids" => 1,
"chain" => "gajumaru", "chain" => "gajumaru",
"network_id" => NetworkID, "network_id" => hz:network_id(),
"type" => "ack", "type" => "ack",
"public_id" => ID, "public_id" => ID,
"payload" => Message}. "payload" => Message};
req(sign, Message, ID) ->
req({sign, message}, Message, ID).
+2 -1
View File
@@ -8,7 +8,8 @@
%%% @end %%% @end
-module(hz_key_master). -module(hz_key_master).
-vsn("0.9.2"). -vsn("0.8.2").
-export([make_key/1, encode/1, decode/1]). -export([make_key/1, encode/1, decode/1]).
-export([lcg/1]). -export([lcg/1]).
+2 -1
View File
@@ -9,7 +9,7 @@
%%% @end %%% @end
-module(hz_man). -module(hz_man).
-vsn("0.9.2"). -vsn("0.8.2").
-behavior(gen_server). -behavior(gen_server).
-author("Craig Everett <ceverett@tsuriai.jp>"). -author("Craig Everett <ceverett@tsuriai.jp>").
-copyright("Craig Everett <ceverett@tsuriai.jp>"). -copyright("Craig Everett <ceverett@tsuriai.jp>").
@@ -172,6 +172,7 @@ start_link() ->
%% preparatory work necessary for proper function. %% preparatory work necessary for proper function.
init(none) -> init(none) ->
ok = io:format("hz_man starting.~n"),
State = #s{}, State = #s{},
{ok, State}. {ok, State}.
-1660
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -9,7 +9,7 @@
%%% @end %%% @end
-module(hz_sup). -module(hz_sup).
-vsn("0.9.2"). -vsn("0.8.2").
-behaviour(supervisor). -behaviour(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
+2 -2
View File
@@ -2,9 +2,9 @@
{type,app}. {type,app}.
{modules,[]}. {modules,[]}.
{prefix,"hz"}. {prefix,"hz"}.
{author,"Craig Everett"}.
{desc,"Gajumaru interoperation library"}. {desc,"Gajumaru interoperation library"}.
{package_id,{"otpr","hakuzaru",{0,9,2}}}. {author,"Craig Everett"}.
{package_id,{"otpr","hakuzaru",{0,8,2}}}.
{deps,[{"otpr","sophia",{9,0,0}}, {deps,[{"otpr","sophia",{9,0,0}},
{"otpr","gmserialization",{0,1,3}}, {"otpr","gmserialization",{0,1,3}},
{"otpr","gmbytecode",{3,4,1}}, {"otpr","gmbytecode",{3,4,1}},