From 55c83454b6d8be72fd8b17086a1cb8390767c052 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 31 May 2021 20:44:23 +0300 Subject: [PATCH] [#556] morph/neofsid: Implement key management on client wrapper Implement method `ClientWrapper.ManageKeys` method which provides the interface to add/remove keys to/from NeoFS account. Signed-off-by: Leonard Lyubich --- pkg/morph/client/neofsid/wrapper/keys.go | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkg/morph/client/neofsid/wrapper/keys.go b/pkg/morph/client/neofsid/wrapper/keys.go index 4604e7645..5748b01ac 100644 --- a/pkg/morph/client/neofsid/wrapper/keys.go +++ b/pkg/morph/client/neofsid/wrapper/keys.go @@ -36,3 +36,33 @@ func (x *ClientWrapper) AccountKeys(id *owner.ID) (keys.PublicKeys, error) { return ks, nil } + +// ManageKeys adds/removes list of public keys to/from NeoFS account. +func (x *ClientWrapper) ManageKeys(ownerID []byte, ks [][]byte, add bool) error { + type args interface { + SetOwnerID([]byte) + SetKeys([][]byte) + } + + var ( + a args + call func(args) error + ) + + if add { + a = new(neofsid.AddKeysArgs) + call = func(a args) error { + return (*neofsid.Client)(x).AddKeys(*a.(*neofsid.AddKeysArgs)) + } + } else { + a = new(neofsid.RemoveKeysArgs) + call = func(a args) error { + return (*neofsid.Client)(x).RemoveKeys(*a.(*neofsid.RemoveKeysArgs)) + } + } + + a.SetOwnerID(ownerID) + a.SetKeys(ks) + + return call(a) +}