From f6b6290e182dbc9d8d6bb3ffffcc90203c7b41af Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Thu, 24 Oct 2024 10:41:42 -0600 Subject: [PATCH] Fix the `query metadata recordspec` command when given a rec-spec-id. (#2197) * [2148]: Fix the query metadata recordspec command to correctly use the RecordSpecification query (instead of RecordSpecificationsForContractSpecification) when provided a record specification id. * [2148]: Add changelog entry. --- .../unreleased/bug-fixes/2148-fix-recordspec-cli.md | 1 + x/metadata/client/cli/cli_test.go | 10 +++++++--- x/metadata/client/cli/query.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changelog/unreleased/bug-fixes/2148-fix-recordspec-cli.md diff --git a/.changelog/unreleased/bug-fixes/2148-fix-recordspec-cli.md b/.changelog/unreleased/bug-fixes/2148-fix-recordspec-cli.md new file mode 100644 index 0000000000..a542e112d2 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/2148-fix-recordspec-cli.md @@ -0,0 +1 @@ +* Fix the query metadata recordspec command to use the RecordSpecification query when provided a recspec id [#2148](https://github.com/provenance-io/provenance/issues/2148). diff --git a/x/metadata/client/cli/cli_test.go b/x/metadata/client/cli/cli_test.go index 33b6bffcf3..62db4fb42b 100644 --- a/x/metadata/client/cli/cli_test.go +++ b/x/metadata/client/cli/cli_test.go @@ -1471,9 +1471,13 @@ func (s *IntegrationCLITestSuite) TestGetMetadataRecordSpecCmd() { expOut: []string{indent(s.recordSpecAsText, 4)}, }, { - name: "rec spec id does not exist", - args: []string{"recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44"}, - expOut: []string{"record_specifications: []"}, + name: "rec spec id does not exist", + args: []string{"recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44"}, + expOut: []string{ + " contract_spec_addr: contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn", + " record_spec_addr: recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44", + " specification: null", + }, }, { name: "record specs from contract spec id as json", diff --git a/x/metadata/client/cli/query.go b/x/metadata/client/cli/query.go index 5816eac6ba..42cc6f9652 100644 --- a/x/metadata/client/cli/query.go +++ b/x/metadata/client/cli/query.go @@ -443,7 +443,7 @@ func GetMetadataRecordSpecCmd() *cobra.Command { if len(args) > 1 { name = trimSpaceAndJoin(args[1:], " ") } - if len(name) == 0 { + if len(name) == 0 && !strings.HasPrefix(strings.ToLower(arg0), types.PrefixRecordSpecification) { return outputRecordSpecsForContractSpec(cmd, arg0) } return outputRecordSpec(cmd, arg0, name)