Compare commits
No commits in common. "master" and "bugfix/traverser-out-range" have entirely different histories.
master
...
bugfix/tra
12 changed files with 63 additions and 54 deletions
|
@ -61,6 +61,7 @@ var (
|
||||||
Use: "list-namespaces",
|
Use: "list-namespaces",
|
||||||
Short: "List all namespaces in frostfsid",
|
Short: "List all namespaces in frostfsid",
|
||||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
},
|
},
|
||||||
Run: frostfsidListNamespaces,
|
Run: frostfsidListNamespaces,
|
||||||
|
@ -90,6 +91,7 @@ var (
|
||||||
Use: "list-subjects",
|
Use: "list-subjects",
|
||||||
Short: "List subjects in namespace",
|
Short: "List subjects in namespace",
|
||||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
},
|
},
|
||||||
Run: frostfsidListSubjects,
|
Run: frostfsidListSubjects,
|
||||||
|
@ -119,6 +121,7 @@ var (
|
||||||
Use: "list-groups",
|
Use: "list-groups",
|
||||||
Short: "List groups in namespace",
|
Short: "List groups in namespace",
|
||||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
},
|
},
|
||||||
Run: frostfsidListGroups,
|
Run: frostfsidListGroups,
|
||||||
|
@ -148,6 +151,7 @@ var (
|
||||||
Use: "list-group-subjects",
|
Use: "list-group-subjects",
|
||||||
Short: "List subjects in group",
|
Short: "List subjects in group",
|
||||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
},
|
},
|
||||||
Run: frostfsidListGroupSubjects,
|
Run: frostfsidListGroupSubjects,
|
||||||
|
@ -165,6 +169,7 @@ func initFrostfsIDCreateNamespaceCmd() {
|
||||||
func initFrostfsIDListNamespacesCmd() {
|
func initFrostfsIDListNamespacesCmd() {
|
||||||
Cmd.AddCommand(frostfsidListNamespacesCmd)
|
Cmd.AddCommand(frostfsidListNamespacesCmd)
|
||||||
frostfsidListNamespacesCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
frostfsidListNamespacesCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
|
frostfsidListNamespacesCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initFrostfsIDCreateSubjectCmd() {
|
func initFrostfsIDCreateSubjectCmd() {
|
||||||
|
@ -188,6 +193,7 @@ func initFrostfsIDListSubjectsCmd() {
|
||||||
frostfsidListSubjectsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
frostfsidListSubjectsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
frostfsidListSubjectsCmd.Flags().String(namespaceFlag, "", "Namespace to list subjects")
|
frostfsidListSubjectsCmd.Flags().String(namespaceFlag, "", "Namespace to list subjects")
|
||||||
frostfsidListSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)")
|
frostfsidListSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)")
|
||||||
|
frostfsidListSubjectsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initFrostfsIDCreateGroupCmd() {
|
func initFrostfsIDCreateGroupCmd() {
|
||||||
|
@ -211,6 +217,7 @@ func initFrostfsIDListGroupsCmd() {
|
||||||
Cmd.AddCommand(frostfsidListGroupsCmd)
|
Cmd.AddCommand(frostfsidListGroupsCmd)
|
||||||
frostfsidListGroupsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
frostfsidListGroupsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
frostfsidListGroupsCmd.Flags().String(namespaceFlag, "", "Namespace to list groups")
|
frostfsidListGroupsCmd.Flags().String(namespaceFlag, "", "Namespace to list groups")
|
||||||
|
frostfsidListGroupsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initFrostfsIDAddSubjectToGroupCmd() {
|
func initFrostfsIDAddSubjectToGroupCmd() {
|
||||||
|
@ -235,6 +242,7 @@ func initFrostfsIDListGroupSubjectsCmd() {
|
||||||
frostfsidListGroupSubjectsCmd.Flags().String(namespaceFlag, "", "Namespace name")
|
frostfsidListGroupSubjectsCmd.Flags().String(namespaceFlag, "", "Namespace name")
|
||||||
frostfsidListGroupSubjectsCmd.Flags().Int64(groupIDFlag, 0, "Group id")
|
frostfsidListGroupSubjectsCmd.Flags().Int64(groupIDFlag, 0, "Group id")
|
||||||
frostfsidListGroupSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)")
|
frostfsidListGroupSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)")
|
||||||
|
frostfsidListGroupSubjectsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) {
|
func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) {
|
||||||
|
|
|
@ -38,24 +38,38 @@ func NewLocalActor(cmd *cobra.Command, c actor.RPCActor, accName string) (*Local
|
||||||
walletDir := config.ResolveHomePath(viper.GetString(commonflags.AlphabetWalletsFlag))
|
walletDir := config.ResolveHomePath(viper.GetString(commonflags.AlphabetWalletsFlag))
|
||||||
var act *actor.Actor
|
var act *actor.Actor
|
||||||
var accounts []*wallet.Account
|
var accounts []*wallet.Account
|
||||||
|
if walletDir == "" {
|
||||||
|
account, err := wallet.NewAccount()
|
||||||
|
commonCmd.ExitOnErr(cmd, "unable to create dummy account: %w", err)
|
||||||
|
act, err = actor.New(c, []actor.SignerAccount{{
|
||||||
|
Signer: transaction.Signer{
|
||||||
|
Account: account.Contract.ScriptHash(),
|
||||||
|
Scopes: transaction.Global,
|
||||||
|
},
|
||||||
|
Account: account,
|
||||||
|
}})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wallets, err := GetAlphabetWallets(viper.GetViper(), walletDir)
|
||||||
|
commonCmd.ExitOnErr(cmd, "unable to get alphabet wallets: %w", err)
|
||||||
|
|
||||||
wallets, err := GetAlphabetWallets(viper.GetViper(), walletDir)
|
for _, w := range wallets {
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get alphabet wallets: %w", err)
|
acc, err := GetWalletAccount(w, accName)
|
||||||
|
commonCmd.ExitOnErr(cmd, fmt.Sprintf("can't find %s account: %%w", accName), err)
|
||||||
for _, w := range wallets {
|
accounts = append(accounts, acc)
|
||||||
acc, err := GetWalletAccount(w, accName)
|
}
|
||||||
commonCmd.ExitOnErr(cmd, fmt.Sprintf("can't find %s account: %%w", accName), err)
|
act, err = actor.New(c, []actor.SignerAccount{{
|
||||||
accounts = append(accounts, acc)
|
Signer: transaction.Signer{
|
||||||
}
|
Account: accounts[0].Contract.ScriptHash(),
|
||||||
act, err = actor.New(c, []actor.SignerAccount{{
|
Scopes: transaction.Global,
|
||||||
Signer: transaction.Signer{
|
},
|
||||||
Account: accounts[0].Contract.ScriptHash(),
|
Account: accounts[0],
|
||||||
Scopes: transaction.Global,
|
}})
|
||||||
},
|
if err != nil {
|
||||||
Account: accounts[0],
|
return nil, err
|
||||||
}})
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
return &LocalActor{
|
return &LocalActor{
|
||||||
neoActor: act,
|
neoActor: act,
|
||||||
|
|
|
@ -12,6 +12,7 @@ var (
|
||||||
Short: "List netmap candidates nodes",
|
Short: "List netmap candidates nodes",
|
||||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
||||||
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
||||||
},
|
},
|
||||||
Run: listNetmapCandidatesNodes,
|
Run: listNetmapCandidatesNodes,
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func initRegisterCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerDomain(cmd *cobra.Command, _ []string) {
|
func registerDomain(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
|
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
email, _ := cmd.Flags().GetString(nnsEmailFlag)
|
email, _ := cmd.Flags().GetString(nnsEmailFlag)
|
||||||
|
@ -53,7 +53,7 @@ func initDeleteCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteDomain(cmd *cobra.Command, _ []string) {
|
func deleteDomain(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
|
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
h, vub, err := c.DeleteDomain(name)
|
h, vub, err := c.DeleteDomain(name)
|
||||||
|
|
|
@ -5,13 +5,13 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func nnsWriter(cmd *cobra.Command) (*client.Contract, *helper.LocalActor) {
|
func getRPCClient(cmd *cobra.Command) (*client.Contract, *helper.LocalActor, util.Uint160) {
|
||||||
v := viper.GetViper()
|
v := viper.GetViper()
|
||||||
c, err := helper.GetN3Client(v)
|
c, err := helper.GetN3Client(v)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
||||||
|
@ -22,17 +22,5 @@ func nnsWriter(cmd *cobra.Command) (*client.Contract, *helper.LocalActor) {
|
||||||
r := management.NewReader(ac.Invoker)
|
r := management.NewReader(ac.Invoker)
|
||||||
nnsCs, err := helper.GetContractByID(r, 1)
|
nnsCs, err := helper.GetContractByID(r, 1)
|
||||||
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
||||||
return client.New(ac, nnsCs.Hash), ac
|
return client.New(ac, nnsCs.Hash), ac, nnsCs.Hash
|
||||||
}
|
|
||||||
|
|
||||||
func nnsReader(cmd *cobra.Command) (*client.ContractReader, *invoker.Invoker) {
|
|
||||||
c, err := helper.GetN3Client(viper.GetViper())
|
|
||||||
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
|
||||||
|
|
||||||
inv := invoker.New(c, nil)
|
|
||||||
r := management.NewReader(inv)
|
|
||||||
nnsCs, err := helper.GetContractByID(r, 1)
|
|
||||||
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
|
||||||
|
|
||||||
return client.NewReader(inv, nnsCs.Hash), inv
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -28,6 +29,7 @@ func initAddRecordCmd() {
|
||||||
func initGetRecordsCmd() {
|
func initGetRecordsCmd() {
|
||||||
Cmd.AddCommand(getRecordsCmd)
|
Cmd.AddCommand(getRecordsCmd)
|
||||||
getRecordsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
getRecordsCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
|
getRecordsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
getRecordsCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
|
getRecordsCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
|
||||||
getRecordsCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc)
|
getRecordsCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc)
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ func initDelRecordCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addRecord(cmd *cobra.Command, _ []string) {
|
func addRecord(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
data, _ := cmd.Flags().GetString(nnsRecordDataFlag)
|
data, _ := cmd.Flags().GetString(nnsRecordDataFlag)
|
||||||
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
||||||
|
@ -75,16 +77,16 @@ func addRecord(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRecords(cmd *cobra.Command, _ []string) {
|
func getRecords(cmd *cobra.Command, _ []string) {
|
||||||
c, inv := nnsReader(cmd)
|
c, act, hash := getRPCClient(cmd)
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
||||||
if recordType == "" {
|
if recordType == "" {
|
||||||
sid, r, err := c.GetAllRecords(name)
|
sid, r, err := unwrap.SessionIterator(act.Invoker.Call(hash, "getAllRecords", name))
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
||||||
defer func() {
|
defer func() {
|
||||||
_ = inv.TerminateSession(sid)
|
_ = act.Invoker.TerminateSession(sid)
|
||||||
}()
|
}()
|
||||||
items, err := inv.TraverseIterator(sid, &r, 0)
|
items, err := act.Invoker.TraverseIterator(sid, &r, 0)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
||||||
for len(items) != 0 {
|
for len(items) != 0 {
|
||||||
for j := range items {
|
for j := range items {
|
||||||
|
@ -95,7 +97,7 @@ func getRecords(cmd *cobra.Command, _ []string) {
|
||||||
recordTypeToString(nns.RecordType(rs[1].Value().(*big.Int).Int64())),
|
recordTypeToString(nns.RecordType(rs[1].Value().(*big.Int).Int64())),
|
||||||
string(bs))
|
string(bs))
|
||||||
}
|
}
|
||||||
items, err = inv.TraverseIterator(sid, &r, 0)
|
items, err = act.Invoker.TraverseIterator(sid, &r, 0)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get records: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +114,7 @@ func getRecords(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func delRecords(cmd *cobra.Command, _ []string) {
|
func delRecords(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
||||||
typ, err := getRecordType(recordType)
|
typ, err := getRecordType(recordType)
|
||||||
|
@ -127,7 +129,7 @@ func delRecords(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func delRecord(cmd *cobra.Command, _ []string) {
|
func delRecord(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
data, _ := cmd.Flags().GetString(nnsRecordDataFlag)
|
data, _ := cmd.Flags().GetString(nnsRecordDataFlag)
|
||||||
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
recordType, _ := cmd.Flags().GetString(nnsRecordTypeFlag)
|
||||||
|
|
|
@ -14,7 +14,7 @@ func initRenewCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func renewDomain(cmd *cobra.Command, _ []string) {
|
func renewDomain(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
h, vub, err := c.Renew(name)
|
h, vub, err := c.Renew(name)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to renew domain: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to renew domain: %w", err)
|
||||||
|
|
|
@ -18,11 +18,12 @@ const (
|
||||||
func initTokensCmd() {
|
func initTokensCmd() {
|
||||||
Cmd.AddCommand(tokensCmd)
|
Cmd.AddCommand(tokensCmd)
|
||||||
tokensCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
tokensCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
|
tokensCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
tokensCmd.Flags().BoolP(commonflags.Verbose, commonflags.VerboseShorthand, false, verboseDesc)
|
tokensCmd.Flags().BoolP(commonflags.Verbose, commonflags.VerboseShorthand, false, verboseDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func listTokens(cmd *cobra.Command, _ []string) {
|
func listTokens(cmd *cobra.Command, _ []string) {
|
||||||
c, _ := nnsReader(cmd)
|
c, _, _ := getRPCClient(cmd)
|
||||||
it, err := c.Tokens()
|
it, err := c.Tokens()
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get tokens: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get tokens: %w", err)
|
||||||
for toks, err := it.Next(10); err == nil && len(toks) > 0; toks, err = it.Next(10) {
|
for toks, err := it.Next(10); err == nil && len(toks) > 0; toks, err = it.Next(10) {
|
||||||
|
@ -40,7 +41,7 @@ func listTokens(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCnameRecord(c *client.ContractReader, token []byte) (string, error) {
|
func getCnameRecord(c *client.Contract, token []byte) (string, error) {
|
||||||
items, err := c.GetRecords(string(token), big.NewInt(int64(nns.CNAME)))
|
items, err := c.GetRecords(string(token), big.NewInt(int64(nns.CNAME)))
|
||||||
|
|
||||||
// GetRecords returns the error "not an array" if the domain does not contain records.
|
// GetRecords returns the error "not an array" if the domain does not contain records.
|
||||||
|
|
|
@ -30,7 +30,7 @@ func initUpdateCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSOA(cmd *cobra.Command, _ []string) {
|
func updateSOA(cmd *cobra.Command, _ []string) {
|
||||||
c, actor := nnsWriter(cmd)
|
c, actor, _ := getRPCClient(cmd)
|
||||||
|
|
||||||
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
name, _ := cmd.Flags().GetString(nnsNameFlag)
|
||||||
email, _ := cmd.Flags().GetString(nnsEmailFlag)
|
email, _ := cmd.Flags().GetString(nnsEmailFlag)
|
||||||
|
|
|
@ -26,15 +26,13 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
|
||||||
_ = iota
|
_ = iota
|
||||||
internal
|
internal
|
||||||
aclDenied
|
aclDenied
|
||||||
apemanagerDenied
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
code int
|
code int
|
||||||
|
|
||||||
internalErr = new(sdkstatus.ServerInternal)
|
internalErr = new(sdkstatus.ServerInternal)
|
||||||
accessErr = new(sdkstatus.ObjectAccessDenied)
|
accessErr = new(sdkstatus.ObjectAccessDenied)
|
||||||
apemanagerErr = new(sdkstatus.APEManagerAccessDenied)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
@ -43,9 +41,6 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
|
||||||
case errors.As(err, &accessErr):
|
case errors.As(err, &accessErr):
|
||||||
code = aclDenied
|
code = aclDenied
|
||||||
err = fmt.Errorf("%w: %s", err, accessErr.Reason())
|
err = fmt.Errorf("%w: %s", err, accessErr.Reason())
|
||||||
case errors.As(err, &apemanagerErr):
|
|
||||||
code = apemanagerDenied
|
|
||||||
err = fmt.Errorf("%w: %s", err, apemanagerErr.Reason())
|
|
||||||
default:
|
default:
|
||||||
code = internal
|
code = internal
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.22
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.17.1
|
code.gitea.io/sdk/gitea v0.17.1
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.0-rc.4
|
git.frostfs.info/TrueCloudLab/frostfs-contract v0.20.0
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d
|
git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20241112082307-f17779933e88
|
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20241112082307-f17779933e88
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
Loading…
Reference in a new issue