package nns import ( "math/big" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" "github.com/spf13/cobra" ) func initRegisterCmd() { Cmd.AddCommand(registerCmd) registerCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc) registerCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc) registerCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) registerCmd.Flags().String(nnsEmailFlag, constants.FrostfsOpsEmail, "Domain owner email") registerCmd.Flags().Int64(nnsRefreshFlag, constants.NNSRefreshDefVal, "SOA record REFRESH parameter") registerCmd.Flags().Int64(nnsRetryFlag, constants.NNSRetryDefVal, "SOA record RETRY parameter") registerCmd.Flags().Int64(nnsExpireFlag, int64(constants.DefaultExpirationTime), "SOA record EXPIRE parameter") registerCmd.Flags().Int64(nnsTTLFlag, constants.NNSTtlDefVal, "SOA record TTL parameter") _ = cobra.MarkFlagRequired(registerCmd.Flags(), nnsNameFlag) } func registerDomain(cmd *cobra.Command, _ []string) { c, actor := getRPCClient(cmd) name, _ := cmd.Flags().GetString(nnsNameFlag) email, _ := cmd.Flags().GetString(nnsEmailFlag) refresh, _ := cmd.Flags().GetInt64(nnsRefreshFlag) retry, _ := cmd.Flags().GetInt64(nnsRetryFlag) expire, _ := cmd.Flags().GetInt64(nnsExpireFlag) ttl, _ := cmd.Flags().GetInt64(nnsTTLFlag) h, vub, err := c.Register(name, actor.Sender(), email, big.NewInt(refresh), big.NewInt(retry), big.NewInt(expire), big.NewInt(ttl)) commonCmd.ExitOnErr(cmd, "unable to register domain: %w", err) cmd.Println("Waiting for transaction to persist...") _, err = actor.Wait(h, vub, err) commonCmd.ExitOnErr(cmd, "register domain error: %w", err) cmd.Println("Domain registered successfully") } func initDeleteCmd() { Cmd.AddCommand(deleteCmd) deleteCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc) deleteCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc) deleteCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) _ = cobra.MarkFlagRequired(deleteCmd.Flags(), nnsNameFlag) } func deleteDomain(cmd *cobra.Command, _ []string) { c, actor := getRPCClient(cmd) name, _ := cmd.Flags().GetString(nnsNameFlag) h, vub, err := c.DeleteDomain(name) _, err = actor.Wait(h, vub, err) commonCmd.ExitOnErr(cmd, "delete domain error: %w", err) cmd.Println("Domain deleted successfully") }