From cc580f9bc66730d0040e90b4282c666e214c0983 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 2 Sep 2022 12:14:51 +0300 Subject: [PATCH] NameService: require admin signature for subdomain registration Originally implemented in https://github.com/nspcc-dev/neofs-contract/pull/139/commits/14fc08629180e9d53d7efe431fb20b245c6ecf78. --- src/NameService/NameService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NameService/NameService.cs b/src/NameService/NameService.cs index 07d6c66..3dbbf51 100644 --- a/src/NameService/NameService.cs +++ b/src/NameService/NameService.cs @@ -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)