forked from TrueCloudLab/frostfs-contract
88c738b736
At initialization contract saves master script hash that allows to re-initialize or migrate contract. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
22 lines
549 B
Go
22 lines
549 B
Go
package common
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
)
|
|
|
|
const OwnerKey = "contractOwner"
|
|
|
|
// HasUpdateAccess returns true if contract can be initialized, re-initialized
|
|
// or migrated.
|
|
func HasUpdateAccess(ctx storage.Context) bool {
|
|
data := storage.Get(ctx, OwnerKey)
|
|
if data == nil { // contract has not been initialized yet, return true
|
|
return true
|
|
}
|
|
|
|
owner := data.(interop.Hash160)
|
|
|
|
return runtime.CheckWitness(owner)
|
|
}
|