diff --git a/src/hz.erl b/src/hz.erl index e0ba057..b76f734 100644 --- a/src/hz.erl +++ b/src/hz.erl @@ -78,7 +78,7 @@ %%% 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"). @@ -94,6 +94,7 @@ | {headers, map()} | bad_length | gc_out_of_range. +-type aaci() :: {aaci, term(), term(), term()}. -type pubkey() :: unicode:chardata(). % "ak_" ++ _ -type account_id() :: pubkey(). -type contract_id() :: unicode:chardata(). % "ct_" ++ _ @@ -218,8 +219,10 @@ %%% Get/Set admin functions --spec network_id() -> NetworkID - when NetworkID :: string() | none. +-spec network_id() -> Result + when Result :: {ok, NetworkID} | {error, Reason}, + NetworkID :: string(), + Reason :: term(). %% @doc %% 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 @@ -1150,7 +1153,7 @@ read_aci(Path) -> -spec contract_call(CallerID, AACI, ConID, Fun, Args) -> Result when CallerID :: unicode:chardata(), - AACI :: map(), + AACI :: aaci(), ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -1185,7 +1188,7 @@ contract_call(CallerID, AACI, ConID, Fun, Args) -> -spec contract_call(CallerID, Gas, AACI, ConID, Fun, Args) -> Result when CallerID :: unicode:chardata(), Gas :: pos_integer(), - AACI :: map(), + AACI :: aaci(), ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -1223,7 +1226,7 @@ contract_call(CallerID, Gas, AACI, ConID, Fun, Args) -> GasPrice :: pos_integer(), Amount :: non_neg_integer(), TTL :: pos_integer(), - AACI :: map(), + AACI :: aaci(), ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -1390,7 +1393,7 @@ contract_call4(PK, Nonce, Gas, GasPrice, Amount, TTL, CK, CallData) -> -spec prepare_contract(File) -> {ok, AACI} | {error, Reason} when File :: file:filename(), - AACI :: map(), + AACI :: aaci(), Reason :: term(). %% @doc %% Compile a contract and extract the function spec meta for use in future formation @@ -2052,7 +2055,7 @@ zip_record_field({Name, Type}, {Remaining, Missing}) -> end. -spec aaci_lookup_spec(AACI, Fun) -> {ok, Type} | {error, Reason} - when AACI :: {aaci, term(), term(), term()}, % FIXME + when AACI :: aaci(), Fun :: binary() | string(), Type :: {term(), term()}, % FIXME Reason :: bad_fun_name. @@ -2213,8 +2216,6 @@ spend2(DSenderID, end. -decode_account_id(S) when is_list(S) -> - decode_account_id(list_to_binary(S)); decode_account_id(B) -> try {account_pubkey, PK} = gmser_api_encoder:decode(B), @@ -2310,8 +2311,8 @@ verify_signature2(Sig, Message, PK) -> % This is Bitcoin's variable-length unsigned integer encoding % See: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer -vencode(N) when N < 0 -> - {error, {negative_N, N}}; +vencode(N) when N =< 0 -> + {error, {non_pos_N, N}}; vencode(N) when N < 16#FD -> {ok, <>}; vencode(N) when N =< 16#FFFF ->