diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index 08a61622b..7a23d3478 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -52,24 +52,36 @@ func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, *pkg.Signature, er return table, tableSignature, nil } -// PutEACL saves the extended ACL table in NeoFS system -// through Container contract call. +// PutEACL marshals table, and passes it to Wrapper's PutEACLBinary method +// along with sig.Key() and sig.Sign(). // -// Returns any error encountered that caused the saving to interrupt. -func (w *Wrapper) PutEACL(table *eacl.Table, signature []byte) error { - if table == nil || len(signature) == 0 { +// Returns error if table is nil. +func PutEACL(w *Wrapper, table *eacl.Table, sig *pkg.Signature) error { + if table == nil { return errNilArgument } - args := client.SetEACLArgs{} - args.SetSignature(signature) - data, err := table.Marshal() if err != nil { return fmt.Errorf("can't marshal eacl table: %w", err) } - args.SetEACL(data) + return w.PutEACLBinary(data, sig.Key(), sig.Sign()) +} + +// PutEACLBinary save binary eACL table with its key and signature +// in NeoFS system through Container contract call. +// +// Returns any error encountered that caused the saving to interrupt. +func (w *Wrapper) PutEACLBinary(table, key, sig []byte) error { + if len(sig) == 0 || len(key) == 0 { + return errNilArgument + } + + args := client.SetEACLArgs{} + args.SetSignature(table) + args.SetPublicKey(key) + args.SetEACL(sig) return w.client.SetEACL(args) } diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 9020df7a0..638c77d60 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/nspcc-dev/neofs-api-go/pkg" eaclSDK "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container" "github.com/nspcc-dev/neofs-api-go/pkg/owner" @@ -88,8 +89,9 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod func (s *morphExecutor) SetExtendedACL(ctx context.Context, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) { table := eaclSDK.NewTableFromV2(body.GetEACL()) + sign := pkg.NewSignatureFromV2(body.GetSignature()) - err := s.wrapper.PutEACL(table, body.GetSignature().GetSign()) + err := wrapper.PutEACL(s.wrapper, table, sign) return new(container.SetExtendedACLResponseBody), err }