feat: add Log, Notify and Triggers
Imported from CityOfZion/neo-storm (5065465e39fd2b308c487f49f75f517620139660).
This commit is contained in:
parent
e6c16a6a24
commit
e4c80a001c
4 changed files with 68 additions and 18 deletions
43
examples/runtime/runtime.go
Normal file
43
examples/runtime/runtime.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package runtime_contract
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go-sc/interop/runtime"
|
||||
"github.com/CityOfZion/neo-go-sc/interop/util"
|
||||
)
|
||||
|
||||
// Check if the invoker of the contract is the specified owner
|
||||
var owner = util.FromAddress("Aej1fe4mUgou48Zzup5j8sPrE3973cJ5oz")
|
||||
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue