forked from TrueCloudLab/frostfs-contract
[#83] policy: Allow to update contract
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
5119f655fe
commit
e27b8ad306
2 changed files with 16 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
name: "APE"
|
name: "APE"
|
||||||
|
permissions:
|
||||||
|
- methods: ["update"]
|
||||||
safemethods:
|
safemethods:
|
||||||
- "getAdmin"
|
- "getAdmin"
|
||||||
- "listChains"
|
- "listChains"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
"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/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"
|
||||||
)
|
)
|
||||||
|
@ -36,6 +37,8 @@ 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 any, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
|
args := data.([]any)
|
||||||
|
common.CheckVersion(args[len(args)-1].(int))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +72,17 @@ func Version() int {
|
||||||
return common.Version
|
return common.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update method updates contract source code and manifest. It can be invoked
|
||||||
|
// by committee only.
|
||||||
|
func Update(script []byte, manifest []byte, data any) {
|
||||||
|
if !common.HasUpdateAccess() {
|
||||||
|
panic("only committee can update contract")
|
||||||
|
}
|
||||||
|
|
||||||
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
||||||
|
runtime.Log("policy contract updated")
|
||||||
|
}
|
||||||
|
|
||||||
func SetAdmin(addr interop.Hash160) {
|
func SetAdmin(addr interop.Hash160) {
|
||||||
common.CheckAlphabetWitness()
|
common.CheckAlphabetWitness()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue