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.
This commit is contained in:
Evgenii Stratonikov 2020-06-19 11:55:22 +03:00
parent 3787a8895e
commit 05dad10e82

View file

@ -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