diff --git a/rebar.config b/rebar.config index b92aaa1..4e1a926 100644 --- a/rebar.config +++ b/rebar.config @@ -2,7 +2,7 @@ {erl_opts, [debug_info]}. -{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"677712b"}}} +{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"c63ac88"}}} , {getopt, "1.0.1"} , {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}} diff --git a/rebar.lock b/rebar.lock index ba48b19..a3392b5 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,7 +1,7 @@ {"1.1.0", [{<<"aebytecode">>, {git,"https://github.com/aeternity/aebytecode.git", - {ref,"677712b0b857da6a747b674b4efb1e030937f5f3"}}, + {ref,"c63ac888dd71c305cbc6d4f70953a176bf1f78f7"}}, 0}, {<<"aeserialization">>, {git,"https://github.com/aeternity/aeserialization.git", diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index b545f5b..c20e569 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -489,6 +489,11 @@ expr_to_fcode(Env, Type, {app, _Ann, Fun = {typed, _, _, {fun_t, _, NamedArgsT, {oracle, QType, RType} = type_to_fcode(Env, OType), TypeArgs = [{lit, {typerep, QType}}, {lit, {typerep, RType}}], builtin_to_fcode(B, FArgs ++ TypeArgs); + {builtin_u, B, _} when B =:= aens_resolve -> + %% Get the type we are assuming the name resolves to + AensType = type_to_fcode(Env, Type), + TypeArgs = [{lit, {typerep, AensType}}], + builtin_to_fcode(B, FArgs ++ TypeArgs); {builtin_u, B, _Ar} -> builtin_to_fcode(B, FArgs); {def_u, F, _Ar} -> {def, F, FArgs}; {remote_u, Ct, RFun, _Ar} -> {remote, Ct, RFun, FArgs}; diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index f6c776f..3a801a9 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -542,16 +542,20 @@ builtin_to_scode(Env, address_is_oracle, [_] = Args) -> call_to_scode(Env, aeb_fate_ops:is_oracle(?a, ?a), Args); builtin_to_scode(Env, address_is_contract, [_] = Args) -> call_to_scode(Env, aeb_fate_ops:is_contract(?a, ?a), Args); -builtin_to_scode(_Env, aens_resolve, [_, _] = _Args) -> - ?TODO(fate_aens_resolve_instruction); -builtin_to_scode(_Env, aens_preclaim, [_, _, _] = _Args) -> - ?TODO(fate_aens_preclaim_instruction); -builtin_to_scode(_Env, aens_claim, [_, _, _, _] = _Args) -> - ?TODO(fate_aens_claim_instruction); -builtin_to_scode(_Env, aens_transfer, [_, _, _, _] = _Args) -> - ?TODO(fate_aens_transfer_instruction); -builtin_to_scode(_Env, aens_revoke, [_, _, _] = _Args) -> - ?TODO(fate_aens_revoke_instruction); +builtin_to_scode(Env, aens_resolve, [_Name, _Key, _Type] = Args) -> + call_to_scode(Env, aeb_fate_ops:aens_resolve(?a, ?a, ?a, ?a), Args); +builtin_to_scode(Env, aens_preclaim, [_Sign, _Account, _Hash] = Args) -> + call_to_scode(Env, [aeb_fate_ops:aens_preclaim(?a, ?a, ?a), + tuple(0)], Args); +builtin_to_scode(Env, aens_claim, [_Sign, _Account, _NameString, _Salt] = Args) -> + call_to_scode(Env, [aeb_fate_ops:aens_claim(?a, ?a, ?a, ?a), + tuple(0)], Args); +builtin_to_scode(Env, aens_transfer, [_Sign, _From, _To, _Name] = Args) -> + call_to_scode(Env, [aeb_fate_ops:aens_transfer(?a, ?a, ?a, ?a), + tuple(0)], Args); +builtin_to_scode(Env, aens_revoke, [_Sign, _Account, _Name] = Args) -> + call_to_scode(Env, [aeb_fate_ops:aens_revoke(?a, ?a, ?a), + tuple(0)], Args); builtin_to_scode(_Env, auth_tx_hash, []) -> [aeb_fate_ops:auth_tx_hash(?a)]. @@ -853,7 +857,6 @@ attributes(I) -> {'LOG4', A, B, C, D, E} -> Impure(none, [A, B, C, D, E]); 'DEACTIVATE' -> Impure(none, []); {'SPEND', A, B} -> Impure(none, [A, B]); - {'ORACLE_REGISTER', A, B, C, D, E, F, G} -> Impure(A, [B, C, D, E, F, G]); {'ORACLE_QUERY', A, B, C, D, E, F, G, H} -> Impure(A, [B, C, D, E, F, G, H]); {'ORACLE_RESPOND', A, B, C, D, E, F} -> Impure(none, [A, B, C, D, E, F]); @@ -861,12 +864,12 @@ attributes(I) -> {'ORACLE_GET_ANSWER', A, B, C, D, E} -> Impure(A, [B, C, D, E]); {'ORACLE_GET_QUESTION', A, B, C, D, E}-> Impure(A, [B, C, D, E]); {'ORACLE_QUERY_FEE', A, B} -> Impure(A, [B]); - 'AENS_RESOLVE' -> Impure(?a, []); %% TODO - 'AENS_PRECLAIM' -> Impure(?a, []); %% TODO - 'AENS_CLAIM' -> Impure(?a, []); %% TODO - 'AENS_UPDATE' -> Impure(?a, []); %% TODO - 'AENS_TRANSFER' -> Impure(?a, []); %% TODO - 'AENS_REVOKE' -> Impure(?a, []); %% TODO + {'AENS_RESOLVE', A, B, C, D} -> Impure(A, [B, C, D]); + {'AENS_PRECLAIM', A, B, C} -> Impure(none, [A, B, C]); + {'AENS_CLAIM', A, B, C, D} -> Impure(none, [A, B, C, D]); + 'AENS_UPDATE' -> Impure(none, []);%% TODO + {'AENS_TRANSFER', A, B, C, D} -> Impure(none, [A, B, C, D]); + {'AENS_REVOKE', A, B, C} -> Impure(none, [A, B, C]); {'ABORT', A} -> Impure(pc, A); {'EXIT', A} -> Impure(pc, A); 'NOP' -> Pure(none, []) diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 2dbb9fd..921744e 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -116,7 +116,8 @@ compilable_contracts() -> "bytes_equality", "address_chain", "namespace_bug", - "bytes_to_x" + "bytes_to_x", + "aens" ]. not_yet_compilable(fate) -> []; diff --git a/test/contracts/aens.aes b/test/contracts/aens.aes index f682d2f..dcb4006 100644 --- a/test/contracts/aens.aes +++ b/test/contracts/aens.aes @@ -3,53 +3,53 @@ contract AENSTest = // Name resolution - function resolve_word(name : string, key : string) : option(address) = + stateful function resolve_word(name : string, key : string) : option(address) = AENS.resolve(name, key) - function resolve_string(name : string, key : string) : option(string) = + stateful function resolve_string(name : string, key : string) : option(string) = AENS.resolve(name, key) // Transactions - function preclaim(addr : address, // Claim on behalf of this account (can be Contract.address) - chash : hash) : () = // Commitment hash + stateful function preclaim(addr : address, // Claim on behalf of this account (can be Contract.address) + chash : hash) : () = // Commitment hash AENS.preclaim(addr, chash) - function signedPreclaim(addr : address, // Claim on behalf of this account (can be Contract.address) - chash : hash, // Commitment hash - sign : signature) : () = // Signed by addr (if not Contract.address) + stateful function signedPreclaim(addr : address, // Claim on behalf of this account (can be Contract.address) + chash : hash, // Commitment hash + sign : signature) : () = // Signed by addr (if not Contract.address) AENS.preclaim(addr, chash, signature = sign) - function claim(addr : address, - name : string, - salt : int) : () = + stateful function claim(addr : address, + name : string, + salt : int) : () = AENS.claim(addr, name, salt) - function signedClaim(addr : address, - name : string, - salt : int, - sign : signature) : () = + stateful function signedClaim(addr : address, + name : string, + salt : int, + sign : signature) : () = AENS.claim(addr, name, salt, signature = sign) // TODO: update() -- how to handle pointers? - function transfer(owner : address, - new_owner : address, - name_hash : hash) : () = + stateful function transfer(owner : address, + new_owner : address, + name_hash : hash) : () = AENS.transfer(owner, new_owner, name_hash) - function signedTransfer(owner : address, - new_owner : address, - name_hash : hash, - sign : signature) : () = + stateful function signedTransfer(owner : address, + new_owner : address, + name_hash : hash, + sign : signature) : () = AENS.transfer(owner, new_owner, name_hash, signature = sign) - function revoke(owner : address, - name_hash : hash) : () = + stateful function revoke(owner : address, + name_hash : hash) : () = AENS.revoke(owner, name_hash) - function signedRevoke(owner : address, - name_hash : hash, - sign : signature) : () = + stateful function signedRevoke(owner : address, + name_hash : hash, + sign : signature) : () = AENS.revoke(owner, name_hash, signature = sign)