2019-09-03 15:00:10 +00:00
|
|
|
package runtimecontract
|
2018-08-21 08:55:03 +00:00
|
|
|
|
|
|
|
import (
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
2018-08-21 08:55:03 +00:00
|
|
|
)
|
|
|
|
|
2020-08-10 10:42:02 +00:00
|
|
|
var (
|
|
|
|
// Check if the invoker of the contract is the specified owner
|
2021-05-11 13:32:09 +00:00
|
|
|
owner = util.FromAddress("NbrUYaZgyhSkNoRo9ugRyEMdUZxrhkNaWB")
|
2020-08-10 10:42:02 +00:00
|
|
|
trigger byte
|
|
|
|
)
|
2018-08-21 08:55:03 +00:00
|
|
|
|
2020-08-10 10:42:02 +00:00
|
|
|
// init initializes trigger before any other contract method is called
|
|
|
|
func init() {
|
|
|
|
trigger = runtime.GetTrigger()
|
2018-08-21 08:55:03 +00:00
|
|
|
}
|
2020-07-03 11:53:29 +00:00
|
|
|
|
2021-01-28 13:31:50 +00:00
|
|
|
func _deploy(_ interface{}, isUpdate bool) {
|
2020-10-10 17:17:04 +00:00
|
|
|
if isUpdate {
|
|
|
|
Log("_deploy method called before contract update")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
Log("_deploy method called before contract creation")
|
|
|
|
}
|
|
|
|
|
2020-07-03 11:53:29 +00:00
|
|
|
// CheckWitness checks owner's witness
|
|
|
|
func CheckWitness() bool {
|
2020-08-10 10:42:02 +00:00
|
|
|
// Log owner upon Verification trigger
|
|
|
|
if trigger != runtime.Verification {
|
|
|
|
return false
|
|
|
|
}
|
2020-07-03 11:53:29 +00:00
|
|
|
if runtime.CheckWitness(owner) {
|
|
|
|
runtime.Log("Verified Owner")
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log logs given message
|
2020-08-10 10:42:02 +00:00
|
|
|
func Log(message string) bool {
|
|
|
|
if trigger != runtime.Application {
|
|
|
|
return false
|
|
|
|
}
|
2020-07-03 11:53:29 +00:00
|
|
|
runtime.Log(message)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify notifies about given message
|
2020-08-10 10:42:02 +00:00
|
|
|
func Notify(event interface{}) bool {
|
|
|
|
if trigger != runtime.Application {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
runtime.Notify("Event", event)
|
2020-07-03 11:53:29 +00:00
|
|
|
return true
|
|
|
|
}
|