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 000000000..a542e112d --- /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 33b6bffcf..62db4fb42 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 5816eac6b..42cc6f965 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)