mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-29 09:27:36 +00:00
c1cc7e6f9d
1. Management contract has 2 overloads of `deploy` method. 2. Normal contracts should have `_deploy` with 2 parameters.
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package runtimecontract
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
|
)
|
|
|
|
var (
|
|
// Check if the invoker of the contract is the specified owner
|
|
owner = util.FromAddress("NULwe3UAHckN2fzNdcVg31tDiaYtMDwANt")
|
|
trigger byte
|
|
)
|
|
|
|
// init initializes trigger before any other contract method is called
|
|
func init() {
|
|
trigger = runtime.GetTrigger()
|
|
}
|
|
|
|
func _deploy(_ interface{}, isUpdate bool) {
|
|
if isUpdate {
|
|
Log("_deploy method called before contract update")
|
|
return
|
|
}
|
|
Log("_deploy method called before contract creation")
|
|
}
|
|
|
|
// CheckWitness checks owner's witness
|
|
func CheckWitness() bool {
|
|
// Log owner upon Verification trigger
|
|
if trigger != runtime.Verification {
|
|
return false
|
|
}
|
|
if runtime.CheckWitness(owner) {
|
|
runtime.Log("Verified Owner")
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Log logs given message
|
|
func Log(message string) bool {
|
|
if trigger != runtime.Application {
|
|
return false
|
|
}
|
|
runtime.Log(message)
|
|
return true
|
|
}
|
|
|
|
// Notify notifies about given message
|
|
func Notify(event interface{}) bool {
|
|
if trigger != runtime.Application {
|
|
return false
|
|
}
|
|
runtime.Notify("Event", event)
|
|
return true
|
|
}
|