From 05dad10e82856a6320912a11d6a7b2e20a12fc88 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 19 Jun 2020 11:55:22 +0300 Subject: [PATCH] native: fix native contract `onPersist` script C# implementation uses NEWARRAY for creating arguments. Don't change our implementation in `emit`, because PACK is cheaper and this script must not depend on the internal details of `emit` package anyway. --- pkg/core/native/contract.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/core/native/contract.go b/pkg/core/native/contract.go index 55ff6230a..e9dc4f418 100644 --- a/pkg/core/native/contract.go +++ b/pkg/core/native/contract.go @@ -8,6 +8,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/emit" + "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/pkg/errors" ) @@ -65,7 +66,10 @@ func (cs *Contracts) GetPersistScript() []byte { w := io.NewBufBinWriter() for i := range cs.Contracts { md := cs.Contracts[i].Metadata() - emit.AppCallWithOperationAndArgs(w.BinWriter, md.Hash, "onPersist") + emit.Int(w.BinWriter, 0) + emit.Opcode(w.BinWriter, opcode.NEWARRAY) + emit.String(w.BinWriter, "onPersist") + emit.AppCall(w.BinWriter, md.Hash) } cs.persistScript = w.Bytes() return cs.persistScript