Merge pull request #1331 from nspcc-dev/persist-fix

core: fix getOnPersistWrapper for native contracts
This commit is contained in:
Roman Khimov 2020-08-18 12:14:44 +03:00 committed by GitHub
commit e726df8d15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package native
import ( import (
"errors" "errors"
"fmt"
"math/big" "math/big"
"github.com/nspcc-dev/neo-go/pkg/core/dao" "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 { func getOnPersistWrapper(f func(ic *interop.Context) error) interop.Method {
return func(ic *interop.Context, _ []stackitem.Item) stackitem.Item { 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{}
} }
} }