Some checks failed
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
Build & Push SDK Proto Builder / build (push) Has been cancelled
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package keys
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
)
|
|
|
|
const flagListNames = "list-names"
|
|
|
|
// ListKeysCmd lists all keys in the key store.
|
|
func ListKeysCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all keys",
|
|
Long: `Return a list of all public keys stored by this key manager
|
|
along with their associated name and address.`,
|
|
RunE: runListCmd,
|
|
}
|
|
|
|
cmd.Flags().BoolP(flagListNames, "n", false, "List names only")
|
|
return cmd
|
|
}
|
|
|
|
func runListCmd(cmd *cobra.Command, _ []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
records, err := clientCtx.Keyring.List()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(records) == 0 && clientCtx.OutputFormat == flags.OutputFormatText {
|
|
cmd.Println("No records were found in keyring")
|
|
return nil
|
|
}
|
|
|
|
if ok, _ := cmd.Flags().GetBool(flagListNames); !ok {
|
|
return printKeyringRecords(cmd.OutOrStdout(), records, clientCtx.OutputFormat)
|
|
}
|
|
|
|
for _, k := range records {
|
|
cmd.Println(k.Name)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ListKeyTypesCmd lists all key types.
|
|
func ListKeyTypesCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "list-key-types",
|
|
Short: "List all key types",
|
|
Long: `Return a list of all supported key types (also known as algos)`,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Println("Supported key types/algos:")
|
|
keyring, _ := clientCtx.Keyring.SupportedAlgorithms()
|
|
cmd.Printf("%+q\n", keyring)
|
|
return nil
|
|
},
|
|
}
|
|
}
|