Compare commits
4 Commits
5a8e0b602d
...
8258d56b34
Author | SHA1 | Date | |
---|---|---|---|
8258d56b34 | |||
3f22659948 | |||
ddf375f05b | |||
58bd19d2dc |
@ -3,6 +3,6 @@
|
|||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel]},
|
{applications,[stdlib,kernel]},
|
||||||
{description,"Gajumaru interoperation library"},
|
{description,"Gajumaru interoperation library"},
|
||||||
{vsn,"0.4.0"},
|
{vsn,"0.5.1"},
|
||||||
{modules,[hakuzaru,hz,hz_fetcher,hz_man,hz_sup]},
|
{modules,[hakuzaru,hz,hz_fetcher,hz_man,hz_sup]},
|
||||||
{mod,{hakuzaru,[]}}]}.
|
{mod,{hakuzaru,[]}}]}.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hakuzaru).
|
-module(hakuzaru).
|
||||||
-vsn("0.4.0").
|
-vsn("0.5.1").
|
||||||
-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").
|
||||||
|
27
src/hz.erl
27
src/hz.erl
@ -23,7 +23,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz).
|
-module(hz).
|
||||||
-vsn("0.4.0").
|
-vsn("0.5.1").
|
||||||
-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").
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
%%% Types
|
%%% Types
|
||||||
|
|
||||||
-export_type([chain_node/0, network_id/0, chain_error/0]).
|
-export_type([chain_node/0, network_id/0, chain_error/0, aaci/0]).
|
||||||
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
@ -94,6 +94,7 @@
|
|||||||
| {headers, map()}
|
| {headers, map()}
|
||||||
| bad_length
|
| bad_length
|
||||||
| gc_out_of_range.
|
| gc_out_of_range.
|
||||||
|
-type aaci() :: {aaci, term(), term(), term()}.
|
||||||
-type pubkey() :: unicode:chardata(). % "ak_" ++ _
|
-type pubkey() :: unicode:chardata(). % "ak_" ++ _
|
||||||
-type account_id() :: pubkey().
|
-type account_id() :: pubkey().
|
||||||
-type contract_id() :: unicode:chardata(). % "ct_" ++ _
|
-type contract_id() :: unicode:chardata(). % "ct_" ++ _
|
||||||
@ -218,8 +219,10 @@
|
|||||||
|
|
||||||
%%% Get/Set admin functions
|
%%% Get/Set admin functions
|
||||||
|
|
||||||
-spec network_id() -> NetworkID
|
-spec network_id() -> Result
|
||||||
when NetworkID :: string() | none.
|
when Result :: {ok, NetworkID} | {error, Reason},
|
||||||
|
NetworkID :: string(),
|
||||||
|
Reason :: term().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Returns the network ID or the atom `none' if it is unset.
|
%% Returns the network ID or the atom `none' if it is unset.
|
||||||
%% Checking this is not normally necessary, but if network ID assignment is dynamic
|
%% Checking this is not normally necessary, but if network ID assignment is dynamic
|
||||||
@ -1151,7 +1154,7 @@ read_aci(Path) ->
|
|||||||
|
|
||||||
-spec contract_call(CallerID, AACI, ConID, Fun, Args) -> Result
|
-spec contract_call(CallerID, AACI, ConID, Fun, Args) -> Result
|
||||||
when CallerID :: unicode:chardata(),
|
when CallerID :: unicode:chardata(),
|
||||||
AACI :: map(),
|
AACI :: aaci(),
|
||||||
ConID :: unicode:chardata(),
|
ConID :: unicode:chardata(),
|
||||||
Fun :: string(),
|
Fun :: string(),
|
||||||
Args :: [string()],
|
Args :: [string()],
|
||||||
@ -1186,7 +1189,7 @@ contract_call(CallerID, AACI, ConID, Fun, Args) ->
|
|||||||
-spec contract_call(CallerID, Gas, AACI, ConID, Fun, Args) -> Result
|
-spec contract_call(CallerID, Gas, AACI, ConID, Fun, Args) -> Result
|
||||||
when CallerID :: unicode:chardata(),
|
when CallerID :: unicode:chardata(),
|
||||||
Gas :: pos_integer(),
|
Gas :: pos_integer(),
|
||||||
AACI :: map(),
|
AACI :: aaci(),
|
||||||
ConID :: unicode:chardata(),
|
ConID :: unicode:chardata(),
|
||||||
Fun :: string(),
|
Fun :: string(),
|
||||||
Args :: [string()],
|
Args :: [string()],
|
||||||
@ -1224,7 +1227,7 @@ contract_call(CallerID, Gas, AACI, ConID, Fun, Args) ->
|
|||||||
GasPrice :: pos_integer(),
|
GasPrice :: pos_integer(),
|
||||||
Amount :: non_neg_integer(),
|
Amount :: non_neg_integer(),
|
||||||
TTL :: pos_integer(),
|
TTL :: pos_integer(),
|
||||||
AACI :: map(),
|
AACI :: aaci(),
|
||||||
ConID :: unicode:chardata(),
|
ConID :: unicode:chardata(),
|
||||||
Fun :: string(),
|
Fun :: string(),
|
||||||
Args :: [string()],
|
Args :: [string()],
|
||||||
@ -1391,7 +1394,7 @@ contract_call4(PK, Nonce, Gas, GasPrice, Amount, TTL, CK, CallData) ->
|
|||||||
|
|
||||||
-spec prepare_contract(File) -> {ok, AACI} | {error, Reason}
|
-spec prepare_contract(File) -> {ok, AACI} | {error, Reason}
|
||||||
when File :: file:filename(),
|
when File :: file:filename(),
|
||||||
AACI :: map(),
|
AACI :: aaci(),
|
||||||
Reason :: term().
|
Reason :: term().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Compile a contract and extract the function spec meta for use in future formation
|
%% Compile a contract and extract the function spec meta for use in future formation
|
||||||
@ -2053,7 +2056,7 @@ zip_record_field({Name, Type}, {Remaining, Missing}) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
-spec aaci_lookup_spec(AACI, Fun) -> {ok, Type} | {error, Reason}
|
-spec aaci_lookup_spec(AACI, Fun) -> {ok, Type} | {error, Reason}
|
||||||
when AACI :: {aaci, term(), term(), term()}, % FIXME
|
when AACI :: aaci(),
|
||||||
Fun :: binary() | string(),
|
Fun :: binary() | string(),
|
||||||
Type :: {term(), term()}, % FIXME
|
Type :: {term(), term()}, % FIXME
|
||||||
Reason :: bad_fun_name.
|
Reason :: bad_fun_name.
|
||||||
@ -2214,8 +2217,6 @@ spend2(DSenderID,
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
decode_account_id(S) when is_list(S) ->
|
|
||||||
decode_account_id(list_to_binary(S));
|
|
||||||
decode_account_id(B) ->
|
decode_account_id(B) ->
|
||||||
try
|
try
|
||||||
{account_pubkey, PK} = gmser_api_encoder:decode(B),
|
{account_pubkey, PK} = gmser_api_encoder:decode(B),
|
||||||
@ -2311,8 +2312,8 @@ verify_signature2(Sig, Message, PK) ->
|
|||||||
|
|
||||||
% This is Bitcoin's variable-length unsigned integer encoding
|
% This is Bitcoin's variable-length unsigned integer encoding
|
||||||
% See: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
|
% See: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
|
||||||
vencode(N) when N < 0 ->
|
vencode(N) when N =< 0 ->
|
||||||
{error, {negative_N, N}};
|
{error, {non_pos_N, N}};
|
||||||
vencode(N) when N < 16#FD ->
|
vencode(N) when N < 16#FD ->
|
||||||
{ok, <<N>>};
|
{ok, <<N>>};
|
||||||
vencode(N) when N =< 16#FFFF ->
|
vencode(N) when N =< 16#FFFF ->
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-module(hz_fetcher).
|
-module(hz_fetcher).
|
||||||
-vsn("0.4.0").
|
-vsn("0.5.1").
|
||||||
-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").
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_man).
|
-module(hz_man).
|
||||||
-vsn("0.4.0").
|
-vsn("0.5.1").
|
||||||
-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>").
|
||||||
@ -75,7 +75,7 @@ chain_nodes() ->
|
|||||||
|
|
||||||
|
|
||||||
-spec chain_nodes(ToUse) -> ok
|
-spec chain_nodes(ToUse) -> ok
|
||||||
when ToUse :: [hz:chain_nodes()].
|
when ToUse :: [hz:chain_node()].
|
||||||
|
|
||||||
chain_nodes(ToUse) ->
|
chain_nodes(ToUse) ->
|
||||||
gen_server:cast(?MODULE, {chain_nodes, ToUse}).
|
gen_server:cast(?MODULE, {chain_nodes, ToUse}).
|
||||||
@ -162,7 +162,7 @@ handle_cast({tls, Boolean}, State) ->
|
|||||||
NewState = do_tls(Boolean, State),
|
NewState = do_tls(Boolean, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
handle_cast({chain_nodes, []}, State) ->
|
handle_cast({chain_nodes, []}, State) ->
|
||||||
{noreply, State#s{chain_nodes = none}};
|
{noreply, State#s{chain_nodes = {[], []}}};
|
||||||
handle_cast({chain_nodes, ToUse}, State) ->
|
handle_cast({chain_nodes, ToUse}, State) ->
|
||||||
{noreply, State#s{chain_nodes = {ToUse, []}}};
|
{noreply, State#s{chain_nodes = {ToUse, []}}};
|
||||||
handle_cast({timeout, Value}, State) ->
|
handle_cast({timeout, Value}, State) ->
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(hz_sup).
|
-module(hz_sup).
|
||||||
-vsn("0.4.0").
|
-vsn("0.5.1").
|
||||||
-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>").
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{prefix,"hz"}.
|
{prefix,"hz"}.
|
||||||
{desc,"Gajumaru interoperation library"}.
|
{desc,"Gajumaru interoperation library"}.
|
||||||
{author,"Craig Everett"}.
|
{author,"Craig Everett"}.
|
||||||
{package_id,{"otpr","hakuzaru",{0,4,0}}}.
|
{package_id,{"otpr","hakuzaru",{0,5,1}}}.
|
||||||
{deps,[{"otpr","sophia",{8,0,1}},
|
{deps,[{"otpr","sophia",{8,0,1}},
|
||||||
{"otpr","gmbytecode",{3,4,1}},
|
{"otpr","gmbytecode",{3,4,1}},
|
||||||
{"otpr","gmserialization",{0,1,2}},
|
{"otpr","gmserialization",{0,1,2}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user