diff --git a/src/NameService/NameService.cs b/src/NameService/NameService.cs index 5f18e9c..869cf3c 100644 --- a/src/NameService/NameService.cs +++ b/src/NameService/NameService.cs @@ -21,11 +21,14 @@ 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); + public delegate void OnRenewDelegate(string name, BigInteger oldExpiration, BigInteger newExpiration); [DisplayName("Transfer")] public static event OnTransferDelegate OnTransfer; [DisplayName("SetAdmin")] public static event OnSetAdminDelegate OnSetAdmin; + [DisplayName("Renew")] + public static event OnRenewDelegate OnRenew; private const byte Prefix_TotalSupply = 0x00; private const byte Prefix_Balance = 0x01; @@ -324,11 +327,13 @@ public static ulong Renew(string name, byte years) Runtime.BurnGas(price * years); StorageMap nameMap = new(Storage.CurrentContext, Prefix_Name); NameState token = getNameState(nameMap, name); + ulong oldExpiration = token.Expiration; token.Expiration += OneYear * years; if (token.Expiration > Runtime.Time + TenYears) throw new ArgumentException("You can't renew a domain name for more than 10 years in total."); ByteString tokenKey = GetKey(name); nameMap[tokenKey] = StdLib.Serialize(token); + OnRenew(name, oldExpiration, token.Expiration); return token.Expiration; }