forked from TrueCloudLab/frostfs-node
[#1400] owner: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f8ac4632f8
commit
bb25ecbd15
60 changed files with 379 additions and 327 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/precision"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/accounting"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -24,18 +24,16 @@ var accountingBalanceCmd = &cobra.Command{
|
|||
Short: "Get internal balance of NeoFS account",
|
||||
Long: `Get internal balance of NeoFS account`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var oid *owner.ID
|
||||
var oid user.ID
|
||||
|
||||
pk, err := key.GetOrGenerate()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
balanceOwner, _ := cmd.Flags().GetString(ownerFlag)
|
||||
if balanceOwner == "" {
|
||||
oid = owner.NewIDFromPublicKey(&pk.PublicKey)
|
||||
user.IDFromKey(&oid, pk.PublicKey)
|
||||
} else {
|
||||
oid := owner.NewID()
|
||||
err := oid.Parse(balanceOwner)
|
||||
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", err)
|
||||
common.ExitOnErr(cmd, "can't decode owner ID wallet address: %w", oid.DecodeString(balanceOwner))
|
||||
}
|
||||
|
||||
cli, err := internalclient.GetSDKClientByFlag(pk, commonflags.RPC)
|
||||
|
@ -43,7 +41,7 @@ var accountingBalanceCmd = &cobra.Command{
|
|||
|
||||
var prm internalclient.BalanceOfPrm
|
||||
prm.SetClient(cli)
|
||||
prm.SetAccount(*oid)
|
||||
prm.SetAccount(oid)
|
||||
|
||||
res, err := internalclient.BalanceOf(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -96,8 +96,9 @@ func createToken(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
ownerStr, _ := cmd.Flags().GetString(ownerFlag)
|
||||
ownerID := owner.NewID()
|
||||
if err := ownerID.Parse(ownerStr); err != nil {
|
||||
|
||||
var ownerID user.ID
|
||||
if err := ownerID.DecodeString(ownerStr); err != nil {
|
||||
return fmt.Errorf("can't parse recipient: %w", err)
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ func createToken(cmd *cobra.Command, _ []string) error {
|
|||
b.SetExpiration(exp)
|
||||
b.SetNotBefore(nvb)
|
||||
b.SetIssuedAt(iat)
|
||||
b.SetOwnerID(*ownerID)
|
||||
b.SetOwnerID(ownerID)
|
||||
|
||||
eaclPath, _ := cmd.Flags().GetString(eaclFlag)
|
||||
if eaclPath != "" {
|
||||
|
|
|
@ -23,10 +23,10 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
versionSDK "github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -114,22 +114,21 @@ var listContainersCmd = &cobra.Command{
|
|||
Short: "List all created containers",
|
||||
Long: "List all created containers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var oid *owner.ID
|
||||
var idUser user.ID
|
||||
|
||||
key, err := getKey()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
if containerOwner == "" {
|
||||
oid = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||
user.IDFromKey(&idUser, key.PublicKey)
|
||||
} else {
|
||||
oid, err = ownerFromString(containerOwner)
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
common.ExitOnErr(cmd, "", userFromString(&idUser, containerOwner))
|
||||
}
|
||||
|
||||
var prm internalclient.ListContainersPrm
|
||||
|
||||
prepareAPIClientWithKey(cmd, key, &prm)
|
||||
prm.SetAccount(*oid)
|
||||
prm.SetAccount(idUser)
|
||||
|
||||
res, err := internalclient.ListContainers(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
@ -168,10 +167,11 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
|||
key, err := getKey()
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
var idOwner *owner.ID
|
||||
var idOwner *user.ID
|
||||
|
||||
if idOwner = tok.OwnerID(); idOwner == nil {
|
||||
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||
idOwner = new(user.ID)
|
||||
user.IDFromKey(idOwner, key.PublicKey)
|
||||
}
|
||||
|
||||
ver := versionSDK.Current()
|
||||
|
|
|
@ -27,8 +27,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -335,7 +335,7 @@ func prepareSessionPrmWithOwner(
|
|||
cmd *cobra.Command,
|
||||
addr *addressSDK.Address,
|
||||
key *ecdsa.PrivateKey,
|
||||
ownerID *owner.ID,
|
||||
ownerID *user.ID,
|
||||
prms ...clientKeySession,
|
||||
) {
|
||||
cli, err := internalclient.GetSDKClientByFlag(key, commonflags.RPC)
|
||||
|
@ -739,8 +739,11 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
|||
}
|
||||
}
|
||||
|
||||
func getOwnerID(key *ecdsa.PrivateKey) (*owner.ID, error) {
|
||||
return owner.NewIDFromPublicKey(&key.PublicKey), nil
|
||||
func getOwnerID(key *ecdsa.PrivateKey) (*user.ID, error) {
|
||||
var res user.ID
|
||||
user.IDFromKey(&res, key.PublicKey)
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
var searchUnaryOpVocabulary = map[string]object.SearchMatchType{
|
||||
|
|
|
@ -2,7 +2,6 @@ package cmd
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -21,8 +20,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/pkg/util/gendoc"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -187,16 +186,14 @@ func getTTL() uint32 {
|
|||
return ttl
|
||||
}
|
||||
|
||||
// ownerFromString converts string with NEO3 wallet address to neofs owner ID.
|
||||
func ownerFromString(s string) (*owner.ID, error) {
|
||||
result := owner.NewID()
|
||||
|
||||
err := result.Parse(s)
|
||||
// userFromString decodes user ID from string input.
|
||||
func userFromString(id *user.ID, s string) error {
|
||||
err := id.DecodeString(s)
|
||||
if err != nil {
|
||||
return nil, errors.New("can't decode owner ID wallet address")
|
||||
return fmt.Errorf("invalid user ID: %w", err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func printVerbose(format string, a ...interface{}) {
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
@ -69,8 +69,10 @@ func createSession(cmd *cobra.Command, _ []string) error {
|
|||
lifetime = lfArg
|
||||
}
|
||||
|
||||
ownerID := owner.NewIDFromPublicKey(&privKey.PublicKey)
|
||||
tok, err := CreateSession(c, ownerID, lifetime)
|
||||
var ownerID user.ID
|
||||
user.IDFromKey(&ownerID, privKey.PublicKey)
|
||||
|
||||
tok, err := CreateSession(c, &ownerID, lifetime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -95,7 +97,7 @@ func createSession(cmd *cobra.Command, _ []string) error {
|
|||
|
||||
// CreateSession returns newly created session token with the specified owner and lifetime.
|
||||
// `Issued-At` and `Not-Valid-Before` fields are set to current epoch.
|
||||
func CreateSession(c *client.Client, owner *owner.ID, lifetime uint64) (*session.Token, error) {
|
||||
func CreateSession(c *client.Client, owner *user.ID, lifetime uint64) (*session.Token, error) {
|
||||
var netInfoPrm internalclient.NetworkInfoPrm
|
||||
netInfoPrm.SetClient(c)
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
storagegroupAPI "github.com/nspcc-dev/neofs-sdk-go/storagegroup"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -140,7 +140,7 @@ func init() {
|
|||
type sgHeadReceiver struct {
|
||||
cmd *cobra.Command
|
||||
key *ecdsa.PrivateKey
|
||||
ownerID *owner.ID
|
||||
ownerID *user.ID
|
||||
prm internalclient.HeadObjectPrm
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue