rpc: use Notify with varargs in the test contract

This commit is contained in:
Evgenii Stratonikov 2020-04-05 18:14:54 +03:00
parent efad66aee1
commit 004023920e
2 changed files with 4 additions and 4 deletions

Binary file not shown.

View file

@ -12,7 +12,7 @@ const (
) )
func Main(operation string, args []interface{}) interface{} { func Main(operation string, args []interface{}) interface{} {
runtime.Notify([]interface{}{"contract call", operation, args}) runtime.Notify("contract call", operation, args)
switch operation { switch operation {
case "Put": case "Put":
ctx := storage.GetContext() ctx := storage.GetContext()
@ -34,7 +34,7 @@ func Main(operation string, args []interface{}) interface{} {
return false return false
} }
amount := storage.Get(ctx, addr).(int) amount := storage.Get(ctx, addr).(int)
runtime.Notify([]interface{}{"balanceOf", addr, amount}) runtime.Notify("balanceOf", addr, amount)
return amount return amount
case "transfer": case "transfer":
ctx := storage.GetContext() ctx := storage.GetContext()
@ -66,7 +66,7 @@ func Main(operation string, args []interface{}) interface{} {
toBalance += amount toBalance += amount
storage.Put(ctx, to, toBalance) storage.Put(ctx, to, toBalance)
runtime.Notify([]interface{}{"transfer", from, to, amount}) runtime.Notify("transfer", from, to, amount)
return true return true
case "init": case "init":
@ -74,7 +74,7 @@ func Main(operation string, args []interface{}) interface{} {
h := engine.GetExecutingScriptHash() h := engine.GetExecutingScriptHash()
amount := totalSupply amount := totalSupply
storage.Put(ctx, h, amount) storage.Put(ctx, h, amount)
runtime.Notify([]interface{}{"transfer", []byte{}, h, amount}) runtime.Notify("transfer", []byte{}, h, amount)
return true return true
default: default:
panic("invalid operation") panic("invalid operation")