Merge branch 'parser' of ssh://git.qpq.swiss:21203/QPQ-AG/hakuzaru into parser
This commit is contained in:
commit
bda4e89e58
16
src/hz.erl
16
src/hz.erl
@ -71,7 +71,7 @@
|
|||||||
contract_call/5,
|
contract_call/5,
|
||||||
contract_call/6,
|
contract_call/6,
|
||||||
contract_call/10,
|
contract_call/10,
|
||||||
decode_bytearray_fate/1, decode_bytearray/2,
|
decode_bytearray/2,
|
||||||
spend/5, spend/10,
|
spend/5, spend/10,
|
||||||
sign_tx/2, sign_tx/3,
|
sign_tx/2, sign_tx/3,
|
||||||
sign_message/2, verify_signature/3,
|
sign_message/2, verify_signature/3,
|
||||||
@ -703,8 +703,9 @@ decode_bytearray_fate(EncodedStr) ->
|
|||||||
{ok, Object}
|
{ok, Object}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec decode_bytearray(Type, EncodedStr) -> {ok, Result} | {error, Reason}
|
-spec decode_bytearray(EncodedStr, Format) -> {ok, Result} | {error, Reason}
|
||||||
when Type :: term(),
|
when Format :: fate | sophia | {sophia, Type} | {erlang, Type},
|
||||||
|
Type :: term(),
|
||||||
EncodedStr :: binary() | string(),
|
EncodedStr :: binary() | string(),
|
||||||
Result :: none | term(),
|
Result :: none | term(),
|
||||||
Reason :: term().
|
Reason :: term().
|
||||||
@ -715,13 +716,18 @@ decode_bytearray_fate(EncodedStr) ->
|
|||||||
%% must be the result type of the same function in the same AACI that was used
|
%% must be the result type of the same function in the same AACI that was used
|
||||||
%% to create the transaction that EncodedStr came from.
|
%% to create the transaction that EncodedStr came from.
|
||||||
|
|
||||||
decode_bytearray(Type, EncodedStr) ->
|
decode_bytearray(EncodedStr, Format) ->
|
||||||
case decode_bytearray_fate(EncodedStr) of
|
case decode_bytearray_fate(EncodedStr) of
|
||||||
{ok, none} -> {ok, none};
|
{ok, none} -> {ok, none};
|
||||||
{ok, Object} -> hz_aaci:fate_to_erlang(Type, Object);
|
{ok, FATE} -> decode_bytearray2(FATE, Format);
|
||||||
{error, Reason} -> {error, Reason}
|
{error, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
decode_bytearray2(FATE, fate) -> FATE;
|
||||||
|
decode_bytearray2(FATE, sophia) -> hz_sophia:fate_to_list(FATE);
|
||||||
|
decode_bytearray2(FATE, {sophia, Type}) -> hz_sophia:fate_to_list(Type, FATE);
|
||||||
|
decode_bytearray2(FATE, {erlang, Type}) -> hz_aaci:fate_to_erlang(Type, FATE).
|
||||||
|
|
||||||
to_binary(S) when is_binary(S) -> S;
|
to_binary(S) when is_binary(S) -> S;
|
||||||
to_binary(S) when is_list(S) -> list_to_binary(S).
|
to_binary(S) when is_list(S) -> list_to_binary(S).
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user