Merge pull request #155 from aeternity/PT-158904718-aens-update-sophia
support for AENS.update call
This commit is contained in:
commit
422baa5b65
@ -2,7 +2,7 @@
|
||||
|
||||
{erl_opts, [debug_info]}.
|
||||
|
||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"4f4d6d3"}}}
|
||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref,"38f4f0e"}}}
|
||||
, {getopt, "1.0.1"}
|
||||
, {eblake2, "1.0.0"}
|
||||
, {jsx, {git, "https://github.com/talentdeficit/jsx.git",
|
||||
|
@ -1,7 +1,7 @@
|
||||
{"1.1.0",
|
||||
[{<<"aebytecode">>,
|
||||
{git,"https://github.com/aeternity/aebytecode.git",
|
||||
{ref,"4f4d6d30cd2c46b3830454d650a424d513f69134"}},
|
||||
{ref,"38f4f0ecd75db592f596b9687c37945d4fc807d7"}},
|
||||
0},
|
||||
{<<"aeserialization">>,
|
||||
{git,"https://github.com/aeternity/aeserialization.git",
|
||||
|
@ -389,6 +389,8 @@ global_env() ->
|
||||
Signature = {named_arg_t, Ann, SignId, SignId, {typed, Ann, SignDef, SignId}},
|
||||
SignFun = fun(Ts, T) -> {type_sig, [stateful|Ann], none, [Signature], Ts, T} end,
|
||||
TTL = {qid, Ann, ["Chain", "ttl"]},
|
||||
Pointee = {qid, Ann, ["AENS", "pointee"]},
|
||||
|
||||
Fee = Int,
|
||||
[A, Q, R, K, V] = lists:map(TVar, ["a", "q", "r", "k", "v"]),
|
||||
|
||||
@ -402,6 +404,10 @@ global_env() ->
|
||||
%% TTL constructors
|
||||
{"RelativeTTL", Fun1(Int, TTL)},
|
||||
{"FixedTTL", Fun1(Int, TTL)},
|
||||
%% AENS pointee constructors
|
||||
{"AccountPointee", Fun1(Address, Pointee)},
|
||||
{"OraclePointee", Fun1(Address, Pointee)},
|
||||
{"ContractPointee", Fun1(Address, Pointee)},
|
||||
%% Abort
|
||||
{"abort", Fun1(String, A)},
|
||||
{"require", Fun([Bool, String], Unit)}])
|
||||
@ -462,7 +468,9 @@ global_env() ->
|
||||
{"preclaim", SignFun([Address, Hash], Unit)},
|
||||
{"claim", SignFun([Address, String, Int, Int], Unit)},
|
||||
{"transfer", SignFun([Address, Address, String], Unit)},
|
||||
{"revoke", SignFun([Address, String], Unit)}]) },
|
||||
{"revoke", SignFun([Address, String], Unit)},
|
||||
{"update", SignFun([Address, String, Option(TTL), Option(TTL), Option(Map(String, Pointee))], Unit)}])
|
||||
, types = MkDefs([{"pointee", 0}]) },
|
||||
|
||||
MapScope = #scope
|
||||
{ funs = MkDefs(
|
||||
|
@ -167,7 +167,10 @@ init_env(Options) ->
|
||||
con_env => #{["None"] => #con_tag{ tag = 0, arities = [0, 1] },
|
||||
["Some"] => #con_tag{ tag = 1, arities = [0, 1] },
|
||||
["RelativeTTL"] => #con_tag{ tag = 0, arities = [1, 1] },
|
||||
["FixedTTL"] => #con_tag{ tag = 1, arities = [1, 1] }
|
||||
["FixedTTL"] => #con_tag{ tag = 1, arities = [1, 1] },
|
||||
["AccountPointee"] => #con_tag{ tag = 0, arities = [1, 1, 1] },
|
||||
["OraclePointee"] => #con_tag{ tag = 1, arities = [1, 1, 1] },
|
||||
["ContractPointee"] => #con_tag{ tag = 2, arities = [1, 1, 1] }
|
||||
},
|
||||
options => Options,
|
||||
functions => #{} }.
|
||||
@ -188,7 +191,7 @@ builtins() ->
|
||||
{"respond", 4}, {"extend", 3}, {"get_answer", 2},
|
||||
{"check", 1}, {"check_query", 2}]},
|
||||
{["AENS"], [{"resolve", 2}, {"preclaim", 3}, {"claim", 5}, {"transfer", 4},
|
||||
{"revoke", 3}]},
|
||||
{"revoke", 3}, {"update", 6}]},
|
||||
{["Map"], [{"from_list", 1}, {"to_list", 1}, {"lookup", 2},
|
||||
{"lookup_default", 3}, {"delete", 2}, {"member", 2}, {"size", 1}]},
|
||||
{["Crypto"], [{"verify_sig", 3}, {"verify_sig_secp256k1", 3},
|
||||
@ -225,7 +228,8 @@ init_type_env() ->
|
||||
["list"] => ?type(T, {list, T}),
|
||||
["map"] => ?type(K, V, {map, K, V}),
|
||||
["option"] => ?type(T, {variant, [[], [T]]}),
|
||||
["Chain", "ttl"] => ?type({variant, [[integer], [integer]]})
|
||||
["Chain", "ttl"] => ?type({variant, [[integer], [integer]]}),
|
||||
["AENS", "pointee"] => ?type({variant, [[address], [address], [address]]})
|
||||
}.
|
||||
|
||||
is_no_code(Env) ->
|
||||
|
@ -463,6 +463,7 @@ is_builtin_fun({qid, _, ["AENS", "preclaim"]}, _Icode) ->
|
||||
is_builtin_fun({qid, _, ["AENS", "claim"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["AENS", "transfer"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["AENS", "revoke"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["AENS", "update"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["Map", "lookup"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["Map", "lookup_default"]}, _Icode) -> true;
|
||||
is_builtin_fun({qid, _, ["Map", "member"]}, _Icode) -> true;
|
||||
@ -618,6 +619,12 @@ builtin_code(_, {qid, _, ["AENS", "revoke"]}, Args, _, _, Icode) ->
|
||||
[ast_body(Addr, Icode), ast_body(Name, Icode), ast_body(Sign, Icode)],
|
||||
[word, word, sign_t()], {tuple, []});
|
||||
|
||||
builtin_code(_, {qid, _, ["AENS", "update"]}, Args, _, _, Icode) ->
|
||||
{Sign, [Addr, Name, TTL, ClientTTL, Pointers]} = get_signature_arg(Args),
|
||||
prim_call(?PRIM_CALL_AENS_UPDATE, #integer{value = 0},
|
||||
[ast_body(Addr, Icode), ast_body(Name, Icode), ast_body(TTL, Icode), ast_body(ClientTTL, Icode), ast_body(Pointers, Icode), ast_body(Sign, Icode)],
|
||||
[word, string, word, word, word, sign_t()], {tuple, []});
|
||||
|
||||
%% -- Maps
|
||||
%% -- lookup functions
|
||||
builtin_code(_, {qid, _, ["Map", "lookup"]}, [Key, Map], _, _, Icode) ->
|
||||
@ -926,6 +933,9 @@ ast_typerep1({variant_t, Cons}, Icode) ->
|
||||
ttl_t(Icode) ->
|
||||
ast_typerep({qid, [], ["Chain", "ttl"]}, Icode).
|
||||
|
||||
%% pointee_t(Icode) ->
|
||||
%% ast_typerep({qid, [], ["AENS", "pointee"]}, Icode).
|
||||
|
||||
sign_t() -> bytes_t(64).
|
||||
bytes_t(Len) when Len =< 32 -> word;
|
||||
bytes_t(Len) -> {tuple, lists:duplicate((31 + Len) div 32, word)}.
|
||||
|
@ -572,6 +572,9 @@ builtin_to_scode(Env, aens_transfer, [_Sign, _From, _To, _Name] = 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, aens_update, [_Sign, _Account, _NameString, _TTL, _ClientTTL, _Pointers] = Args) ->
|
||||
call_to_scode(Env, [aeb_fate_ops:aens_update(?a, ?a, ?a, ?a, ?a, ?a),
|
||||
tuple(0)], Args);
|
||||
builtin_to_scode(_Env, auth_tx_hash, []) ->
|
||||
[aeb_fate_ops:auth_tx_hash(?a)].
|
||||
|
||||
@ -896,7 +899,7 @@ attributes(I) ->
|
||||
{'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, E} -> Impure(none, [A, B, C, D, E]);
|
||||
'AENS_UPDATE' -> Impure(none, []);%% TODO
|
||||
{'AENS_UPDATE', A, B, C, D, E, F} -> Impure(none, [A, B, C, D, E, F]);
|
||||
{'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);
|
||||
|
@ -88,13 +88,18 @@ builtin_types() ->
|
||||
, "option" => fun([A]) -> {variant, [[], [A]]} end
|
||||
, "map" => fun([K, V]) -> map_typerep(K, V) end
|
||||
, ["Chain", "ttl"] => fun([]) -> {variant, [[word], [word]]} end
|
||||
, ["AENS", "pointee"] => fun([]) -> {variant, [[word], [word], [word]]} end
|
||||
}.
|
||||
|
||||
builtin_constructors() ->
|
||||
#{ ["RelativeTTL"] => 0
|
||||
, ["FixedTTL"] => 1
|
||||
, ["None"] => 0
|
||||
, ["Some"] => 1 }.
|
||||
, ["Some"] => 1
|
||||
, ["AccountPointee"] => 0
|
||||
, ["OraclePointee"] => 1
|
||||
, ["ContractPointee"] => 2
|
||||
}.
|
||||
|
||||
map_typerep(K, V) ->
|
||||
{map, K, V}.
|
||||
@ -146,4 +151,3 @@ get_constructor_tag(Name, #{constructors := Constructors}) ->
|
||||
undefined -> error({undefined_constructor, Name});
|
||||
Tag -> Tag
|
||||
end.
|
||||
|
||||
|
@ -33,7 +33,22 @@ contract AENSTest =
|
||||
sign : signature) : unit =
|
||||
AENS.claim(addr, name, salt, name_fee, signature = sign)
|
||||
|
||||
// TODO: update() -- how to handle pointers?
|
||||
|
||||
stateful entrypoint update(owner : address,
|
||||
name : string,
|
||||
ttl : option(Chain.ttl),
|
||||
client_ttl : option(Chain.ttl),
|
||||
pointers : option(map(string, AENS.pointee))) : unit =
|
||||
AENS.update(owner, name, ttl, client_ttl, pointers)
|
||||
|
||||
stateful entrypoint signedUpdate(owner : address,
|
||||
name : string,
|
||||
ttl : option(Chain.ttl),
|
||||
client_ttl : option(Chain.ttl),
|
||||
pointers : option(map(string, AENS.pointee)),
|
||||
sign : signature) : unit =
|
||||
AENS.update(owner, name, ttl, client_ttl, pointers, signature = sign)
|
||||
|
||||
|
||||
stateful entrypoint transfer(owner : address,
|
||||
new_owner : address,
|
||||
|
Loading…
x
Reference in New Issue
Block a user