[#1159] adm: Remove wallet requirement for list-groups

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-06-17 14:59:41 +03:00
parent a9b93676e0
commit e05deb6dea

View file

@ -3,6 +3,8 @@ package frostfsid
import (
"errors"
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-contract/commonclient"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
"sort"
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
@ -349,12 +351,23 @@ func frostfsidDeleteGroup(cmd *cobra.Command, _ []string) {
}
func frostfsidListGroups(cmd *cobra.Command, _ []string) {
c, err := helper.GetN3Client(viper.GetViper())
commonCmd.ExitOnErr(cmd, "can't create N3 client: %w", err)
inv := invoker.New(c, nil)
r := management.NewReader(inv)
cs, err := r.GetContractByID(1)
commonCmd.ExitOnErr(cmd, "can't get NNS contract info: %w", err)
nmHash, err := helper.NNSResolveHash(inv, cs.Hash, helper.DomainOf(constants.FrostfsIDContract))
commonCmd.ExitOnErr(cmd, "can't get netmap contract hash: %w", err)
ns := getFrostfsIDNamespace(cmd)
items, err := commonclient.ReadIteratorItems(inv, 100, nmHash, "listGroups", ns)
commonCmd.ExitOnErr(cmd, "list groups: %w", err)
ffsid, err := newFrostfsIDClient(cmd)
commonCmd.ExitOnErr(cmd, "init contract invoker: %w", err)
groups, err := ffsid.roCli.ListGroups(ns)
groups, err := frostfsidclient.ParseGroups(items)
commonCmd.ExitOnErr(cmd, "list groups: %w", err)
sort.Slice(groups, func(i, j int) bool { return groups[i].Name < groups[j].Name })