-
Notifications
You must be signed in to change notification settings - Fork 22
/
AensDelegation.aes
56 lines (44 loc) · 2.26 KB
/
AensDelegation.aes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@compiler >= 6
include "Option.aes"
contract AensDelegation =
stateful entrypoint pre_claim(owner: address, commitment_hash: hash, sig: signature) =
AENS.preclaim(owner, commitment_hash, signature = sig)
stateful entrypoint claim(owner: address, name : string, salt: int, name_fee: int, sig: signature) =
AENS.claim(owner, name, salt, name_fee, signature = sig)
stateful entrypoint extend(addr: address, name: string, sig: signature, ttl: option(Chain.ttl)) =
switch(AENS.lookup(name))
None => ()
Some(AENS.Name(_, _, _)) =>
AENS.update(addr, name, Some(Option.default(RelativeTTL(180000), ttl)), None, None, signature = sig)
stateful entrypoint add_key(addr: address, name: string, key: string,
pt : AENS.pointee, sig : signature) =
switch(AENS.lookup(name))
None => ()
Some(AENS.Name(_, _, ptrs)) =>
AENS.update(addr, name, None, None, Some(ptrs{[key] = pt}), signature = sig)
stateful entrypoint delete_key(addr: address, name: string, key: string, sig: signature) =
switch(AENS.lookup(name))
None => ()
Some(AENS.Name(_, _, ptrs)) =>
let ptrs = Map.delete(key, ptrs)
AENS.update(addr, name, None, None, Some(ptrs), signature = sig)
stateful entrypoint transfer(owner: address, new_owner: address, name: string, sig: signature) =
switch(AENS.lookup(name))
None => ()
Some(AENS.Name(_, _, _)) =>
AENS.transfer(owner, new_owner, name, signature = sig)
stateful entrypoint revoke(addr: address, name: string, sig: signature) =
switch(AENS.lookup(name))
None => ()
Some(AENS.Name(_, _, _)) =>
AENS.revoke(addr, name, signature = sig)
entrypoint get_name(name : string) : option(AENS.name) =
AENS.lookup(name)
entrypoint get_owner(name: string): option(address) =
switch(AENS.lookup(name))
None => None
Some(AENS.Name(owner, _, _)) => Some(owner)
entrypoint get_pointers(name : string) : map(string, AENS.pointee) =
switch(AENS.lookup(name))
None => {}
Some(AENS.Name(_, _, ptrs)) => ptrs