frostfs-node/pkg/morph/client/neofs/wrapper/bind.go
Leonard Lyubich 8c2d42368a [#556] morph/neofs: Implement wrapper over contract client
Implement wrapper over NeoFS contact's client which allows you to
conveniently interact with the contract. Implement `ManageKeys` method
for binding or unbinding public keys to the NeoFS account.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-02 10:50:44 +03:00

35 lines
792 B
Go

package neofscontract
import (
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs"
)
// ManageKeys binds/unbinds list of public keys from NeoFS account by script hash.
func (x *ClientWrapper) ManageKeys(scriptHash []byte, ks [][]byte, bind bool) error {
type args interface {
SetScriptHash([]byte)
SetKeys([][]byte)
}
var (
a args
call func(args) error
)
if bind {
a = new(neofscontract.BindKeysArgs)
call = func(a args) error {
return (*neofscontract.Client)(x).BindKeys(*a.(*neofscontract.BindKeysArgs))
}
} else {
a = new(neofscontract.UnbindKeysArgs)
call = func(a args) error {
return (*neofscontract.Client)(x).UnbindKeys(*a.(*neofscontract.UnbindKeysArgs))
}
}
a.SetScriptHash(scriptHash)
a.SetKeys(ks)
return call(a)
}