diff --git a/contracts/nns/config.yml b/contracts/nns/config.yml index 87353939..2c156972 100644 --- a/contracts/nns/config.yml +++ b/contracts/nns/config.yml @@ -14,6 +14,14 @@ events: type: Integer - name: tokenId type: ByteArray + - name: SetAdmin + parameters: + - name: name + type: String + - name: oldAdmin + type: Hash160 + - name: newAdmin + type: Hash160 permissions: - hash: fffdc93764dbaddd97c48f252a53ea4643faa3fd methods: ["update"] diff --git a/contracts/nns/contract.go b/contracts/nns/contract.go index 9b0aea44..a32dbb9b 100644 --- a/contracts/nns/contract.go +++ b/contracts/nns/contract.go @@ -522,8 +522,10 @@ func SetAdmin(name string, admin interop.Hash160) { ctx := storage.GetContext() ns := getFragmentedNameState(ctx, []byte(name), fragments) common.CheckOwnerWitness(ns.Owner) + oldAdm := ns.Admin ns.Admin = admin putNameState(ctx, ns) + runtime.Notify("SetAdmin", name, oldAdm, admin) } // SetRecord updates existing domain record with the specified type and ID. diff --git a/tests/nns_test.go b/tests/nns_test.go index ec197035..f3fa3314 100644 --- a/tests/nns_test.go +++ b/tests/nns_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/nspcc-dev/neo-go/pkg/core/interop/storage" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/neotest" "github.com/nspcc-dev/neo-go/pkg/util" @@ -354,7 +355,16 @@ func TestNNSSetAdmin(t *testing.T) { "testdomain.com", int64(recordtype.TXT), "won't be added") c1 := c.WithSigners(c.Committee, acc) - c1.Invoke(t, stackitem.Null{}, "setAdmin", "testdomain.com", acc.ScriptHash()) + h := c1.Invoke(t, stackitem.Null{}, "setAdmin", "testdomain.com", acc.ScriptHash()) + c1.CheckTxNotificationEvent(t, h, 0, state.NotificationEvent{ + ScriptHash: c1.Hash, + Name: "SetAdmin", + Item: stackitem.NewArray([]stackitem.Item{ + stackitem.NewByteArray([]byte("testdomain.com")), + stackitem.Null{}, + stackitem.NewByteArray(acc.ScriptHash().BytesBE()), + }), + }) expiration := top.Timestamp + uint64(expire*1000) expectedProps := stackitem.NewMapWithValue([]stackitem.MapElement{