Merge pull request #96 from aeternity/PT-166233700-fate-nameservice
Implement aens instructions for fate
This commit is contained in:
commit
02ba4b265b
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{erl_opts, [debug_info]}.
|
{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"}
|
, {getopt, "1.0.1"}
|
||||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git",
|
, {jsx, {git, "https://github.com/talentdeficit/jsx.git",
|
||||||
{tag, "2.8.0"}}}
|
{tag, "2.8.0"}}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{"1.1.0",
|
{"1.1.0",
|
||||||
[{<<"aebytecode">>,
|
[{<<"aebytecode">>,
|
||||||
{git,"https://github.com/aeternity/aebytecode.git",
|
{git,"https://github.com/aeternity/aebytecode.git",
|
||||||
{ref,"677712b0b857da6a747b674b4efb1e030937f5f3"}},
|
{ref,"c63ac888dd71c305cbc6d4f70953a176bf1f78f7"}},
|
||||||
0},
|
0},
|
||||||
{<<"aeserialization">>,
|
{<<"aeserialization">>,
|
||||||
{git,"https://github.com/aeternity/aeserialization.git",
|
{git,"https://github.com/aeternity/aeserialization.git",
|
||||||
|
@ -489,6 +489,11 @@ expr_to_fcode(Env, Type, {app, _Ann, Fun = {typed, _, _, {fun_t, _, NamedArgsT,
|
|||||||
{oracle, QType, RType} = type_to_fcode(Env, OType),
|
{oracle, QType, RType} = type_to_fcode(Env, OType),
|
||||||
TypeArgs = [{lit, {typerep, QType}}, {lit, {typerep, RType}}],
|
TypeArgs = [{lit, {typerep, QType}}, {lit, {typerep, RType}}],
|
||||||
builtin_to_fcode(B, FArgs ++ TypeArgs);
|
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);
|
{builtin_u, B, _Ar} -> builtin_to_fcode(B, FArgs);
|
||||||
{def_u, F, _Ar} -> {def, F, FArgs};
|
{def_u, F, _Ar} -> {def, F, FArgs};
|
||||||
{remote_u, Ct, RFun, _Ar} -> {remote, Ct, RFun, FArgs};
|
{remote_u, Ct, RFun, _Ar} -> {remote, Ct, RFun, FArgs};
|
||||||
|
@ -542,16 +542,20 @@ builtin_to_scode(Env, address_is_oracle, [_] = Args) ->
|
|||||||
call_to_scode(Env, aeb_fate_ops:is_oracle(?a, ?a), Args);
|
call_to_scode(Env, aeb_fate_ops:is_oracle(?a, ?a), Args);
|
||||||
builtin_to_scode(Env, address_is_contract, [_] = Args) ->
|
builtin_to_scode(Env, address_is_contract, [_] = Args) ->
|
||||||
call_to_scode(Env, aeb_fate_ops:is_contract(?a, ?a), Args);
|
call_to_scode(Env, aeb_fate_ops:is_contract(?a, ?a), Args);
|
||||||
builtin_to_scode(_Env, aens_resolve, [_, _] = _Args) ->
|
builtin_to_scode(Env, aens_resolve, [_Name, _Key, _Type] = Args) ->
|
||||||
?TODO(fate_aens_resolve_instruction);
|
call_to_scode(Env, aeb_fate_ops:aens_resolve(?a, ?a, ?a, ?a), Args);
|
||||||
builtin_to_scode(_Env, aens_preclaim, [_, _, _] = _Args) ->
|
builtin_to_scode(Env, aens_preclaim, [_Sign, _Account, _Hash] = Args) ->
|
||||||
?TODO(fate_aens_preclaim_instruction);
|
call_to_scode(Env, [aeb_fate_ops:aens_preclaim(?a, ?a, ?a),
|
||||||
builtin_to_scode(_Env, aens_claim, [_, _, _, _] = _Args) ->
|
tuple(0)], Args);
|
||||||
?TODO(fate_aens_claim_instruction);
|
builtin_to_scode(Env, aens_claim, [_Sign, _Account, _NameString, _Salt] = Args) ->
|
||||||
builtin_to_scode(_Env, aens_transfer, [_, _, _, _] = _Args) ->
|
call_to_scode(Env, [aeb_fate_ops:aens_claim(?a, ?a, ?a, ?a),
|
||||||
?TODO(fate_aens_transfer_instruction);
|
tuple(0)], Args);
|
||||||
builtin_to_scode(_Env, aens_revoke, [_, _, _] = _Args) ->
|
builtin_to_scode(Env, aens_transfer, [_Sign, _From, _To, _Name] = Args) ->
|
||||||
?TODO(fate_aens_revoke_instruction);
|
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, []) ->
|
builtin_to_scode(_Env, auth_tx_hash, []) ->
|
||||||
[aeb_fate_ops:auth_tx_hash(?a)].
|
[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]);
|
{'LOG4', A, B, C, D, E} -> Impure(none, [A, B, C, D, E]);
|
||||||
'DEACTIVATE' -> Impure(none, []);
|
'DEACTIVATE' -> Impure(none, []);
|
||||||
{'SPEND', A, B} -> Impure(none, [A, B]);
|
{'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_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_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]);
|
{'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_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_GET_QUESTION', A, B, C, D, E}-> Impure(A, [B, C, D, E]);
|
||||||
{'ORACLE_QUERY_FEE', A, B} -> Impure(A, [B]);
|
{'ORACLE_QUERY_FEE', A, B} -> Impure(A, [B]);
|
||||||
'AENS_RESOLVE' -> Impure(?a, []); %% TODO
|
{'AENS_RESOLVE', A, B, C, D} -> Impure(A, [B, C, D]);
|
||||||
'AENS_PRECLAIM' -> Impure(?a, []); %% TODO
|
{'AENS_PRECLAIM', A, B, C} -> Impure(none, [A, B, C]);
|
||||||
'AENS_CLAIM' -> Impure(?a, []); %% TODO
|
{'AENS_CLAIM', A, B, C, D} -> Impure(none, [A, B, C, D]);
|
||||||
'AENS_UPDATE' -> Impure(?a, []); %% TODO
|
'AENS_UPDATE' -> Impure(none, []);%% TODO
|
||||||
'AENS_TRANSFER' -> Impure(?a, []); %% TODO
|
{'AENS_TRANSFER', A, B, C, D} -> Impure(none, [A, B, C, D]);
|
||||||
'AENS_REVOKE' -> Impure(?a, []); %% TODO
|
{'AENS_REVOKE', A, B, C} -> Impure(none, [A, B, C]);
|
||||||
{'ABORT', A} -> Impure(pc, A);
|
{'ABORT', A} -> Impure(pc, A);
|
||||||
{'EXIT', A} -> Impure(pc, A);
|
{'EXIT', A} -> Impure(pc, A);
|
||||||
'NOP' -> Pure(none, [])
|
'NOP' -> Pure(none, [])
|
||||||
|
@ -116,7 +116,8 @@ compilable_contracts() ->
|
|||||||
"bytes_equality",
|
"bytes_equality",
|
||||||
"address_chain",
|
"address_chain",
|
||||||
"namespace_bug",
|
"namespace_bug",
|
||||||
"bytes_to_x"
|
"bytes_to_x",
|
||||||
|
"aens"
|
||||||
].
|
].
|
||||||
|
|
||||||
not_yet_compilable(fate) -> [];
|
not_yet_compilable(fate) -> [];
|
||||||
|
@ -3,53 +3,53 @@ contract AENSTest =
|
|||||||
|
|
||||||
// Name resolution
|
// 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)
|
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)
|
AENS.resolve(name, key)
|
||||||
|
|
||||||
// Transactions
|
// Transactions
|
||||||
|
|
||||||
function preclaim(addr : address, // Claim on behalf of this account (can be Contract.address)
|
stateful function preclaim(addr : address, // Claim on behalf of this account (can be Contract.address)
|
||||||
chash : hash) : () = // Commitment hash
|
chash : hash) : () = // Commitment hash
|
||||||
AENS.preclaim(addr, chash)
|
AENS.preclaim(addr, chash)
|
||||||
|
|
||||||
function signedPreclaim(addr : address, // Claim on behalf of this account (can be Contract.address)
|
stateful function signedPreclaim(addr : address, // Claim on behalf of this account (can be Contract.address)
|
||||||
chash : hash, // Commitment hash
|
chash : hash, // Commitment hash
|
||||||
sign : signature) : () = // Signed by addr (if not Contract.address)
|
sign : signature) : () = // Signed by addr (if not Contract.address)
|
||||||
AENS.preclaim(addr, chash, signature = sign)
|
AENS.preclaim(addr, chash, signature = sign)
|
||||||
|
|
||||||
function claim(addr : address,
|
stateful function claim(addr : address,
|
||||||
name : string,
|
name : string,
|
||||||
salt : int) : () =
|
salt : int) : () =
|
||||||
AENS.claim(addr, name, salt)
|
AENS.claim(addr, name, salt)
|
||||||
|
|
||||||
function signedClaim(addr : address,
|
stateful function signedClaim(addr : address,
|
||||||
name : string,
|
name : string,
|
||||||
salt : int,
|
salt : int,
|
||||||
sign : signature) : () =
|
sign : signature) : () =
|
||||||
AENS.claim(addr, name, salt, signature = sign)
|
AENS.claim(addr, name, salt, signature = sign)
|
||||||
|
|
||||||
// TODO: update() -- how to handle pointers?
|
// TODO: update() -- how to handle pointers?
|
||||||
|
|
||||||
function transfer(owner : address,
|
stateful function transfer(owner : address,
|
||||||
new_owner : address,
|
new_owner : address,
|
||||||
name_hash : hash) : () =
|
name_hash : hash) : () =
|
||||||
AENS.transfer(owner, new_owner, name_hash)
|
AENS.transfer(owner, new_owner, name_hash)
|
||||||
|
|
||||||
function signedTransfer(owner : address,
|
stateful function signedTransfer(owner : address,
|
||||||
new_owner : address,
|
new_owner : address,
|
||||||
name_hash : hash,
|
name_hash : hash,
|
||||||
sign : signature) : () =
|
sign : signature) : () =
|
||||||
AENS.transfer(owner, new_owner, name_hash, signature = sign)
|
AENS.transfer(owner, new_owner, name_hash, signature = sign)
|
||||||
|
|
||||||
function revoke(owner : address,
|
stateful function revoke(owner : address,
|
||||||
name_hash : hash) : () =
|
name_hash : hash) : () =
|
||||||
AENS.revoke(owner, name_hash)
|
AENS.revoke(owner, name_hash)
|
||||||
|
|
||||||
function signedRevoke(owner : address,
|
stateful function signedRevoke(owner : address,
|
||||||
name_hash : hash,
|
name_hash : hash,
|
||||||
sign : signature) : () =
|
sign : signature) : () =
|
||||||
AENS.revoke(owner, name_hash, signature = sign)
|
AENS.revoke(owner, name_hash, signature = sign)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user