Tried to implement PutNumber and GetNumber funcs based on contracts in frostfsid_contract.go Added just one test for now, it's not failing Signed-off-by: Lebedeva Ekaterina <ekaterina.lebedeva@yadro.com>
34 lines
840 B
Go
34 lines
840 B
Go
package contract
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
)
|
|
|
|
var notificationName string
|
|
|
|
// init initializes notificationName before calling any other smart-contract method
|
|
func init() {
|
|
notificationName = "Hello world!"
|
|
}
|
|
|
|
// RuntimeNotify sends runtime notification with "Hello world!" name
|
|
func RuntimeNotify(args []interface{}) {
|
|
runtime.Notify(notificationName, args)
|
|
}
|
|
|
|
// the answer to the “Great Question” of “Life, the Universe and Everything”
|
|
func GetNumber() int {
|
|
ctx := storage.GetContext()
|
|
// it := storage.Find(ctx, 123, storage.None)
|
|
// for iterator.Next(it) {
|
|
// num = iterator.Value(it).(int)
|
|
// }
|
|
num := storage.Get(ctx, 123).(int)
|
|
return num
|
|
}
|
|
|
|
func PutNumber(num int) {
|
|
ctx := storage.GetContext()
|
|
storage.Put(ctx, 123, num)
|
|
}
|