vm/encoding: move bigint from vm to encoding package

This commit is contained in:
Anna Shaleva 2020-06-04 21:11:27 +03:00
parent 783f5ecb01
commit 7ca2807875
16 changed files with 55 additions and 47 deletions

View file

@ -4,8 +4,8 @@ import (
"errors"
"math/big"
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
)
// SerializeItem encodes given Item into the byte slice.
@ -43,7 +43,7 @@ func serializeItemTo(item Item, w *io.BinWriter, seen map[Item]bool) {
w.WriteBool(t.Value().(bool))
case *BigInteger:
w.WriteBytes([]byte{byte(IntegerT)})
w.WriteVarBytes(emit.IntToBytes(t.Value().(*big.Int)))
w.WriteVarBytes(bigint.ToBytes(t.Value().(*big.Int)))
case *Interop:
w.Err = errors.New("interop item can't be serialized")
case *Array, *Struct:
@ -102,7 +102,7 @@ func DecodeBinaryStackItem(r *io.BinReader) Item {
return NewBool(b)
case IntegerT:
data := r.ReadVarBytes()
num := emit.BytesToInt(data)
num := bigint.FromBytes(data)
return NewBigInteger(num)
case ArrayT, StructT:
size := int(r.ReadVarUint())