From af21f33657344dcd23a4367e7ef129a670aee1ad Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 30 Jun 2021 13:59:32 +0300 Subject: [PATCH] [#100] *: Use full scope in migration As soon as migration required changes in memory, we need bigger scope. Otherwise in requires two step migration which is unpleasant and annoying. Signed-off-by: Alex Vanin --- alphabet/alphabet_contract.go | 2 +- audit/audit_contract.go | 3 ++- balance/balance_contract.go | 3 ++- neofs/neofs_contract.go | 4 ++-- neofsid/neofsid_contract.go | 3 ++- netmap/netmap_contract.go | 2 +- processing/processing_contract.go | 2 +- proxy/proxy_contract.go | 3 ++- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/alphabet/alphabet_contract.go b/alphabet/alphabet_contract.go index c0fe9a4..e4bf04c 100644 --- a/alphabet/alphabet_contract.go +++ b/alphabet/alphabet_contract.go @@ -82,7 +82,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("alphabet contract updated") return true diff --git a/audit/audit_contract.go b/audit/audit_contract.go index 6a243d4..55247f9 100644 --- a/audit/audit_contract.go +++ b/audit/audit_contract.go @@ -2,6 +2,7 @@ package auditcontract import ( "github.com/nspcc-dev/neo-go/pkg/interop" + "github.com/nspcc-dev/neo-go/pkg/interop/contract" "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/management" @@ -82,7 +83,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("audit contract updated") return true diff --git a/balance/balance_contract.go b/balance/balance_contract.go index 82360fd..3f93e3f 100644 --- a/balance/balance_contract.go +++ b/balance/balance_contract.go @@ -2,6 +2,7 @@ package balancecontract import ( "github.com/nspcc-dev/neo-go/pkg/interop" + "github.com/nspcc-dev/neo-go/pkg/interop/contract" "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/std" @@ -101,7 +102,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("balance contract updated") return true diff --git a/neofs/neofs_contract.go b/neofs/neofs_contract.go index 9898a7f..bcbacd6 100644 --- a/neofs/neofs_contract.go +++ b/neofs/neofs_contract.go @@ -65,7 +65,7 @@ const ( publicKeySize = 33 - maxBalanceAmount = 9000 // Max integer of Fixed12 in JSON bound (2**53-1) + maxBalanceAmount = 9000 // Max integer of Fixed12 in JSON bound (2**53-1) maxBalanceAmountGAS = maxBalanceAmount * 1_0000_0000 // hardcoded value to ignore deposit notification in onReceive @@ -138,7 +138,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("neofs contract updated") return true diff --git a/neofsid/neofsid_contract.go b/neofsid/neofsid_contract.go index b4de65a..4aa0fa7 100644 --- a/neofsid/neofsid_contract.go +++ b/neofsid/neofsid_contract.go @@ -2,6 +2,7 @@ package neofsidcontract import ( "github.com/nspcc-dev/neo-go/pkg/interop" + "github.com/nspcc-dev/neo-go/pkg/interop/contract" "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/std" @@ -67,7 +68,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("neofsid contract updated") return true diff --git a/netmap/netmap_contract.go b/netmap/netmap_contract.go index 006fb53..4b8cf36 100644 --- a/netmap/netmap_contract.go +++ b/netmap/netmap_contract.go @@ -120,7 +120,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("netmap contract updated") return true diff --git a/processing/processing_contract.go b/processing/processing_contract.go index 3bb856a..7cd14a9 100644 --- a/processing/processing_contract.go +++ b/processing/processing_contract.go @@ -58,7 +58,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("processing contract updated") return true diff --git a/proxy/proxy_contract.go b/proxy/proxy_contract.go index ffc8a2b..0ed1c50 100644 --- a/proxy/proxy_contract.go +++ b/proxy/proxy_contract.go @@ -2,6 +2,7 @@ package proxycontract import ( "github.com/nspcc-dev/neo-go/pkg/interop" + "github.com/nspcc-dev/neo-go/pkg/interop/contract" "github.com/nspcc-dev/neo-go/pkg/interop/native/gas" "github.com/nspcc-dev/neo-go/pkg/interop/native/management" "github.com/nspcc-dev/neo-go/pkg/interop/native/neo" @@ -56,7 +57,7 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool { return false } - management.UpdateWithData(script, manifest, data) + contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data) runtime.Log("proxy contract updated") return true