diff --git a/src/hz.erl b/src/hz.erl index 66699c0..a10cd9c 100644 --- a/src/hz.erl +++ b/src/hz.erl @@ -1189,7 +1189,7 @@ read_aci(Path) -> -spec contract_call(CallerID, AACI, ConID, Fun, Args) -> Result when CallerID :: unicode:chardata(), - AACI :: aaci(), + AACI :: aaci() | {aaci, Label :: term()}, ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -1224,7 +1224,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 :: aaci(), + AACI :: aaci() | {aaci, Label :: term()}, ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -1262,7 +1262,7 @@ contract_call(CallerID, Gas, AACI, ConID, Fun, Args) -> GasPrice :: pos_integer(), Amount :: non_neg_integer(), TTL :: non_neg_integer(), - AACI :: aaci(), + AACI :: aaci() | {aaci, Label :: term()}, ConID :: unicode:chardata(), Fun :: string(), Args :: [string()], @@ -2233,7 +2233,7 @@ lookup_aaci(Label) -> -spec aaci_lookup_spec(AACI, Fun) -> {ok, Type} | {error, Reason} - when AACI :: aaci(), + when AACI :: aaci() | {aaci, Label :: term()}, Fun :: binary() | string(), Type :: {term(), term()}, % FIXME Reason :: bad_fun_name | aaci_not_found. @@ -2243,15 +2243,15 @@ lookup_aaci(Label) -> %% prepare_contract/1. This type information, particularly the return type, is %% useful for calling decode_bytearray/2. -aaci_lookup_spec({aaci, Label}, Fun) -> - case hz_man:lookup_aaci(Label) of - {ok, AACI} -> aaci_lookup_spec(AACI, Fun); - error -> {error, aaci_not_found} - end; aaci_lookup_spec({aaci, _, FunDefs, _}, Fun) -> case maps:find(Fun, FunDefs) of A = {ok, _} -> A; error -> {error, bad_fun_name} + end; +aaci_lookup_spec({aaci, Label}, Fun) -> + case hz_man:lookup_aaci(Label) of + {ok, AACI} -> aaci_lookup_spec(AACI, Fun); + error -> {error, aaci_not_found} end. -spec min_gas_price() -> integer(). @@ -2278,15 +2278,15 @@ min_gas() -> 200000. -encode_call_data({aaci, Label}, Fun, Args) -> - case hz_man:lookup_aaci(Label) of - {ok, AACI} -> encode_call_data(AACI, Fun, Args); - error -> {error, aaci_not_found} - end; encode_call_data({aaci, _ContractName, FunDefs, _TypeDefs}, Fun, Args) -> case maps:find(Fun, FunDefs) of {ok, {ArgDef, _ResultDef}} -> encode_call_data2(ArgDef, Fun, Args); error -> {error, bad_fun_name} + end; +encode_call_data({aaci, Label}, Fun, Args) -> + case hz_man:lookup_aaci(Label) of + {ok, AACI} -> encode_call_data(AACI, Fun, Args); + error -> {error, aaci_not_found} end. encode_call_data2(ArgDef, Fun, Args) ->