-
Notifications
You must be signed in to change notification settings - Fork 79
/
runtime.go
44 lines (35 loc) · 973 Bytes
/
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
package runtimecontract
import (
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/util"
)
// Check if the invoker of the contract is the specified owner
var owner = util.FromAddress("Aej1fe4mUgou48Zzup5j8sPrE3973cJ5oz")
// Main is something to be ran from outside.
func Main(operation string, args []interface{}) bool {
trigger := runtime.GetTrigger()
// Log owner upon Verification trigger
if trigger == runtime.Verification() {
if runtime.CheckWitness(owner) {
runtime.Log("Verified Owner")
}
return true
}
// Discerns between log and notify for this test
if trigger == runtime.Application() {
return handleOperation(operation, args)
}
return false
}
func handleOperation(operation string, args []interface{}) bool {
if operation == "log" {
message := args[0].(string)
runtime.Log(message)
return true
}
if operation == "notify" {
runtime.Notify(args[0])
return true
}
return false
}