frostfs-contract/proxy/proxy_contract.go
Evgenii Stratonikov a0b73150c6
Some checks failed
DCO action / DCO (pull_request) Failing after 1m2s
Tests / Tests (1.19) (pull_request) Successful in 1m32s
Tests / Tests (1.20) (pull_request) Successful in 1m32s
Revert "[#53] proxy: Allow using proxy by trusted accounts"
This reverts commit bc3186575f.
2023-12-08 11:10:00 +03:00

58 lines
1.6 KiB
Go

package proxy
import (
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
"github.com/nspcc-dev/neo-go/pkg/interop"
"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"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
)
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
caller := runtime.GetCallingScriptHash()
if !common.BytesEqual(caller, []byte(gas.Hash)) {
common.AbortWithMessage("proxy contract accepts GAS only")
}
}
func _deploy(data any, isUpdate bool) {
if isUpdate {
args := data.([]any)
common.CheckVersion(args[len(args)-1].(int))
return
}
runtime.Log("proxy contract initialized")
}
// Update method updates contract source code and manifest. It can be invoked
// only by committee.
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("proxy contract updated")
}
// Verify method returns true if transaction contains valid multisignature of
// Alphabet nodes of the Inner Ring.
func Verify() bool {
alphabet := neo.GetCommittee()
sig := common.Multiaddress(alphabet, false)
if !runtime.CheckWitness(sig) {
sig = common.Multiaddress(alphabet, true)
return runtime.CheckWitness(sig)
}
return true
}
// Version returns the version of the contract.
func Version() int {
return common.Version
}