From d8e42fcd16077a7449ff447dcde986c13ba66ea0 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 23 Nov 2021 12:18:34 +0300 Subject: [PATCH] nns: migrate roots from the old version Now root is just a TLD and needs to have SOA record. Set owner to committee and some default values for other parameters. Signed-off-by: Evgenii Stratonikov --- nns/nns_contract.go | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 33e8031..8daad18 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -90,33 +90,24 @@ func Update(nef []byte, manifest string) { func _deploy(data interface{}, isUpdate bool) { if isUpdate { ctx := storage.GetContext() - it := storage.Find(ctx, []byte{prefixRecord}, storage.DeserializeValues) + committee := common.CommitteeAddress() + it := storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix) for iterator.Next(it) { - oldRec := iterator.Value(it).(struct { - key string - rec RecordState - }) - newRec := RecordState{ - Name: oldRec.rec.Name, - Type: oldRec.rec.Type, - Data: oldRec.rec.Data, - ID: 0, + name := iterator.Value(it).(string) + ns := NameState{ + Owner: committee, + Name: name, + Expiration: runtime.GetTime() + millisecondsInYear, } - newKey := append([]byte(oldRec.key), newRec.ID) - rec := std.Serialize(newRec) - storage.Put(ctx, newKey, rec) - storage.Delete(ctx, oldRec.key) + tokenKey := getTokenKey([]byte(name)) + putNameStateWithKey(ctx, tokenKey, ns) + putSoaRecord(ctx, name, "ops@nspcc.ru", + 3600 /* 1 hour */, 600, /* 10 min */ + 604800 /* 1 week */, 3600 /* 1 hour */) } - - maxExpire := 1<<31 - 1 - domains := storage.Find(ctx, []byte{prefixName}, storage.ValuesOnly|storage.DeserializeValues) - for iterator.Next(domains) { - ns := iterator.Value(domains).(NameState) - putSoaRecord(ctx, ns.Name, "ops@nspcc.ru", 86400, 7200, maxExpire, 3600) - } - return } + ctx := storage.GetContext() storage.Put(ctx, []byte{prefixTotalSupply}, 0) storage.Put(ctx, []byte{prefixRegisterPrice}, defaultRegisterPrice)