diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index 59baacfeeb..019726ce68 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -109,25 +109,32 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) { return cnr, nil } +// Delete marshals container ID, and passes it to Wrapper's Delete method +// along with sig.Key() and sig.Sign(). +// +// Returns error if cid is nil. +func Delete(w *Wrapper, cid *container.ID, sig *pkg.Signature) error { + if cid == nil { + return errNilArgument + } + + return w.Delete(cid.ToV2().GetValue(), sig.Sign()) +} + // Delete removes the container from NeoFS system // through Container contract call. // // Returns any error encountered that caused // the removal to interrupt. -func (w *Wrapper) Delete(cid *container.ID, signature []byte) error { - if cid == nil || len(signature) == 0 { +func (w *Wrapper) Delete(cid, signature []byte) error { + if len(signature) == 0 { return errNilArgument } - args := client.DeleteArgs{} + var args client.DeleteArgs + args.SetSignature(signature) - - v2 := cid.ToV2() - if v2 == nil { - return errUnsupported // use other major version if there any - } - - args.SetCID(v2.GetValue()) + args.SetCID(cid) return w.client.Delete(args) } diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 3e4baed333..e6801e028d 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -45,8 +45,9 @@ func (s *morphExecutor) Put(ctx context.Context, body *container.PutRequestBody) func (s *morphExecutor) Delete(ctx context.Context, body *container.DeleteRequestBody) (*container.DeleteResponseBody, error) { cid := containerSDK.NewIDFromV2(body.GetContainerID()) + sig := pkg.NewSignatureFromV2(body.GetSignature()) - err := s.wrapper.Delete(cid, body.GetSignature().GetSign()) + err := wrapper.Delete(s.wrapper, cid, sig) if err != nil { return nil, err }