Compare commits
5 Commits
b719c946ef
...
grids3
| Author | SHA1 | Date | |
|---|---|---|---|
| feae15740a | |||
| af1639d47b | |||
| cb36bad74b | |||
| 17a2b867fe | |||
| a35118db7a |
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel]},
|
{applications,[stdlib,kernel]},
|
||||||
{description,"Gajumaru interoperation library"},
|
{description,"Gajumaru interoperation library"},
|
||||||
{vsn,"0.8.0"},
|
{vsn,"0.8.2"},
|
||||||
{modules,[hakuzaru,hz,hz_fetcher,hz_format,hz_grids,
|
{modules,[hakuzaru,hz,hz_fetcher,hz_format,hz_grids,
|
||||||
hz_key_master,hz_man,hz_sup]},
|
hz_key_master,hz_man,hz_sup]},
|
||||||
{mod,{hakuzaru,[]}}]}.
|
{mod,{hakuzaru,[]}}]}.
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hakuzaru).
|
-module(hakuzaru).
|
||||||
-vsn("0.8.0").
|
-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").
|
||||||
|
|||||||
+14
-1
@@ -23,7 +23,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz).
|
-module(hz).
|
||||||
-vsn("0.8.0").
|
-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").
|
||||||
@@ -2461,6 +2461,19 @@ spend3(DSenderID,
|
|||||||
hz:post_tx(Encoded).
|
hz:post_tx(Encoded).
|
||||||
|
|
||||||
|
|
||||||
|
-spec sign(Scheme, Target, SecKey) -> Sig
|
||||||
|
when Scheme :: message | binary | bitcoin,
|
||||||
|
Target :: binary(),
|
||||||
|
SecKey :: binary(),
|
||||||
|
Sig :: binary().
|
||||||
|
|
||||||
|
sign(message, Target, SecKey) -> sign_message(Message, SecKey);
|
||||||
|
sign(binary, Target, SecKey) -> sign_binary(Target, SecKey);
|
||||||
|
sign(bitcoin, Target, SecKey) -> sign_bitcoin(Target, SecKey).
|
||||||
|
|
||||||
|
sign(bitcoin, Target, SecKey) -> sign_message(Target, SecKey).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_message(Message, SecKey) -> Sig
|
-spec sign_message(Message, SecKey) -> Sig
|
||||||
when Message :: binary(),
|
when Message :: binary(),
|
||||||
SecKey :: binary(),
|
SecKey :: binary(),
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
-module(hz_fetcher).
|
-module(hz_fetcher).
|
||||||
-vsn("0.8.0").
|
-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").
|
||||||
|
|||||||
+17
-6
@@ -21,7 +21,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_format).
|
-module(hz_format).
|
||||||
-vsn("0.8.0").
|
-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").
|
||||||
@@ -552,8 +552,7 @@ read_w_gajus([32, $G], A) ->
|
|||||||
calc([{$G, A}], []);
|
calc([{$G, A}], []);
|
||||||
read_w_gajus([32, $P], A) ->
|
read_w_gajus([32, $P], A) ->
|
||||||
calc([], [{$P, A}]);
|
calc([], [{$P, A}]);
|
||||||
read_w_gajus(A, B) ->
|
read_w_gajus(_, _) ->
|
||||||
io:format("A: ~ts, B: ~p~n", [A, B]),
|
|
||||||
error.
|
error.
|
||||||
|
|
||||||
read_w_pucks([C | Rest], A) when $0 =< C andalso C =< $9 ->
|
read_w_pucks([C | Rest], A) when $0 =< C andalso C =< $9 ->
|
||||||
@@ -599,10 +598,23 @@ read([32, $P], A, P) ->
|
|||||||
calc([], [{$P, A} | P]);
|
calc([], [{$P, A} | P]);
|
||||||
read([C, 32 | Rest], A, G) ->
|
read([C, 32 | Rest], A, G) ->
|
||||||
read(Rest, [], [{C, A} | G]);
|
read(Rest, [], [{C, A} | G]);
|
||||||
|
read([$, | Rest], A, []) ->
|
||||||
|
read_w_gajus(Rest, A);
|
||||||
|
read([$_ | Rest], A, []) ->
|
||||||
|
read_w_gajus(Rest, A);
|
||||||
|
read([$. | Rest], A, []) ->
|
||||||
|
case read_w_pucks(Rest, []) of
|
||||||
|
{ok, P} ->
|
||||||
|
G = list_to_integer(lists:reverse(A)) * one(gaju),
|
||||||
|
{ok, G + P};
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
|
end;
|
||||||
read([C | Rest], A, G) ->
|
read([C | Rest], A, G) ->
|
||||||
read(Rest, [], [{C, A} | G]);
|
read(Rest, [], [{C, A} | G]);
|
||||||
read(Rest, A, G) ->
|
read([], A, []) ->
|
||||||
io:format("read(\"~ts\", ~tp, ~tp) -> died!~n", [Rest, A, G]),
|
read_w_gajus([], A);
|
||||||
|
read(_, _, _) ->
|
||||||
error.
|
error.
|
||||||
|
|
||||||
|
|
||||||
@@ -622,7 +634,6 @@ read([C, 32 | Rest], A, G, P) ->
|
|||||||
read([C | Rest], A, G, P) ->
|
read([C | Rest], A, G, P) ->
|
||||||
read(Rest, [], G, [{C, A} | P]);
|
read(Rest, [], G, [{C, A} | P]);
|
||||||
read(_, _, _, _) ->
|
read(_, _, _, _) ->
|
||||||
io:format("read/4 died!~n"),
|
|
||||||
error.
|
error.
|
||||||
|
|
||||||
calc(G, P) ->
|
calc(G, P) ->
|
||||||
|
|||||||
+37
-3
@@ -37,7 +37,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_grids).
|
-module(hz_grids).
|
||||||
-vsn("0.8.0").
|
-vsn("0.8.2").
|
||||||
-export([url/2, url/3, url/4, parse/1, req/2, req/3]).
|
-export([url/2, url/3, url/4, parse/1, req/2, req/3]).
|
||||||
|
|
||||||
|
|
||||||
@@ -190,16 +190,48 @@ l_to_i(S) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec req(Type, Message) -> RequestMap
|
||||||
|
when Type :: {sign, message | binary | bitcoin}
|
||||||
|
| tx
|
||||||
|
| ack
|
||||||
|
| sign,
|
||||||
|
Message :: binary(),
|
||||||
|
RequestMap :: map().
|
||||||
|
%% @doc
|
||||||
|
%% 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, ID) ->
|
req({sign, message}, Message, ID) ->
|
||||||
#{"grids" => 1,
|
#{"grids" => 1,
|
||||||
"chain" => "gajumaru",
|
"chain" => "gajumaru",
|
||||||
"network_id" => hz:network_id(),
|
"network_id" => hz:network_id(),
|
||||||
"type" => "message",
|
"type" => "message",
|
||||||
"public_id" => ID,
|
"public_id" => ID,
|
||||||
"payload" => Message};
|
"payload" => Message};
|
||||||
|
req({sign, binary}, Binary, ID) ->
|
||||||
|
#{"grids" => 1,
|
||||||
|
"chain" => "gajumaru",
|
||||||
|
"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) ->
|
req(tx, Data, ID) ->
|
||||||
#{"grids" => 1,
|
#{"grids" => 1,
|
||||||
"chain" => "gajumaru",
|
"chain" => "gajumaru",
|
||||||
@@ -213,4 +245,6 @@ req(ack, Message, ID) ->
|
|||||||
"network_id" => hz:network_id(),
|
"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).
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_key_master).
|
-module(hz_key_master).
|
||||||
-vsn("0.8.0").
|
-vsn("0.8.2").
|
||||||
|
|
||||||
|
|
||||||
-export([make_key/1, encode/1, decode/1]).
|
-export([make_key/1, encode/1, decode/1]).
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_man).
|
-module(hz_man).
|
||||||
-vsn("0.8.0").
|
-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>").
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_sup).
|
-module(hz_sup).
|
||||||
-vsn("0.8.0").
|
-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,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,8,0}}}.
|
{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}},
|
||||||
|
|||||||
Reference in New Issue
Block a user