From 591f639ad60459d7c6f43f6117ec929938d8e0e1 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 17 Aug 2020 15:34:13 +0300 Subject: [PATCH] core: fix getOnPersistWrapper for native contracts According to manifest, OnPersist.ReturnType is void, so we shouldn't return anything from it. It's not so important, as we drop this value at the end of OnPersist invocation. --- pkg/core/native/native_nep5.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/core/native/native_nep5.go b/pkg/core/native/native_nep5.go index e09b3a0a5..49ebe3908 100644 --- a/pkg/core/native/native_nep5.go +++ b/pkg/core/native/native_nep5.go @@ -2,6 +2,7 @@ package native import ( "errors" + "fmt" "math/big" "github.com/nspcc-dev/neo-go/pkg/core/dao" @@ -303,6 +304,10 @@ func toUint160(s stackitem.Item) util.Uint160 { func getOnPersistWrapper(f func(ic *interop.Context) error) interop.Method { return func(ic *interop.Context, _ []stackitem.Item) stackitem.Item { - return stackitem.NewBool(f(ic) == nil) + err := f(ic) + if err != nil { + panic(fmt.Errorf("OnPersist for native contract: %w", err)) + } + return stackitem.Null{} } }