forked from TrueCloudLab/frostfs-node
8c2d42368a
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>
35 lines
792 B
Go
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)
|
|
}
|