forked from TrueCloudLab/frostfs-contract
[#49] Support contract migration
At initialization contract saves master script hash that allows to re-initialize or migrate contract. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
a4a9a49a76
commit
88c738b736
11 changed files with 186 additions and 28 deletions
22
common/update.go
Normal file
22
common/update.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue