Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event: SetAdmin #11

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/NameService/NameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ namespace Neo.SmartContract
public sealed class NameService : Framework.SmartContract
{
public delegate void OnTransferDelegate(UInt160 from, UInt160 to, BigInteger amount, ByteString tokenId);
public delegate void OnSetAdminDelegate(string name, UInt160 oldAdmin, UInt160 newAdmin);

[DisplayName("Transfer")]
public static event OnTransferDelegate OnTransfer;
[DisplayName("SetAdmin")]
public static event OnSetAdminDelegate OnSetAdmin;

private const byte Prefix_TotalSupply = 0x00;
private const byte Prefix_Balance = 0x01;
Expand Down Expand Up @@ -274,8 +277,10 @@ public static void SetAdmin(string name, UInt160 admin)
NameState token = (NameState)StdLib.Deserialize(nameMap[tokenKey]);
token.EnsureNotExpired();
if (!Runtime.CheckWitness(token.Owner)) throw new InvalidOperationException("No authorization.");
UInt160 old = token.Admin;
token.Admin = admin;
nameMap[tokenKey] = StdLib.Serialize(token);
OnSetAdmin(name, old, admin);
}

public static void SetRecord(string name, RecordType type, string data)
Expand Down