Document hz_aaci functions
Once the types were documented, the functions were easy to document. Just say "see erlang_expr/0 for details" over and over! ;p
This commit is contained in:
+22
-5
@@ -375,8 +375,10 @@
|
|||||||
AACI :: aaci(),
|
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 contract type information for forming contract calls
|
||||||
%% of calldata
|
%% This is the simplest (but slowest) way of getting access to the AACI
|
||||||
|
%% structure for a contract. Having the AACI is not strictly necessary, but
|
||||||
|
%% makes it much more convenient to form contract calls and view their results.
|
||||||
|
|
||||||
prepare_from_file(Path) ->
|
prepare_from_file(Path) ->
|
||||||
case so_compiler:file(Path, [{aci, json}]) of
|
case so_compiler:file(Path, [{aci, json}]) of
|
||||||
@@ -388,6 +390,10 @@ prepare_from_file(Path) ->
|
|||||||
when ACI :: term(),
|
when ACI :: term(),
|
||||||
AACI :: aaci().
|
AACI :: aaci().
|
||||||
|
|
||||||
|
%% @doc
|
||||||
|
%% Convert the ACI structure produced by the compiler into the AACI format used by Hakuzaru
|
||||||
|
%% See the documentation for the aaci/0 type for more information.
|
||||||
|
|
||||||
prepare(ACI) ->
|
prepare(ACI) ->
|
||||||
% We want to take the types represented by the ACI, things like N1.T(N2.T),
|
% We want to take the types represented by the ACI, things like N1.T(N2.T),
|
||||||
% and dereference them down to concrete types like
|
% and dereference them down to concrete types like
|
||||||
@@ -1209,6 +1215,14 @@ coerce_direction(Type, Term, from_fate) ->
|
|||||||
Reason :: term(),
|
Reason :: term(),
|
||||||
PathStep :: term().
|
PathStep :: term().
|
||||||
|
|
||||||
|
%% @doc
|
||||||
|
%% Convert a FATE-flavored Erlang term into a Sophia-flavored Erlang term
|
||||||
|
%% Typically this is called by hakuzaru for you when decoding results from the
|
||||||
|
%% chain, if you ask for the 'erlang' format, but you can call this function
|
||||||
|
%% manually if you have a result in the 'fate' format, and need the 'erlang'
|
||||||
|
%% format now. See the documentation of the erlang_repr/0 type for more
|
||||||
|
%% information.
|
||||||
|
|
||||||
fate_to_erlang({_, _, integer}, S) when is_integer(S) ->
|
fate_to_erlang({_, _, integer}, S) when is_integer(S) ->
|
||||||
{ok, S};
|
{ok, S};
|
||||||
fate_to_erlang({_, _, address}, {address, Bin}) ->
|
fate_to_erlang({_, _, address}, {address, Bin}) ->
|
||||||
@@ -1298,9 +1312,12 @@ opaque_type_to_iolist(N, _) ->
|
|||||||
Reason :: bad_fun_name.
|
Reason :: bad_fun_name.
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Look up the type information of a given function, in the AACI provided by
|
%% Extract the type information for a particular function from the AACI
|
||||||
%% prepare_contract/1. This type information, particularly the return type, is
|
%% If you want to manually convert a FATE result into the Sophia-flavored
|
||||||
%% useful for calling decode_bytearray/2.
|
%% Erlang representation, or manually convert some or all of the inputs for a
|
||||||
|
%% contract call yourself, this function gives you all of the annotated types
|
||||||
|
%% associated with a contract entrypoint. For more information, see the
|
||||||
|
%% documentation for the annotated_type/0 type.
|
||||||
|
|
||||||
get_function_signature({aaci, _, FunDefs, _}, Fun) ->
|
get_function_signature({aaci, _, FunDefs, _}, Fun) ->
|
||||||
case maps:find(Fun, FunDefs) of
|
case maps:find(Fun, FunDefs) of
|
||||||
|
|||||||
Reference in New Issue
Block a user