[#204] *: check contract version during update
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
8226bd4e43
commit
74cc2d0aea
12 changed files with 29 additions and 2 deletions
|
@ -35,6 +35,8 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
|||
func _deploy(data interface{}, isUpdate bool) {
|
||||
ctx := storage.GetContext()
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ const (
|
|||
func _deploy(data interface{}, isUpdate bool) {
|
||||
ctx := storage.GetContext()
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ func init() {
|
|||
func _deploy(data interface{}, isUpdate bool) {
|
||||
ctx := storage.GetContext()
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) {
|
|||
func _deploy(data interface{}, isUpdate bool) {
|
||||
ctx := storage.GetContext()
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ var (
|
|||
// _deploy sets up initial alphabet node keys.
|
||||
func _deploy(data interface{}, isUpdate bool) {
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
|
||||
ctx := storage.GetContext()
|
||||
nodes := getNodes(ctx, candidatesKey)
|
||||
storage.Delete(ctx, candidatesKey)
|
||||
|
|
|
@ -32,6 +32,8 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
ctx := storage.GetContext()
|
||||
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
addrContainer interop.Hash160
|
||||
keys []interop.PublicKey
|
||||
config [][]byte
|
||||
version int
|
||||
})
|
||||
|
||||
ln := len(args.config)
|
||||
|
@ -83,6 +84,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
}
|
||||
|
||||
if isUpdate {
|
||||
common.CheckVersion(args.version)
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ func Update(nef []byte, manifest string, data interface{}) {
|
|||
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
||||
func _deploy(data interface{}, isUpdate bool) {
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
|
||||
ctx := storage.GetContext()
|
||||
committee := common.CommitteeAddress()
|
||||
it := storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix)
|
||||
|
|
|
@ -28,6 +28,8 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
|||
|
||||
func _deploy(data interface{}, isUpdate bool) {
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,11 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func _deploy(_ interface{}, isUpdate bool) {
|
||||
ctx := storage.GetContext()
|
||||
func _deploy(data interface{}, isUpdate bool) {
|
||||
if isUpdate {
|
||||
ctx := storage.GetContext()
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
storage.Delete(ctx, common.LegacyOwnerKey)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
ctx := storage.GetContext()
|
||||
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
|
||||
// Storage migration.
|
||||
storage.Delete(ctx, []byte("contractOwner"))
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ const (
|
|||
// _deploy function sets up initial list of inner ring public keys.
|
||||
func _deploy(data interface{}, isUpdate bool) {
|
||||
if isUpdate {
|
||||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue