2021-07-22 09:46:38 +00:00
|
|
|
package nns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NameState represents domain name state.
|
|
|
|
type NameState struct {
|
|
|
|
Owner interop.Hash160
|
|
|
|
Name string
|
2022-07-06 09:22:43 +00:00
|
|
|
Expiration int64
|
2021-07-22 09:46:38 +00:00
|
|
|
Admin interop.Hash160
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensureNotExpired panics if domain name is expired.
|
|
|
|
func (n NameState) ensureNotExpired() {
|
2022-07-06 09:22:43 +00:00
|
|
|
if int64(runtime.GetTime()) >= n.Expiration {
|
2021-07-22 09:46:38 +00:00
|
|
|
panic("name has expired")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// checkAdmin panics if script container is not signed by the domain name admin.
|
|
|
|
func (n NameState) checkAdmin() {
|
|
|
|
if runtime.CheckWitness(n.Owner) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if n.Admin == nil || !runtime.CheckWitness(n.Admin) {
|
|
|
|
panic("not witnessed by admin")
|
|
|
|
}
|
|
|
|
}
|