Rename get_function_signature
hz_aaci:aaci_get_function_signature is a bit redundant.
This commit is contained in:
parent
4f1958b210
commit
6f5525afcf
@ -1475,10 +1475,10 @@ lookup_aaci(Label) ->
|
||||
%% useful for calling decode_bytearray/2.
|
||||
|
||||
aaci_lookup_spec(AACI = {aaci, _, _, _}, Fun) ->
|
||||
hz_aaci:aaci_get_function_signature(AACI, Fun);
|
||||
hz_aaci:get_function_signature(AACI, Fun);
|
||||
aaci_lookup_spec({aaci, Label}, Fun) ->
|
||||
case hz_man:lookup_aaci(Label) of
|
||||
{ok, AACI} -> hz_aaci:aaci_get_function_signature(AACI, Fun);
|
||||
{ok, AACI} -> hz_aaci:get_function_signature(AACI, Fun);
|
||||
error -> {error, aaci_not_found}
|
||||
end.
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
erlang_to_fate/2,
|
||||
fate_to_erlang/2,
|
||||
erlang_args_to_fate/2,
|
||||
aaci_get_function_signature/2]).
|
||||
get_function_signature/2]).
|
||||
|
||||
%%% Types
|
||||
|
||||
@ -855,7 +855,7 @@ fate_to_erlang({O, N, _}, Data) ->
|
||||
|
||||
%%% AACI Getters
|
||||
|
||||
-spec aaci_get_function_signature(AACI, Fun) -> {ok, Type} | {error, Reason}
|
||||
-spec get_function_signature(AACI, Fun) -> {ok, Type} | {error, Reason}
|
||||
when AACI :: aaci(),
|
||||
Fun :: binary() | string(),
|
||||
Type :: {term(), term()}, % FIXME
|
||||
@ -866,7 +866,7 @@ fate_to_erlang({O, N, _}, Data) ->
|
||||
%% prepare_contract/1. This type information, particularly the return type, is
|
||||
%% useful for calling decode_bytearray/2.
|
||||
|
||||
aaci_get_function_signature({aaci, _, FunDefs, _}, Fun) ->
|
||||
get_function_signature({aaci, _, FunDefs, _}, Fun) ->
|
||||
case maps:find(Fun, FunDefs) of
|
||||
{ok, A} -> {ok, A};
|
||||
error -> {error, bad_fun_name}
|
||||
@ -1022,7 +1022,7 @@ namespace_coerce_test() ->
|
||||
entrypoint f(): N.pair = { a = 1, b = 2 }
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "f"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "f"),
|
||||
check_roundtrip(Output, #{"a" => 123, "b" => 456}, {tuple, {123, 456}}).
|
||||
|
||||
record_substitution_test() ->
|
||||
@ -1032,7 +1032,7 @@ record_substitution_test() ->
|
||||
entrypoint f(): pair(int) = { a = 1, b = 2 }
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "f"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "f"),
|
||||
check_roundtrip(Output, #{"a" => 123, "b" => 456}, {tuple, {123, 456}}).
|
||||
|
||||
tuple_substitution_test() ->
|
||||
@ -1042,7 +1042,7 @@ tuple_substitution_test() ->
|
||||
entrypoint f(): triple(int, string) = (1, 2, \"hello\")
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "f"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "f"),
|
||||
check_roundtrip(Output, {1, 2, "hello"}, {tuple, {1, 2, <<"hello">>}}).
|
||||
|
||||
variant_substitution_test() ->
|
||||
@ -1052,7 +1052,7 @@ variant_substitution_test() ->
|
||||
entrypoint f(): adt(string, int) = Left(\"hi\", 1)
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "f"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "f"),
|
||||
check_roundtrip(Output, {"Left", "hi", 1}, {variant, [2, 2], 0, {<<"hi">>, 1}}),
|
||||
check_roundtrip(Output, {"Right", 2, 3}, {variant, [2, 2], 1, {2, 3}}).
|
||||
|
||||
@ -1064,7 +1064,7 @@ nested_coerce_test() ->
|
||||
entrypoint f(): r = { f1 = (1, 2), f2 = (\"a\", \"b\") }
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "f"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "f"),
|
||||
check_roundtrip(Output,
|
||||
#{ "f1" => {1, 2}, "f2" => {"a", "b"}},
|
||||
{tuple, {{tuple, {1, 2}}, {tuple, {<<"a">>, <<"b">>}}}}).
|
||||
@ -1076,7 +1076,7 @@ state_coerce_test() ->
|
||||
entrypoint init(): state = 0
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[], Output}} = aaci_get_function_signature(AACI, "init"),
|
||||
{ok, {[], Output}} = get_function_signature(AACI, "init"),
|
||||
check_roundtrip(Output, 0, 0).
|
||||
|
||||
param_test() ->
|
||||
@ -1086,7 +1086,7 @@ param_test() ->
|
||||
entrypoint init(x): state = x
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
{ok, {[{"x", Input}], Output}} = aaci_get_function_signature(AACI, "init"),
|
||||
{ok, {[{"x", Input}], Output}} = get_function_signature(AACI, "init"),
|
||||
check_roundtrip(Input, 0, 0),
|
||||
check_roundtrip(Output, 0, 0).
|
||||
|
||||
@ -1129,30 +1129,30 @@ obscure_aaci_test() ->
|
||||
",
|
||||
{ok, AACI} = aaci_from_string(Contract),
|
||||
|
||||
{ok, {[], {{bytes, [4]}, _, _}}} = aaci_get_function_signature(AACI, "fixed_bytes"),
|
||||
{ok, {[], {{bytes, [any]}, _, _}}} = aaci_get_function_signature(AACI, "any_bytes"),
|
||||
{ok, {[], {bits, _, _}}} = aaci_get_function_signature(AACI, "bits"),
|
||||
{ok, {[], {char, _, _}}} = aaci_get_function_signature(AACI, "character"),
|
||||
{ok, {[], {{bytes, [4]}, _, _}}} = get_function_signature(AACI, "fixed_bytes"),
|
||||
{ok, {[], {{bytes, [any]}, _, _}}} = get_function_signature(AACI, "any_bytes"),
|
||||
{ok, {[], {bits, _, _}}} = get_function_signature(AACI, "bits"),
|
||||
{ok, {[], {char, _, _}}} = get_function_signature(AACI, "character"),
|
||||
|
||||
{ok, {[], {{"option", [integer]}, _, {variant, [{"None", []}, {"Some", [_]}]}}}} = aaci_get_function_signature(AACI, "options"),
|
||||
{ok, {[], {"hash", _, {bytes, [32]}}}} = aaci_get_function_signature(AACI, "hash"),
|
||||
{ok, {[], {"unit", _, {tuple, []}}}} = aaci_get_function_signature(AACI, "unit"),
|
||||
{ok, {[], {{"option", [integer]}, _, {variant, [{"None", []}, {"Some", [_]}]}}}} = get_function_signature(AACI, "options"),
|
||||
{ok, {[], {"hash", _, {bytes, [32]}}}} = get_function_signature(AACI, "hash"),
|
||||
{ok, {[], {"unit", _, {tuple, []}}}} = get_function_signature(AACI, "unit"),
|
||||
|
||||
{ok, {_, {"Chain.ttl", _, {variant, _}}}} = aaci_get_function_signature(AACI, "ttl"),
|
||||
{ok, {_, {"Chain.paying_for_tx", _, {variant, _}}}} = aaci_get_function_signature(AACI, "paying_for"),
|
||||
{ok, {_, {"Chain.ga_meta_tx", _, {variant, _}}}} = aaci_get_function_signature(AACI, "ga_meta_tx"),
|
||||
{ok, {_, {"Chain.base_tx", _, {variant, _}}}} = aaci_get_function_signature(AACI, "base_tx"),
|
||||
{ok, {_, {"Chain.tx", _, {record, _}}}} = aaci_get_function_signature(AACI, "tx"),
|
||||
{ok, {_, {"Chain.ttl", _, {variant, _}}}} = get_function_signature(AACI, "ttl"),
|
||||
{ok, {_, {"Chain.paying_for_tx", _, {variant, _}}}} = get_function_signature(AACI, "paying_for"),
|
||||
{ok, {_, {"Chain.ga_meta_tx", _, {variant, _}}}} = get_function_signature(AACI, "ga_meta_tx"),
|
||||
{ok, {_, {"Chain.base_tx", _, {variant, _}}}} = get_function_signature(AACI, "base_tx"),
|
||||
{ok, {_, {"Chain.tx", _, {record, _}}}} = get_function_signature(AACI, "tx"),
|
||||
|
||||
{ok, {_, {"AENS.pointee", _, {variant, _}}}} = aaci_get_function_signature(AACI, "pointee"),
|
||||
{ok, {_, {"AENS.name", _, {variant, _}}}} = aaci_get_function_signature(AACI, "name"),
|
||||
{ok, {_, {"AENSv2.pointee", _, {variant, _}}}} = aaci_get_function_signature(AACI, "pointee2"),
|
||||
{ok, {_, {"AENSv2.name", _, {variant, _}}}} = aaci_get_function_signature(AACI, "name2"),
|
||||
{ok, {_, {"AENS.pointee", _, {variant, _}}}} = get_function_signature(AACI, "pointee"),
|
||||
{ok, {_, {"AENS.name", _, {variant, _}}}} = get_function_signature(AACI, "name"),
|
||||
{ok, {_, {"AENSv2.pointee", _, {variant, _}}}} = get_function_signature(AACI, "pointee2"),
|
||||
{ok, {_, {"AENSv2.name", _, {variant, _}}}} = get_function_signature(AACI, "name2"),
|
||||
|
||||
{ok, {_, {"MCL_BLS12_381.fr", _, {bytes, [32]}}}} = aaci_get_function_signature(AACI, "fr"),
|
||||
{ok, {_, {"MCL_BLS12_381.fp", _, {bytes, [48]}}}} = aaci_get_function_signature(AACI, "fp"),
|
||||
{ok, {_, {"MCL_BLS12_381.fr", _, {bytes, [32]}}}} = get_function_signature(AACI, "fr"),
|
||||
{ok, {_, {"MCL_BLS12_381.fp", _, {bytes, [48]}}}} = get_function_signature(AACI, "fp"),
|
||||
|
||||
{ok, {[], {{"Set.set", [integer]}, _, {record, [{"to_map", _}]}}}} = aaci_get_function_signature(AACI, "set"),
|
||||
{ok, {[], {{"Set.set", [integer]}, _, {record, [{"to_map", _}]}}}} = get_function_signature(AACI, "set"),
|
||||
|
||||
ok.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user