-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
ignite network request remove-account
(#2999)
* implement * changelog * rename variabel * rename variabel * Update ignite/cmd/network_request.go Co-authored-by: Lucas Bertrand <[email protected]> Co-authored-by: Lucas Bertrand <[email protected]>
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package ignitecmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/ignite/cli/ignite/pkg/cliui" | ||
"github.com/ignite/cli/ignite/pkg/cosmosutil" | ||
"github.com/ignite/cli/ignite/services/network" | ||
"github.com/ignite/cli/ignite/services/network/networktypes" | ||
) | ||
|
||
// NewNetworkRequestRemoveAccount creates a new command to send remove account request | ||
func NewNetworkRequestRemoveAccount() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "remove-account [launch-id] [address]", | ||
Short: "Send request to remove account", | ||
RunE: networkRequestRemoveAccountHandler, | ||
Args: cobra.ExactArgs(2), | ||
} | ||
|
||
flagSetClearCache(c) | ||
c.Flags().AddFlagSet(flagNetworkFrom()) | ||
c.Flags().AddFlagSet(flagSetHome()) | ||
c.Flags().AddFlagSet(flagSetKeyringBackend()) | ||
c.Flags().AddFlagSet(flagSetKeyringDir()) | ||
return c | ||
} | ||
|
||
func networkRequestRemoveAccountHandler(cmd *cobra.Command, args []string) error { | ||
session := cliui.New(cliui.StartSpinner()) | ||
defer session.End() | ||
|
||
nb, err := newNetworkBuilder(cmd, CollectEvents(session.EventBus())) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// parse launch ID | ||
launchID, err := network.ParseID(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// get the address for the account and change the prefix for Ignite Chain | ||
address, err := cosmosutil.ChangeAddressPrefix(args[1], networktypes.SPN) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
n, err := nb.Network() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return n.SendAccountRemoveRequest( | ||
cmd.Context(), | ||
launchID, | ||
address, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters