2021-07-04 11:00:56 +00:00
|
|
|
package proxy
|
2021-02-19 14:47:41 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-07 11:06:21 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
2021-02-19 14:47:41 +00:00
|
|
|
"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"
|
2023-12-08 08:10:00 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/native/neo"
|
2021-02-19 14:47:41 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
)
|
|
|
|
|
2021-07-07 15:34:03 +00:00
|
|
|
// OnNEP17Payment is a callback for NEP-17 compatible native GAS contract.
|
2023-11-07 12:18:48 +00:00
|
|
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
2021-02-19 14:47:41 +00:00
|
|
|
caller := runtime.GetCallingScriptHash()
|
|
|
|
if !common.BytesEqual(caller, []byte(gas.Hash)) {
|
2021-11-30 09:44:05 +00:00
|
|
|
common.AbortWithMessage("proxy contract accepts GAS only")
|
2021-02-19 14:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-07 12:18:48 +00:00
|
|
|
func _deploy(data any, isUpdate bool) {
|
2021-06-03 07:49:07 +00:00
|
|
|
if isUpdate {
|
2023-11-07 12:18:48 +00:00
|
|
|
args := data.([]any)
|
2021-12-27 08:49:30 +00:00
|
|
|
common.CheckVersion(args[len(args)-1].(int))
|
2021-06-03 07:49:07 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-02-19 14:47:41 +00:00
|
|
|
runtime.Log("proxy contract initialized")
|
|
|
|
}
|
|
|
|
|
2022-04-14 11:56:51 +00:00
|
|
|
// Update method updates contract source code and manifest. It can be invoked
|
2021-09-20 15:41:46 +00:00
|
|
|
// only by committee.
|
2023-11-07 12:18:48 +00:00
|
|
|
func Update(script []byte, manifest []byte, data any) {
|
2021-09-20 15:41:46 +00:00
|
|
|
if !common.HasUpdateAccess() {
|
|
|
|
panic("only committee can update contract")
|
2021-02-19 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2023-06-19 08:17:51 +00:00
|
|
|
management.UpdateWithData(script, manifest, common.AppendVersion(data))
|
2021-02-19 14:47:41 +00:00
|
|
|
runtime.Log("proxy contract updated")
|
|
|
|
}
|
|
|
|
|
2022-04-14 11:56:51 +00:00
|
|
|
// Verify method returns true if transaction contains valid multisignature of
|
2021-07-07 15:34:03 +00:00
|
|
|
// Alphabet nodes of the Inner Ring.
|
2023-12-08 08:10:00 +00:00
|
|
|
func Verify() bool {
|
|
|
|
alphabet := neo.GetCommittee()
|
|
|
|
sig := common.Multiaddress(alphabet, false)
|
2021-03-09 19:15:58 +00:00
|
|
|
|
2023-12-08 08:10:00 +00:00
|
|
|
if !runtime.CheckWitness(sig) {
|
|
|
|
sig = common.Multiaddress(alphabet, true)
|
|
|
|
return runtime.CheckWitness(sig)
|
2021-03-10 14:01:57 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 08:10:00 +00:00
|
|
|
return true
|
2021-02-19 14:47:41 +00:00
|
|
|
}
|
|
|
|
|
2022-04-14 11:56:51 +00:00
|
|
|
// Version returns the version of the contract.
|
2021-02-19 14:47:41 +00:00
|
|
|
func Version() int {
|
2021-07-29 11:44:53 +00:00
|
|
|
return common.Version
|
2021-02-19 14:47:41 +00:00
|
|
|
}
|