Skip to content

Commit

Permalink
NameService: require admin signature for subdomain registration
Browse files Browse the repository at this point in the history
Originally implemented in
nspcc-dev/neofs-contract@14fc086.
  • Loading branch information
AnnaShaleva committed Sep 9, 2022
1 parent b5f7a16 commit cc580f9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/NameService/NameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ public static bool Register(string name, UInt160 owner)
string[] fragments = SplitAndCheck(name, false);
if (fragments is null) throw new FormatException("The format of the name is incorrect.");
if (rootMap[fragments[^1]] is null) throw new Exception("The root does not exist.");
ByteString parentKey = GetKey(fragments[1]);
ByteString parentBuffer = nameMap[parentKey];
if (parentBuffer is null) throw new InvalidOperationException("Unknown parent domain.");
NameState parent = (NameState)StdLib.Deserialize(parentBuffer);
parent.CheckAdmin();
if (!Runtime.CheckWitness(owner)) throw new InvalidOperationException("No authorization.");
long price = GetPrice((byte)fragments[0].Length);
if (price < 0)
Expand Down

0 comments on commit cc580f9

Please sign in to comment.