[#1301] adm/morph: Add 'delete' domains
Some checks failed
Tests and linters / Tests with -race (pull_request) Failing after 41s
DCO action / DCO (pull_request) Successful in 50s
Vulncheck / Vulncheck (pull_request) Failing after 52s
Tests and linters / Tests (pull_request) Failing after 1m24s
Tests and linters / Run gofumpt (pull_request) Successful in 1m23s
Pre-commit hooks / Pre-commit (pull_request) Failing after 1m35s
Build / Build Components (pull_request) Successful in 1m51s
Tests and linters / Lint (pull_request) Failing after 1m53s
Tests and linters / Staticcheck (pull_request) Successful in 1m51s
Tests and linters / gopls check (pull_request) Successful in 4m42s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-09-18 14:16:57 +03:00
parent 94ee5f7c2a
commit f8fea4f994
2 changed files with 30 additions and 0 deletions

View file

@ -42,3 +42,23 @@ func registerDomain(cmd *cobra.Command, _ []string) {
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")
}

View file

@ -42,6 +42,15 @@ var (
},
Run: registerDomain,
}
deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete a domain by name",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
},
Run: deleteDomain,
}
renewCmd = &cobra.Command{
Use: "renew",
Short: "Increases domain expiration date",
@ -91,6 +100,7 @@ var (
func init() {
initTokensCmd()
initRegisterCmd()
initDeleteCmd()
initRenewCmd()
initUpdateCmd()
initAddRecordCmd()