diff --git a/starport/cmd/account.go b/starport/cmd/account.go index 8dae42a423..3cedd9542c 100644 --- a/starport/cmd/account.go +++ b/starport/cmd/account.go @@ -116,15 +116,3 @@ func getPassphrase(cmd *cobra.Command) (string, error) { return pass, nil } - -func checkAccountExist(cmd *cobra.Command, name string) error { - ca, err := cosmosaccount.New( - cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)), - ) - if err != nil { - return err - } - - _, err = ca.GetByName(name) - return err -} diff --git a/starport/cmd/network.go b/starport/cmd/network.go index 6b4b5b7620..dec73fe58f 100644 --- a/starport/cmd/network.go +++ b/starport/cmd/network.go @@ -72,10 +72,10 @@ var cosmos *cosmosclient.Client // initializeNetwork initializes event bus, CLIn components such as spinner and returns a new network builder func initializeNetwork(cmd *cobra.Command) ( - *network.Builder, - *clispinner.Spinner, - func(), - error, + nb *network.Builder, + spinner *clispinner.Spinner, + cleanup func(), + err error, ) { var ( wg sync.WaitGroup @@ -91,7 +91,7 @@ func initializeNetwork(cmd *cobra.Command) ( wg.Wait() } - nb, err := newNetwork(cmd, network.CollectEvents(ev)) + nb, err = newNetwork(cmd, network.CollectEvents(ev)) if err != nil { shutdown() } diff --git a/starport/cmd/network_chain_init.go b/starport/cmd/network_chain_init.go index 93fbcec17e..46df6afc06 100644 --- a/starport/cmd/network_chain_init.go +++ b/starport/cmd/network_chain_init.go @@ -54,7 +54,8 @@ func networkChainInitHandler(cmd *cobra.Command, args []string) error { // check if the provided account for the validator exists validatorAccount, _ := cmd.Flags().GetString(flagValidatorAccount) - if err := checkAccountExist(cmd, validatorAccount); err != nil { + _, err = nb.AccountRegistry().GetByName(validatorAccount) + if err != nil { return err } diff --git a/starport/services/network/network.go b/starport/services/network/network.go index f439d4aa20..c9f9ea61ff 100644 --- a/starport/services/network/network.go +++ b/starport/services/network/network.go @@ -123,6 +123,11 @@ func InitializationKeyringBackend(keyringBackend chaincmd.KeyringBackend) InitOp } } +// AccountRegistry returns the account registry used by the network builder +func (b Builder) AccountRegistry() cosmosaccount.Registry { + return b.cosmos.AccountRegistry +} + // Blockchain initializes a blockchain from source and options. func (b *Builder) Blockchain(ctx context.Context, source SourceOption, options ...InitOption) (*Blockchain, error) { var o initOptions