Handle signature, hash and map in create_calldata for FATE
This commit is contained in:
parent
11dc632927
commit
81f277127d
@ -37,6 +37,8 @@
|
||||
|
||||
-type flit() :: {int, integer()}
|
||||
| {string, binary()}
|
||||
| {hash, binary()}
|
||||
| {signature, binary()}
|
||||
| {account_pubkey, binary()}
|
||||
| {contract_pubkey, binary()}
|
||||
| {oracle_pubkey, binary()}
|
||||
@ -365,6 +367,8 @@ expr_to_fcode(_Env, _Type, {contract_pubkey, _, K}) -> {lit, {contract_pubkey, K
|
||||
expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {lit, {oracle_pubkey, K}};
|
||||
expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {lit, {oracle_query_id, K}};
|
||||
|
||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:32/binary>>}) -> {lit, {hash, Bin}};
|
||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:64/binary>>}) -> {lit, {signature, Bin}};
|
||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin}) -> {lit, {string, Bin}};
|
||||
|
||||
%% Variables
|
||||
|
@ -236,6 +236,8 @@ lit_to_fate(L) ->
|
||||
case L of
|
||||
{int, N} -> aeb_fate_data:make_integer(N);
|
||||
{string, S} -> aeb_fate_data:make_string(S);
|
||||
{hash, H} -> aeb_fate_data:make_hash(H);
|
||||
{signature, S} -> aeb_fate_data:make_signature(S);
|
||||
{bool, B} -> aeb_fate_data:make_boolean(B);
|
||||
{account_pubkey, K} -> aeb_fate_data:make_address(K);
|
||||
{contract_pubkey, K} -> aeb_fate_data:make_contract(K);
|
||||
@ -257,8 +259,16 @@ term_to_fate({tuple, As}) ->
|
||||
aeb_fate_data:make_tuple(list_to_tuple([ term_to_fate(A) || A<-As]));
|
||||
term_to_fate({con, Ar, I, As}) ->
|
||||
FateAs = [ term_to_fate(A) || A <- As ],
|
||||
aeb_fate_data:make_variant(Ar, I, list_to_tuple(FateAs)).
|
||||
aeb_fate_data:make_variant(Ar, I, list_to_tuple(FateAs));
|
||||
term_to_fate({builtin, map_empty, []}) ->
|
||||
aeb_fate_data:make_map(#{});
|
||||
term_to_fate({'let', _, {builtin, map_empty, []}, Set}) ->
|
||||
aeb_fate_data:make_map(map_to_fate(Set)).
|
||||
|
||||
map_to_fate({op, map_set, [{var, _}, K, V]}) ->
|
||||
#{term_to_fate(K) => term_to_fate(V)};
|
||||
map_to_fate({op, map_set, [Set, K, V]}) ->
|
||||
Map = map_to_fate(Set), Map#{term_to_fate(K) => term_to_fate(V)}.
|
||||
|
||||
to_scode(_Env, {lit, L}) ->
|
||||
[push(?i(lit_to_fate(L)))];
|
||||
|
@ -57,20 +57,22 @@ compilable_contracts() ->
|
||||
["ak_2gx9MEFxKvY9vMG5YnqnXWv1hCsX7rgnfvBLJS4aQurustR1rt", "200000", "1000"]},
|
||||
{"maps", "fromlist_i",
|
||||
["[(1, {x = 1, y = 2}), (2, {x = 3, y = 4}), (3, {x = 4, y = 4})]"]},
|
||||
{"maps", "get_i", ["1", "{}"]},
|
||||
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}}"]},
|
||||
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}}"]},
|
||||
{"maps", "get_i", ["1", "{[1] = {x = 3, y = 4}, [2] = {x = 4, y = 5}, [3] = {x = 5, y = 6}}"]},
|
||||
{"strings", "str_concat", ["\"test\"","\"me\""]},
|
||||
{"complex_types", "filter_some", ["[Some(1), Some(2), None]"]},
|
||||
{"complex_types", "init", ["ct_Ez6MyeTMm17YnTnDdHTSrzMEBKmy7Uz2sXu347bTDPgVH2ifJ"]},
|
||||
{"__call" "init", []},
|
||||
{"bitcoin_auth", "init",
|
||||
["#0102030405060708090a0b0c0d0e0f1017181920212223242526272829303132"
|
||||
"33343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]}
|
||||
{"bitcoin_auth", "authorize", ["1", "#0102030405060708090a0b0c0d0e0f101718192021222324252627282930313233343536373839401a1b1c1d1e1f202122232425262728293031323334353637"]},
|
||||
{"bitcoin_auth", "to_sign", ["#0102030405060708090a0b0c0d0e0f1017181920212223242526272829303132", "2"]}
|
||||
|
||||
].
|
||||
|
||||
not_yet_compilable(fate) ->
|
||||
["oracles", %% Oracle.register
|
||||
"events",
|
||||
"basic_auth", %% auth_tx_hash instruction
|
||||
"bitcoin_auth", %% fate_auth_tx_hash_instruction
|
||||
"address_literals", %% oracle_query_id literals
|
||||
"address_chain" %% Oracle.check_query
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user