diff --git a/pkg/core/native/oracle.go b/pkg/core/native/oracle.go index 18c168743..d0e2935b6 100644 --- a/pkg/core/native/oracle.go +++ b/pkg/core/native/oracle.go @@ -13,7 +13,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/contract" - "github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/native/noderoles" "github.com/nspcc-dev/neo-go/pkg/core/state" @@ -29,7 +28,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util/slice" "github.com/nspcc-dev/neo-go/pkg/vm/emit" - "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" ) @@ -89,11 +87,7 @@ func newOracle() *Oracle { defer o.UpdateHash() w := io.NewBufBinWriter() - emit.Opcodes(w.BinWriter, opcode.NEWARRAY0) - emit.Int(w.BinWriter, int64(callflag.All)) - emit.String(w.BinWriter, "finish") - emit.Bytes(w.BinWriter, o.Hash.BytesBE()) - emit.Syscall(w.BinWriter, interopnames.SystemContractCall) + emit.AppCall(w.BinWriter, o.Hash, "finish", callflag.All) o.oracleScript = w.Bytes() desc := newDescriptor("request", smartcontract.VoidType, diff --git a/pkg/vm/emit/emit.go b/pkg/vm/emit/emit.go index c3f3fb773..e3146d76c 100644 --- a/pkg/vm/emit/emit.go +++ b/pkg/vm/emit/emit.go @@ -76,6 +76,10 @@ func bigInt(w *io.BinWriter, n *big.Int) { // Array emits array of elements to the given buffer. func Array(w *io.BinWriter, es ...interface{}) { + if len(es) == 0 { + Opcodes(w, opcode.NEWARRAY0) + return + } for i := len(es) - 1; i >= 0; i-- { switch e := es[i].(type) { case []interface{}: diff --git a/pkg/vm/emit/emit_test.go b/pkg/vm/emit/emit_test.go index ea5c996a1..9d8a20257 100644 --- a/pkg/vm/emit/emit_test.go +++ b/pkg/vm/emit/emit_test.go @@ -177,7 +177,7 @@ func TestEmitArray(t *testing.T) { buf := io.NewBufBinWriter() Array(buf.BinWriter) require.NoError(t, buf.Err) - assert.EqualValues(t, []byte{byte(opcode.PUSH0), byte(opcode.PACK)}, buf.Bytes()) + assert.EqualValues(t, []byte{byte(opcode.NEWARRAY0)}, buf.Bytes()) }) t.Run("invalid type", func(t *testing.T) {