Contract factories and bytecode introspection #796
@ -500,7 +500,13 @@ global_env() ->
|
|||||||
], var_args, A))},
|
], var_args, A))},
|
||||||
{"clone", Stateful(
|
{"clone", Stateful(
|
||||||
FunN([ {named_arg_t, Ann, {id, Ann, "gas"}, Int,
|
FunN([ {named_arg_t, Ann, {id, Ann, "gas"}, Int,
|
||||||
{qid, Ann, ["Call","gas_left"]}}
|
{typed, Ann,
|
||||||
|
{app, Ann,
|
||||||
|
{typed, Ann, {qid, Ann, ["Call","gas_left"]},
|
||||||
|
typesig_to_fun_t(Fun([], Int))
|
||||||
|
},
|
||||||
|
[]}, Int
|
||||||
|
}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
, {named_arg_t, Ann, {id, Ann, "value"}, Int, {typed, Ann, {int, Ann, 0}, Int}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "protected"}, Bool, {typed, Ann, {bool, Ann, false}, Bool}}
|
, {named_arg_t, Ann, {id, Ann, "protected"}, Bool, {typed, Ann, {bool, Ann, false}, Bool}}
|
||||||
, {named_arg_t, Ann, {id, Ann, "ref"}, A, undefined}
|
, {named_arg_t, Ann, {id, Ann, "ref"}, A, undefined}
|
||||||
|
@ -580,9 +580,18 @@ builtin_to_scode(Env, chain_bytecode_hash, [_Addr] = Args) ->
|
|||||||
call_to_scode(Env, aeb_fate_ops:bytecode_hash(?a, ?a), Args);
|
call_to_scode(Env, aeb_fate_ops:bytecode_hash(?a, ?a), Args);
|
||||||
builtin_to_scode(Env, chain_clone,
|
builtin_to_scode(Env, chain_clone,
|
||||||
[TypeRep, GasCap, Value, Prot, Contract | InitArgs]) ->
|
[TypeRep, GasCap, Value, Prot, Contract | InitArgs]) ->
|
||||||
call_to_scode(Env, aeb_fate_ops:clone_g(?a, ?a, ?a, ?a, ?a),
|
case GasCap of
|
||||||
[Contract, TypeRep, Value, GasCap, Prot | InitArgs]
|
{builtin, call_gas_left, _} ->
|
||||||
);
|
call_to_scode(Env, aeb_fate_ops:clone(?a, ?a, ?a, ?a),
|
||||||
|
[Contract, TypeRep, Value, Prot | InitArgs]
|
||||||
|
);
|
||||||
|
_ ->
|
||||||
|
io:format("\n\n************* GAS CAP: ~p\n\n", [GasCap]),
|
||||||
|
call_to_scode(Env, aeb_fate_ops:clone_g(?a, ?a, ?a, ?a, ?a),
|
||||||
|
[Contract, TypeRep, Value, GasCap, Prot | InitArgs]
|
||||||
|
)
|
||||||
|
end;
|
||||||
|
|
||||||
builtin_to_scode(Env, chain_create,
|
builtin_to_scode(Env, chain_create,
|
||||||
[ Code, TypeRep, Value | InitArgs]) ->
|
[ Code, TypeRep, Value | InitArgs]) ->
|
||||||
call_to_scode(Env, aeb_fate_ops:create(?a, ?a, ?a),
|
call_to_scode(Env, aeb_fate_ops:create(?a, ?a, ?a),
|
||||||
|
@ -26,14 +26,14 @@ run_test(Test) ->
|
|||||||
simple_compile_test_() ->
|
simple_compile_test_() ->
|
||||||
[ {"Testing the " ++ ContractName ++ " contract with the " ++ atom_to_list(Backend) ++ " backend",
|
[ {"Testing the " ++ ContractName ++ " contract with the " ++ atom_to_list(Backend) ++ " backend",
|
||||||
fun() ->
|
fun() ->
|
||||||
case compile(Backend, ContractName) of
|
case compile(Backend, ContractName, [pp_assembler]) of
|
||||||
#{byte_code := ByteCode,
|
#{byte_code := ByteCode,
|
||||||
contract_source := _,
|
contract_source := _,
|
||||||
type_info := _} when Backend == aevm ->
|
type_info := _} when Backend == aevm ->
|
||||||
?assertMatch(Code when is_binary(Code), ByteCode);
|
?assertMatch(Code when is_binary(Code), ByteCode);
|
||||||
#{fate_code := Code} when Backend == fate ->
|
#{fate_code := Code} when Backend == fate ->
|
||||||
Code1 = aeb_fate_code:deserialize(aeb_fate_code:serialize(Code)),
|
Code1 = aeb_fate_code:deserialize(aeb_fate_code:serialize(Code)),
|
||||||
?assertMatch({X, X}, {Code1, Code});
|
?assertMatch({X, X}, {Code1, Code}), error(xd);
|
||||||
ErrBin ->
|
ErrBin ->
|
||||||
io:format("\n~s", [ErrBin]),
|
io:format("\n~s", [ErrBin]),
|
||||||
error(ErrBin)
|
error(ErrBin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user