[#164] *: provide version as the last argument
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
99c81fe26a
commit
da7f7eb88f
12 changed files with 60 additions and 13 deletions
|
@ -74,7 +74,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("alphabet contract updated")
|
runtime.Log("alphabet contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("audit contract updated")
|
runtime.Log("audit contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("balance contract updated")
|
runtime.Log("balance contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,46 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
|
import "github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
major = 0
|
major = 0
|
||||||
minor = 12
|
minor = 13
|
||||||
patch = 1
|
patch = 0
|
||||||
|
|
||||||
|
// Versions from which an update should be performed.
|
||||||
|
// These should be used in a group (so prevMinor can be equal to minor if there are
|
||||||
|
// any migration routines.
|
||||||
|
prevMajor = 0
|
||||||
|
prevMinor = 12
|
||||||
|
prevPatch = 0
|
||||||
|
|
||||||
Version = major*1_000_000 + minor*1_000 + patch
|
Version = major*1_000_000 + minor*1_000 + patch
|
||||||
|
|
||||||
|
PrevVersion = prevMajor*1_000_000 + prevMinor*1_000 + prevPatch
|
||||||
|
|
||||||
|
// ErrVersionMismatch is thrown by CheckVersion in case of error.
|
||||||
|
ErrVersionMismatch = "previous version mismatch"
|
||||||
|
|
||||||
|
// ErrAlreadyUpdated is thrown by CheckVersion if current version equals to version contract
|
||||||
|
// is being updated from.
|
||||||
|
ErrAlreadyUpdated = "contract is already of the latest version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CheckVersion checks that previous version is more than PrevVersion to ensure migrating contract data
|
||||||
|
// was done successfully.
|
||||||
|
func CheckVersion(from int) {
|
||||||
|
if from < PrevVersion {
|
||||||
|
panic(ErrVersionMismatch + ": expected >=" + std.Itoa(PrevVersion, 10))
|
||||||
|
}
|
||||||
|
if from == Version {
|
||||||
|
panic(ErrAlreadyUpdated + ": " + std.Itoa(Version, 10))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendVersion appends current contract version to the list of deploy arguments.
|
||||||
|
func AppendVersion(data interface{}) []interface{} {
|
||||||
|
if data == nil {
|
||||||
|
return []interface{}{Version}
|
||||||
|
}
|
||||||
|
return append(data.([]interface{}), Version)
|
||||||
|
}
|
||||||
|
|
|
@ -141,7 +141,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("container contract updated")
|
runtime.Log("container contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only side chain committee can update contract")
|
panic("only side chain committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("neofs contract updated")
|
runtime.Log("neofs contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("neofsid contract updated")
|
runtime.Log("neofsid contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("netmap contract updated")
|
runtime.Log("netmap contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ func Update(nef []byte, manifest string) {
|
||||||
// thus we provide `AllowCall` to management.Update.
|
// thus we provide `AllowCall` to management.Update.
|
||||||
// management.Update(nef, []byte(manifest))
|
// management.Update(nef, []byte(manifest))
|
||||||
contract.Call(interop.Hash160(management.Hash), "update",
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
contract.All, nef, manifest)
|
contract.All, nef, manifest, common.AppendVersion(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
||||||
|
|
|
@ -56,7 +56,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only side chain committee can update contract")
|
panic("only side chain committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("processing contract updated")
|
runtime.Log("processing contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("proxy contract updated")
|
runtime.Log("proxy contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
panic("only committee can update contract")
|
panic("only committee can update contract")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update",
|
||||||
|
contract.All, script, manifest, common.AppendVersion(data))
|
||||||
runtime.Log("reputation contract updated")
|
runtime.Log("reputation contract updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue