Bump gmserialization to v1.2.0
This commit is contained in:
parent
927cd42592
commit
0119f1207f
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
|
|
||||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {tag, "v3.4.1"}}}
|
{deps, [ {gmbytecode, {git, "https://git.qpq.swiss/QPQ-AG/gmbytecode.git",
|
||||||
|
{ref, "691b9742bf7e4aa6a4e8e209397916be5abe1763"}}}
|
||||||
, {eblake2, "1.0.0"}
|
, {eblake2, "1.0.0"}
|
||||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
|
, {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}
|
||||||
]}.
|
]}.
|
||||||
@ -13,8 +14,8 @@
|
|||||||
{base_plt_apps, [erts, kernel, stdlib, crypto, mnesia]}
|
{base_plt_apps, [erts, kernel, stdlib, crypto, mnesia]}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{relx, [{release, {aesophia, "8.0.1"},
|
{relx, [{release, {sophia, "8.0.1"},
|
||||||
[aesophia, aebytecode]},
|
[sophia, gmbytecode]},
|
||||||
|
|
||||||
{dev_mode, true},
|
{dev_mode, true},
|
||||||
{include_erts, false},
|
{include_erts, false},
|
||||||
|
24
rebar.lock
24
rebar.lock
@ -1,22 +1,22 @@
|
|||||||
{"1.2.0",
|
{"1.2.0",
|
||||||
[{<<"aebytecode">>,
|
[{<<"base58">>,
|
||||||
{git,"https://github.com/aeternity/aebytecode.git",
|
{git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git",
|
||||||
{ref,"6bd6f82c70d800950ea1a2c70c364a4181ff5291"}},
|
{ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}},
|
||||||
0},
|
|
||||||
{<<"aeserialization">>,
|
|
||||||
{git,"https://github.com/aeternity/aeserialization.git",
|
|
||||||
{ref,"b26e6d105424748ba1c27917267b7cff07f37802"}},
|
|
||||||
1},
|
|
||||||
{<<"base58">>,
|
|
||||||
{git,"https://github.com/aeternity/erl-base58.git",
|
|
||||||
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}},
|
|
||||||
2},
|
2},
|
||||||
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
|
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
|
||||||
{<<"enacl">>,
|
{<<"enacl">>,
|
||||||
{git,"https://github.com/aeternity/enacl.git",
|
{git,"https://git.qpq.swiss/QPQ-AG/enacl.git",
|
||||||
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
|
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
|
||||||
2},
|
2},
|
||||||
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},1},
|
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},1},
|
||||||
|
{<<"gmbytecode">>,
|
||||||
|
{git,"https://git.qpq.swiss/QPQ-AG/gmbytecode.git",
|
||||||
|
{ref,"691b9742bf7e4aa6a4e8e209397916be5abe1763"}},
|
||||||
|
0},
|
||||||
|
{<<"gmserialization">>,
|
||||||
|
{git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git",
|
||||||
|
{ref,"ac64e01b0f675c1a34c70a827062f381920742db"}},
|
||||||
|
1},
|
||||||
{<<"jsx">>,
|
{<<"jsx">>,
|
||||||
{git,"https://github.com/talentdeficit/jsx.git",
|
{git,"https://github.com/talentdeficit/jsx.git",
|
||||||
{ref,"3074d4865b3385a050badf7828ad31490d860df5"}},
|
{ref,"3074d4865b3385a050badf7828ad31490d860df5"}},
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
, validate_byte_code/3
|
, validate_byte_code/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("aebytecode/include/aeb_opcodes.hrl").
|
-include_lib("gmbytecode/include/gmb_opcodes.hrl").
|
||||||
-include("aeso_utils.hrl").
|
-include("aeso_utils.hrl").
|
||||||
|
|
||||||
|
|
||||||
@ -124,14 +124,14 @@ from_string1(ContractString, Options) ->
|
|||||||
SavedFreshNames = maps:get(saved_fresh_names, FCodeEnv, #{}),
|
SavedFreshNames = maps:get(saved_fresh_names, FCodeEnv, #{}),
|
||||||
FateCode = aeso_fcode_to_fate:compile(ChildContracts, FCode, SavedFreshNames, Options),
|
FateCode = aeso_fcode_to_fate:compile(ChildContracts, FCode, SavedFreshNames, Options),
|
||||||
pp_assembler(FateCode, Options),
|
pp_assembler(FateCode, Options),
|
||||||
ByteCode = aeb_fate_code:serialize(FateCode, []),
|
ByteCode = gmb_fate_code:serialize(FateCode, []),
|
||||||
{ok, Version} = version(),
|
{ok, Version} = version(),
|
||||||
Res = #{byte_code => ByteCode,
|
Res = #{byte_code => ByteCode,
|
||||||
compiler_version => Version,
|
compiler_version => Version,
|
||||||
contract_source => ContractString,
|
contract_source => ContractString,
|
||||||
type_info => [],
|
type_info => [],
|
||||||
fate_code => FateCode,
|
fate_code => FateCode,
|
||||||
abi_version => aeb_fate_abi:abi_version(),
|
abi_version => gmb_fate_abi:abi_version(),
|
||||||
payable => maps:get(payable, FCode),
|
payable => maps:get(payable, FCode),
|
||||||
warnings => Warnings
|
warnings => Warnings
|
||||||
},
|
},
|
||||||
@ -203,7 +203,7 @@ add_extra_call(Contract0, Call, Options) ->
|
|||||||
, ast := Ast} = string_to_code(Contract0, Options),
|
, ast := Ast} = string_to_code(Contract0, Options),
|
||||||
FateCode = aeso_fcode_to_fate:compile(ChildContracts, OrgFcode, #{}, []),
|
FateCode = aeso_fcode_to_fate:compile(ChildContracts, OrgFcode, #{}, []),
|
||||||
%% collect all hashes and compute the first name without hash collision to
|
%% collect all hashes and compute the first name without hash collision to
|
||||||
SymbolHashes = maps:keys(aeb_fate_code:symbols(FateCode)),
|
SymbolHashes = maps:keys(gmb_fate_code:symbols(FateCode)),
|
||||||
CallName = first_none_match(?CALL_NAME, SymbolHashes,
|
CallName = first_none_match(?CALL_NAME, SymbolHashes,
|
||||||
lists:seq($1, $9) ++ lists:seq($A, $Z) ++ lists:seq($a, $z)),
|
lists:seq($1, $9) ++ lists:seq($A, $Z) ++ lists:seq($a, $z)),
|
||||||
Contract = insert_call_function(Ast, Contract0, CallName, Call),
|
Contract = insert_call_function(Ast, Contract0, CallName, Call),
|
||||||
@ -220,7 +220,7 @@ encode_value(Contract0, Type, Value, Options) ->
|
|||||||
case add_extra_call(Contract0, {value, Type, Value}, Options) of
|
case add_extra_call(Contract0, {value, Type, Value}, Options) of
|
||||||
{ok, CallName, Code} ->
|
{ok, CallName, Code} ->
|
||||||
Body = get_call_body(CallName, Code),
|
Body = get_call_body(CallName, Code),
|
||||||
{ok, aeb_fate_encoding:serialize(aeso_fcode_to_fate:term_to_fate(Body))};
|
{ok, gmb_fate_encoding:serialize(aeso_fcode_to_fate:term_to_fate(Body))};
|
||||||
Err = {error, _} ->
|
Err = {error, _} ->
|
||||||
Err
|
Err
|
||||||
end.
|
end.
|
||||||
@ -243,7 +243,7 @@ decode_value(Contract0, Type, FateValue, Options) ->
|
|||||||
first_none_match(_CallName, _Hashes, []) ->
|
first_none_match(_CallName, _Hashes, []) ->
|
||||||
error(unable_to_find_unique_call_name);
|
error(unable_to_find_unique_call_name);
|
||||||
first_none_match(CallName, Hashes, [Char|Chars]) ->
|
first_none_match(CallName, Hashes, [Char|Chars]) ->
|
||||||
case not lists:member(aeb_fate_code:symbol_identifier(list_to_binary(CallName)), Hashes) of
|
case not lists:member(gmb_fate_code:symbol_identifier(list_to_binary(CallName)), Hashes) of
|
||||||
true ->
|
true ->
|
||||||
CallName;
|
CallName;
|
||||||
false ->
|
false ->
|
||||||
@ -303,7 +303,7 @@ to_sophia_value(ContractString, Fun, ResType, Data) ->
|
|||||||
to_sophia_value(_, _, error, Err, _Options) ->
|
to_sophia_value(_, _, error, Err, _Options) ->
|
||||||
{ok, {app, [], {id, [], "error"}, [{string, [], Err}]}};
|
{ok, {app, [], {id, [], "error"}, [{string, [], Err}]}};
|
||||||
to_sophia_value(_, _, revert, Data, _Options) ->
|
to_sophia_value(_, _, revert, Data, _Options) ->
|
||||||
try aeso_vm_decode:from_fate({id, [], "string"}, aeb_fate_encoding:deserialize(Data)) of
|
try aeso_vm_decode:from_fate({id, [], "string"}, gmb_fate_encoding:deserialize(Data)) of
|
||||||
Err ->
|
Err ->
|
||||||
{ok, {app, [], {id, [], "abort"}, [Err]}}
|
{ok, {app, [], {id, [], "abort"}, [Err]}}
|
||||||
catch _:_ ->
|
catch _:_ ->
|
||||||
@ -328,11 +328,11 @@ to_sophia_value(ContractString, FunName, ok, Data, Options0) ->
|
|||||||
|
|
||||||
fate_data_to_sophia_value(Type, UnfoldedType, FateData) ->
|
fate_data_to_sophia_value(Type, UnfoldedType, FateData) ->
|
||||||
try
|
try
|
||||||
{ok, aeso_vm_decode:from_fate(UnfoldedType, aeb_fate_encoding:deserialize(FateData))}
|
{ok, aeso_vm_decode:from_fate(UnfoldedType, gmb_fate_encoding:deserialize(FateData))}
|
||||||
catch throw:cannot_translate_to_sophia ->
|
catch throw:cannot_translate_to_sophia ->
|
||||||
Type1 = prettypr:format(aeso_pretty:type(Type)),
|
Type1 = prettypr:format(aeso_pretty:type(Type)),
|
||||||
Msg = io_lib:format("Cannot translate FATE value ~p\n of Sophia type ~s",
|
Msg = io_lib:format("Cannot translate FATE value ~p\n of Sophia type ~s",
|
||||||
[aeb_fate_encoding:deserialize(FateData), Type1]),
|
[gmb_fate_encoding:deserialize(FateData), Type1]),
|
||||||
{error, [aeso_errors:new(data_error, Msg)]};
|
{error, [aeso_errors:new(data_error, Msg)]};
|
||||||
_:_ ->
|
_:_ ->
|
||||||
Type1 = prettypr:format(aeso_pretty:type(Type)),
|
Type1 = prettypr:format(aeso_pretty:type(Type)),
|
||||||
@ -350,7 +350,7 @@ create_calldata(Code, Fun, Args, Options0) ->
|
|||||||
Options = [no_code | Options0],
|
Options = [no_code | Options0],
|
||||||
case check_call(Code, Fun, Args, Options) of
|
case check_call(Code, Fun, Args, Options) of
|
||||||
{ok, FunName, FateArgs} ->
|
{ok, FunName, FateArgs} ->
|
||||||
aeb_fate_abi:create_calldata(FunName, FateArgs);
|
gmb_fate_abi:create_calldata(FunName, FateArgs);
|
||||||
{error, _} = Err -> Err
|
{error, _} = Err -> Err
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ decode_calldata(ContractString, FunName, Calldata, Options0) ->
|
|||||||
[ unfold_record_types
|
[ unfold_record_types
|
||||||
, unfold_variant_types
|
, unfold_variant_types
|
||||||
, not_unfold_system_alias_types]),
|
, not_unfold_system_alias_types]),
|
||||||
case aeb_fate_abi:decode_calldata(FunName, Calldata) of
|
case gmb_fate_abi:decode_calldata(FunName, Calldata) of
|
||||||
{ok, FateArgs} ->
|
{ok, FateArgs} ->
|
||||||
try
|
try
|
||||||
{tuple_t, [], ArgTypes1} = Type,
|
{tuple_t, [], ArgTypes1} = Type,
|
||||||
@ -424,7 +424,7 @@ pp_sophia_code(C, Opts)-> pp(C, Opts, pp_sophia_code, fun(Code) ->
|
|||||||
pp_ast(C, Opts) -> pp(C, Opts, pp_ast, fun aeso_ast:pp/1).
|
pp_ast(C, Opts) -> pp(C, Opts, pp_ast, fun aeso_ast:pp/1).
|
||||||
pp_typed_ast(C, Opts)-> pp(C, Opts, pp_typed_ast, fun aeso_ast:pp_typed/1).
|
pp_typed_ast(C, Opts)-> pp(C, Opts, pp_typed_ast, fun aeso_ast:pp_typed/1).
|
||||||
|
|
||||||
pp_assembler(C, Opts) -> pp(C, Opts, pp_assembler, fun(Asm) -> io:format("~s", [aeb_fate_asm:pp(Asm)]) end).
|
pp_assembler(C, Opts) -> pp(C, Opts, pp_assembler, fun(Asm) -> io:format("~s", [gmb_fate_asm:pp(Asm)]) end).
|
||||||
|
|
||||||
pp(Code, Options, Option, PPFun) ->
|
pp(Code, Options, Option, PPFun) ->
|
||||||
case proplists:lookup(Option, Options) of
|
case proplists:lookup(Option, Options) of
|
||||||
@ -442,14 +442,14 @@ pp(Code, Options, Option, PPFun) ->
|
|||||||
validate_byte_code(#{ byte_code := ByteCode, payable := Payable }, Source, Options) ->
|
validate_byte_code(#{ byte_code := ByteCode, payable := Payable }, Source, Options) ->
|
||||||
Fail = fun(Err) -> {error, [aeso_errors:new(data_error, Err)]} end,
|
Fail = fun(Err) -> {error, [aeso_errors:new(data_error, Err)]} end,
|
||||||
try
|
try
|
||||||
FCode1 = ?protect(deserialize, aeb_fate_code:strip_init_function(aeb_fate_code:deserialize(ByteCode))),
|
FCode1 = ?protect(deserialize, gmb_fate_code:strip_init_function(gmb_fate_code:deserialize(ByteCode))),
|
||||||
{FCode2, SrcPayable} =
|
{FCode2, SrcPayable} =
|
||||||
?protect(compile,
|
?protect(compile,
|
||||||
begin
|
begin
|
||||||
{ok, #{ byte_code := SrcByteCode, payable := SrcPayable }} =
|
{ok, #{ byte_code := SrcByteCode, payable := SrcPayable }} =
|
||||||
from_string1(Source, Options),
|
from_string1(Source, Options),
|
||||||
FCode = aeb_fate_code:deserialize(SrcByteCode),
|
FCode = gmb_fate_code:deserialize(SrcByteCode),
|
||||||
{aeb_fate_code:strip_init_function(FCode), SrcPayable}
|
{gmb_fate_code:strip_init_function(FCode), SrcPayable}
|
||||||
end),
|
end),
|
||||||
case compare_fate_code(FCode1, FCode2) of
|
case compare_fate_code(FCode1, FCode2) of
|
||||||
ok when SrcPayable /= Payable ->
|
ok when SrcPayable /= Payable ->
|
||||||
@ -465,10 +465,10 @@ validate_byte_code(#{ byte_code := ByteCode, payable := Payable }, Source, Optio
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
compare_fate_code(FCode1, FCode2) ->
|
compare_fate_code(FCode1, FCode2) ->
|
||||||
Funs1 = aeb_fate_code:functions(FCode1),
|
Funs1 = gmb_fate_code:functions(FCode1),
|
||||||
Funs2 = aeb_fate_code:functions(FCode2),
|
Funs2 = gmb_fate_code:functions(FCode2),
|
||||||
Syms1 = aeb_fate_code:symbols(FCode1),
|
Syms1 = gmb_fate_code:symbols(FCode1),
|
||||||
Syms2 = aeb_fate_code:symbols(FCode2),
|
Syms2 = gmb_fate_code:symbols(FCode2),
|
||||||
FunHashes1 = maps:keys(Funs1),
|
FunHashes1 = maps:keys(Funs1),
|
||||||
FunHashes2 = maps:keys(Funs2),
|
FunHashes2 = maps:keys(Funs2),
|
||||||
case FunHashes1 == FunHashes2 of
|
case FunHashes1 == FunHashes2 of
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
-export([ from_fate/2 ]).
|
-export([ from_fate/2 ]).
|
||||||
|
|
||||||
-include_lib("aebytecode/include/aeb_fate_data.hrl").
|
-include_lib("gmbytecode/include/gmb_fate_data.hrl").
|
||||||
|
|
||||||
-spec from_fate(aeso_syntax:type(), aeb_fate_data:fate_type()) -> aeso_syntax:expr().
|
-spec from_fate(aeso_syntax:type(), gmb_fate_data:fate_type()) -> aeso_syntax:expr().
|
||||||
from_fate({id, _, "address"}, ?FATE_ADDRESS(Bin)) -> {account_pubkey, [], Bin};
|
from_fate({id, _, "address"}, ?FATE_ADDRESS(Bin)) -> {account_pubkey, [], Bin};
|
||||||
from_fate({id, _, "signature"}, ?FATE_BYTES(Bin)) -> {signature, [], Bin};
|
from_fate({id, _, "signature"}, ?FATE_BYTES(Bin)) -> {signature, [], Bin};
|
||||||
from_fate({id, _, "hash"}, ?FATE_BYTES(Bin)) -> {bytes, [], Bin};
|
from_fate({id, _, "hash"}, ?FATE_BYTES(Bin)) -> {bytes, [], Bin};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
stdlib,
|
stdlib,
|
||||||
jsx,
|
jsx,
|
||||||
syntax_tools,
|
syntax_tools,
|
||||||
aebytecode,
|
gmbytecode,
|
||||||
eblake2
|
eblake2
|
||||||
]},
|
]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user