Compare commits

...

1 commit

Author SHA1 Message Date
Alex Vanin
72571349a8 Enable notary and remove all ballots
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-14 12:10:17 +03:00
8 changed files with 30 additions and 39 deletions

View file

@ -34,6 +34,13 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
if isUpdate { if isUpdate {
ctx := storage.GetContext()
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
proxyContract := data.([]interface{})[0] // better to hardcode it
storage.Put(ctx, proxyKey, proxyContract)
return return
} }

View file

@ -44,6 +44,10 @@ const (
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
if isUpdate { if isUpdate {
ctx := storage.GetContext()
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
return return
} }

View file

@ -60,6 +60,10 @@ func init() {
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
if isUpdate { if isUpdate {
ctx := storage.GetContext()
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
return return
} }

View file

@ -94,6 +94,9 @@ func _deploy(data interface{}, isUpdate bool) {
}) })
if isUpdate { if isUpdate {
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
return return
} }

View file

@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/interop/iterator" "github.com/nspcc-dev/neo-go/pkg/interop/iterator"
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto" "github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
"github.com/nspcc-dev/neo-go/pkg/interop/native/management" "github.com/nspcc-dev/neo-go/pkg/interop/native/management"
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime" "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/storage" "github.com/nspcc-dev/neo-go/pkg/interop/storage"
"github.com/nspcc-dev/neofs-contract/common" "github.com/nspcc-dev/neofs-contract/common"
@ -33,19 +32,9 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
if isUpdate { if isUpdate {
it := storage.Find(ctx, []byte{}, storage.None) storage.Delete(ctx, "ballots")
for iterator.Next(it) { storage.Put(ctx, notaryDisabledKey, false)
kv := iterator.Value(it).([][]byte)
// V2 format
if len(kv[0]) == ownerSize {
info := std.Deserialize(kv[1]).(UserInfo)
key := append([]byte{ownerKeysPrefix}, kv[0]...)
for i := range info.Keys {
storage.Put(ctx, append(key, info.Keys[i]...), []byte{1})
}
storage.Delete(ctx, kv[0])
}
}
return return
} }

View file

@ -83,6 +83,9 @@ func _deploy(data interface{}, isUpdate bool) {
} }
if isUpdate { if isUpdate {
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
return return
} }

View file

@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/interop/convert" "github.com/nspcc-dev/neo-go/pkg/interop/convert"
"github.com/nspcc-dev/neo-go/pkg/interop/iterator" "github.com/nspcc-dev/neo-go/pkg/interop/iterator"
"github.com/nspcc-dev/neo-go/pkg/interop/native/management" "github.com/nspcc-dev/neo-go/pkg/interop/native/management"
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime" "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/storage" "github.com/nspcc-dev/neo-go/pkg/interop/storage"
"github.com/nspcc-dev/neofs-contract/common" "github.com/nspcc-dev/neofs-contract/common"
@ -22,31 +21,9 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
if isUpdate { if isUpdate {
// Storage migration. storage.Delete(ctx, "ballots")
storage.Delete(ctx, []byte("contractOwner")) storage.Put(ctx, notaryDisabledKey, false)
it := storage.Find(ctx, []byte{}, storage.None)
for iterator.Next(it) {
kv := iterator.Value(it).([][]byte)
if string(kv[0]) == notaryDisabledKey {
continue
}
if string(kv[0]) == "ballots" {
continue
}
storage.Delete(ctx, kv[0])
rawValues := std.Deserialize(kv[1]).([][]byte)
key := getReputationKey(reputationCountPrefix, kv[0])
storage.Put(ctx, key, len(rawValues))
key[0] = reputationValuePrefix
for i := range rawValues {
newKey := append(key, convert.ToBytes(i)...)
storage.Put(ctx, newKey, rawValues[i])
}
}
return return
} }

View file

@ -58,6 +58,10 @@ const (
// _deploy function sets up initial list of inner ring public keys. // _deploy function sets up initial list of inner ring public keys.
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
if isUpdate { if isUpdate {
ctx := storage.GetContext()
storage.Delete(ctx, "ballots")
storage.Put(ctx, notaryDisabledKey, false)
return return
} }