[#1379] neofs-cli: Move client creation to internal/client
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
cbc4ca800d
commit
a198a4858c
4 changed files with 19 additions and 34 deletions
|
@ -2,12 +2,27 @@ package internal
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var errInvalidEndpoint = errors.New("provided RPC endpoint is incorrect")
|
||||
|
||||
// GetSDKClientByFlag returns default neofs-sdk-go client using the specified flag for the address.
|
||||
func GetSDKClientByFlag(key *ecdsa.PrivateKey, endpointFlag string) (*client.Client, error) {
|
||||
var addr network.Address
|
||||
|
||||
err := addr.FromString(viper.GetString(endpointFlag))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
|
||||
}
|
||||
return GetSDKClient(key, addr)
|
||||
}
|
||||
|
||||
// GetSDKClient returns default neofs-sdk-go client.
|
||||
func GetSDKClient(key *ecdsa.PrivateKey, addr network.Address) (*client.Client, error) {
|
||||
var (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue