[#82] Fix conversion of container id values from smart-contract

Smart-contract stores container ids as a raw bytes, not marshaled
protobuf structures.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-07 19:27:07 +03:00 committed by Alex Vanin
parent 7d51688d2c
commit e3f8e350f9

View file

@ -8,7 +8,6 @@ import (
v2container "github.com/nspcc-dev/neofs-api-go/v2/container" v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
msgContainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc" msgContainer "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs" v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
msgRefs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
core "github.com/nspcc-dev/neofs-node/pkg/core/container" core "github.com/nspcc-dev/neofs-node/pkg/core/container"
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -144,16 +143,9 @@ func (w *Wrapper) List(ownerID *owner.ID) ([]*container.ID, error) {
result := make([]*container.ID, 0, len(rawIDs)) result := make([]*container.ID, 0, len(rawIDs))
for i := range rawIDs { for i := range rawIDs {
// convert serialized bytes into GRPC structure v2 := new(v2refs.ContainerID)
grpcMsg := new(msgRefs.ContainerID) v2.SetValue(rawIDs[i])
err = grpcMsg.Unmarshal(rawIDs[i])
if err != nil {
// use other major version if there any
return nil, errors.Wrap(err, "can't unmarshal container id")
}
// convert GRPC structure into SDK structure, used in the code
v2 := v2refs.ContainerIDFromGRPCMessage(grpcMsg)
cid := container.NewIDFromV2(v2) cid := container.NewIDFromV2(v2)
result = append(result, cid) result = append(result, cid)