package common import ( "github.com/nspcc-dev/neo-go/pkg/interop/convert" "github.com/nspcc-dev/neo-go/pkg/interop/native/std" "github.com/nspcc-dev/neo-go/pkg/interop/storage" ) // SetSerialized serializes data and puts it into contract storage. func SetSerialized(ctx storage.Context, key any, value interface{}) { data := std.Serialize(value) storage.Put(ctx, key, data) } // ToFixedWidth64 converts x to bytes such that numbers <= math.MaxUint64 // have constant with of 9. func ToFixedWidth64(x int) []byte { data := convert.ToBytes(x) if x < 0 || len(data) >= 9 { return data } return append(data, make([]byte, 9-len(data))...) } // FromFixedWidth64 is a reverse function for ToFixedWidth64. func FromFixedWidth64(x []byte) int { return convert.ToInteger(x) }