-
Notifications
You must be signed in to change notification settings - Fork 79
/
runtime.go
55 lines (48 loc) · 1.14 KB
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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("NbrUYaZgyhSkNoRo9ugRyEMdUZxrhkNaWB")
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
}