[#107] Remove contract owner argument at contract deploy
Contract owner entity does exist anymore. Contract migration now managed by side chain committee which are Alphabet nodes of the Inner Ring. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
378e69c015
commit
6d0c5d110c
10 changed files with 62 additions and 134 deletions
|
@ -39,24 +39,18 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrNetmap := args[1].(interop.Hash160)
|
||||||
addrNetmap := args[2].(interop.Hash160)
|
addrProxy := args[2].(interop.Hash160)
|
||||||
addrProxy := args[3].(interop.Hash160)
|
name := args[3].(string)
|
||||||
name := args[4].(string)
|
index := args[4].(int)
|
||||||
index := args[5].(int)
|
total := args[5].(int)
|
||||||
total := args[6].(int)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || !notaryDisabled && len(addrProxy) != 20 {
|
if len(addrNetmap) != 20 || !notaryDisabled && len(addrProxy) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapKey, addrNetmap)
|
storage.Put(ctx, netmapKey, addrNetmap)
|
||||||
storage.Put(ctx, proxyKey, addrProxy)
|
storage.Put(ctx, proxyKey, addrProxy)
|
||||||
storage.Put(ctx, nameKey, name)
|
storage.Put(ctx, nameKey, name)
|
||||||
|
@ -74,12 +68,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -48,20 +48,14 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrNetmap := args[1].(interop.Hash160)
|
||||||
addrNetmap := args[2].(interop.Hash160)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 {
|
if len(addrNetmap) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
|
@ -74,12 +68,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
@ -186,7 +178,6 @@ func list(it iterator.Iterator) [][]byte {
|
||||||
|
|
||||||
ignore := [][]byte{
|
ignore := [][]byte{
|
||||||
[]byte(netmapContractKey),
|
[]byte(netmapContractKey),
|
||||||
[]byte(common.OwnerKey),
|
|
||||||
[]byte(notaryDisabledKey),
|
[]byte(notaryDisabledKey),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,21 +65,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrNetmap := args[1].(interop.Hash160)
|
||||||
addrNetmap := args[2].(interop.Hash160)
|
addrContainer := args[2].(interop.Hash160)
|
||||||
addrContainer := args[3].(interop.Hash160)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
storage.Put(ctx, containerContractKey, addrContainer)
|
||||||
|
|
||||||
|
@ -94,12 +88,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -70,20 +70,14 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrNetmap := args[1].(interop.Hash160)
|
||||||
addrNetmap := args[2].(interop.Hash160)
|
addrBalance := args[2].(interop.Hash160)
|
||||||
addrBalance := args[3].(interop.Hash160)
|
addrID := args[3].(interop.Hash160)
|
||||||
addrID := args[4].(interop.Hash160)
|
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrBalance) != 20 || len(addrID) != 20 {
|
if len(addrNetmap) != 20 || len(addrBalance) != 20 || len(addrID) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
storage.Put(ctx, balanceContractKey, addrBalance)
|
storage.Put(ctx, balanceContractKey, addrBalance)
|
||||||
storage.Put(ctx, neofsIDContractKey, addrID)
|
storage.Put(ctx, neofsIDContractKey, addrID)
|
||||||
|
@ -99,12 +93,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -6,7 +6,9 @@ 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/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
"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/roles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
"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"
|
||||||
|
@ -51,17 +53,12 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrProc := args[1].(interop.Hash160)
|
||||||
addrProc := args[2].(interop.Hash160)
|
keys := args[2].([]interop.PublicKey)
|
||||||
keys := args[3].([]interop.PublicKey)
|
config := args[3].([][]byte)
|
||||||
config := args[4].([][]byte)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
var irList []common.IRNode
|
var irList []common.IRNode
|
||||||
|
|
||||||
if len(keys) == 0 {
|
if len(keys) == 0 {
|
||||||
|
@ -84,7 +81,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
common.SetSerialized(ctx, alphabetKey, irList)
|
common.SetSerialized(ctx, alphabetKey, irList)
|
||||||
common.SetSerialized(ctx, candidatesKey, []common.IRNode{})
|
common.SetSerialized(ctx, candidatesKey, []common.IRNode{})
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, processingContractKey, addrProc)
|
storage.Put(ctx, processingContractKey, addrProc)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
|
@ -110,12 +106,14 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by side chain committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
blockHeight := ledger.CurrentIndex()
|
||||||
|
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight))
|
||||||
|
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !runtime.CheckWitness(alphabetCommittee) {
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -30,21 +30,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrNetmap := args[1].(interop.Hash160)
|
||||||
addrNetmap := args[2].(interop.Hash160)
|
addrContainer := args[2].(interop.Hash160)
|
||||||
addrContainer := args[3].(interop.Hash160)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
storage.Put(ctx, containerContractKey, addrContainer)
|
||||||
|
|
||||||
|
@ -59,12 +53,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -67,22 +67,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
addrBalance := args[1].(interop.Hash160)
|
||||||
addrBalance := args[2].(interop.Hash160)
|
addrContainer := args[2].(interop.Hash160)
|
||||||
addrContainer := args[3].(interop.Hash160)
|
keys := args[3].([]interop.PublicKey)
|
||||||
keys := args[4].([]interop.PublicKey)
|
config := args[4].([][]byte)
|
||||||
config := args[5].([][]byte)
|
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrBalance) != 20 || len(addrContainer) != 20 {
|
if len(addrBalance) != 20 || len(addrContainer) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
|
|
||||||
// epoch number is a little endian int, it doesn't need to be serialized
|
// epoch number is a little endian int, it doesn't need to be serialized
|
||||||
storage.Put(ctx, snapshotEpoch, 0)
|
storage.Put(ctx, snapshotEpoch, 0)
|
||||||
storage.Put(ctx, snapshotBlockKey, 0)
|
storage.Put(ctx, snapshotBlockKey, 0)
|
||||||
|
@ -124,12 +117,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -4,7 +4,9 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"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/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
"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/roles"
|
||||||
"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"
|
||||||
|
@ -30,32 +32,28 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
arr := data.([]interop.Hash160)
|
arr := data.([]interop.Hash160)
|
||||||
owner := arr[0]
|
addrNeoFS := arr[0]
|
||||||
addrNeoFS := arr[1]
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNeoFS) != 20 {
|
if len(addrNeoFS) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, neofsContractKey, addrNeoFS)
|
storage.Put(ctx, neofsContractKey, addrNeoFS)
|
||||||
|
|
||||||
runtime.Log("processing contract initialized")
|
runtime.Log("processing contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by side chain committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
blockHeight := ledger.CurrentIndex()
|
||||||
|
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight))
|
||||||
|
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !runtime.CheckWitness(alphabetCommittee) {
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -29,32 +29,24 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
owner := args[0].(interop.Hash160)
|
addrNetmap := args[0].(interop.Hash160)
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(addrNetmap) != 20 {
|
if len(addrNetmap) != 20 {
|
||||||
panic("init: incorrect length of contract script hash")
|
panic("init: incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
|
|
||||||
runtime.Log("proxy contract initialized")
|
runtime.Log("proxy contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
|
|
@ -22,16 +22,9 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.([]interface{})
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled := args[0].(bool)
|
||||||
owner := args[1].(interop.Hash160)
|
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner can reinitialize contract")
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||||
if notaryDisabled {
|
if notaryDisabled {
|
||||||
|
@ -43,12 +36,10 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by committee.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
if !common.HasUpdateAccess(ctx) {
|
|
||||||
panic("only owner 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, data)
|
||||||
|
@ -136,7 +127,6 @@ func ListByEpoch(epoch int) [][]byte {
|
||||||
var result [][]byte
|
var result [][]byte
|
||||||
|
|
||||||
ignore := [][]byte{
|
ignore := [][]byte{
|
||||||
[]byte(common.OwnerKey),
|
|
||||||
[]byte(notaryDisabledKey),
|
[]byte(notaryDisabledKey),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue