diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fe2bb20e1e1..36ef5ff3f75b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (cli) [#13207](https://github.com/cosmos/cosmos-sdk/pull/13207) Reduce user's password prompts when calling keyring `List()` function. * (cli) [#13353](https://github.com/cosmos/cosmos-sdk/pull/13353) Add `tx group draft-proposal` command for generating group proposal JSONs (skeleton). * (cli) [#13304](https://github.com/cosmos/cosmos-sdk/pull/13304) Add `tx gov draft-proposal` command for generating proposal JSONs (skeleton). * (x/authz) [#13047](https://github.com/cosmos/cosmos-sdk/pull/13047) Add a GetAuthorization function to the keeper. diff --git a/client/keys/list.go b/client/keys/list.go index f7ec267df233..2da7daba95b5 100644 --- a/client/keys/list.go +++ b/client/keys/list.go @@ -34,7 +34,7 @@ func runListCmd(cmd *cobra.Command, _ []string) error { return err } - if len(records) == 0 && clientCtx.OutputFormat == flags.OutputFormatText { + if len(records) == 0 { cmd.Println("No records were found in keyring") return nil } diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index c9c858ac0896..a0de3c1a4f4f 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -535,56 +535,8 @@ func wrapKeyNotFound(err error, msg string) error { return err } -func (ks keystore) List() ([]Info, error) { - res := []Info{} - - keys, err := ks.db.Keys() - if err != nil { - return nil, err - } - - if len(keys) == 0 { - return res, nil - } - - sort.Strings(keys) - for _, key := range keys { - if strings.HasSuffix(key, infoSuffix) { - rawInfo, err := ks.db.Get(key) - if err != nil { - fmt.Printf("err for key %s: %q\n", key, err) - - // add the name of the key in case the user wants to retrieve it - // afterwards - info := newOfflineInfo(key, nil, hd.PubKeyType("")) - res = append(res, info) - continue - } - - if len(rawInfo.Data) == 0 { - fmt.Println(sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, key)) - - // add the name of the key in case the user wants to retrieve it - // afterwards - info := newOfflineInfo(key, nil, hd.PubKeyType("")) - res = append(res, info) - continue - } - - info, err := unmarshalInfo(rawInfo.Data) - if err != nil { - fmt.Printf("err for key %s: %q\n", key, err) - - // add the name of the key in case the user wants to retrieve it - // afterwards - info = newOfflineInfo(key, nil, hd.PubKeyType("")) - } - - res = append(res, info) - } - } - - return res, nil +func (ks keystore) List() ([]*Record, error) { + return ks.MigrateAll() } func (ks keystore) NewMnemonic(uid string, language Language, hdPath, bip39Passphrase string, algo SignatureAlgo) (*Record, string, error) { @@ -959,6 +911,7 @@ func (ks keystore) MigrateAll() ([]*Record, error) { } sort.Strings(keys) + var recs []*Record for _, key := range keys { // The keyring items only with `.info` consists the key info.