Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetByAddr and smaller metadata queries. #1614

Merged
merged 36 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a8110ba
[1443]: Update the protos. Add a GetByAddr query. Add include_id_info…
SpicyLemon Jun 30, 2023
6c296bf
[1443]: Create ParseMetadataAddressFromBech32 from MetadataAddressFro…
SpicyLemon Jul 3, 2023
b0f8a2a
[1443]: Implement the GetByAddr query.
SpicyLemon Jul 3, 2023
086ea9e
[1443]: Update the wrapper constructors to optionally include the id …
SpicyLemon Jul 3, 2023
a3f6148
[1443]: Pay attention to the new IncludeIdInfo flags added to a bunch…
SpicyLemon Jul 3, 2023
0bf75f5
[1443]: Add a flag for including the request in the results.
SpicyLemon Jul 3, 2023
00c7e1a
[1443]: Pay attention to the new IncludeRequest flags and fix some NP…
SpicyLemon Jul 3, 2023
379d489
[1443]: Retrofit the --include-request flag to be passed on in the re…
SpicyLemon Jul 3, 2023
f8b8b30
[1443]: Update the CLI stuff to handle the IncludeIdInfo flags. Refac…
SpicyLemon Jul 3, 2023
74e78c3
[1443]: Clean up, fix, and enhance the grpc query tests that started …
SpicyLemon Jul 3, 2023
53981a2
[1443]: Add omitempty to the GetByAddr response fields.
SpicyLemon Jul 3, 2023
4b5d7c1
[1443]: Use the command context instead of a fresh background one for…
SpicyLemon Jul 4, 2023
396ca1a
[1443]: Fix the get query tests since I changed it all up.
SpicyLemon Jul 4, 2023
87e6d6a
[1443]: Add a default case to the HRP switch in the new GetByAddr end…
SpicyLemon Jul 4, 2023
e406fce
[1443]: Double up the ParseMetadataAddressFromBech32 tests on Metadat…
SpicyLemon Jul 4, 2023
d16a618
[1443]: Add a maximum number of addresses that can be provided in a G…
SpicyLemon Jul 4, 2023
8732dde
[1443]: Add a changelog entry.
SpicyLemon Jul 4, 2023
7a4a30f
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Jul 6, 2023
e6f5447
[1443]: Get rid of the MaxGetByAddrAddrs variable and just let the pr…
SpicyLemon Jul 6, 2023
18a1842
[1443]: A couple unit test tweaks.
SpicyLemon Jul 6, 2023
439388d
[1443]: Update spec docs.
SpicyLemon Jul 7, 2023
299b368
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Jul 17, 2023
0cb70a9
[1443]: Add a note in the changelog about how to maintain current que…
SpicyLemon Jul 17, 2023
e9dfeb8
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Jul 17, 2023
249cbd2
[1443]: Change the include_id_info field to exclude_id_info in the pr…
SpicyLemon Jul 17, 2023
ebf524b
[1443]: Update the query server and fix tests to match new behavior.
SpicyLemon Jul 17, 2023
3b77d26
[1443]: Update the changelog to reflect new behavior.
SpicyLemon Jul 17, 2023
2995105
[1443]: Fix all the links in the spec to use the version with the exc…
SpicyLemon Jul 17, 2023
56dbc02
[1443]: Add a missing verb to a sentence in the spec docs.
SpicyLemon Jul 21, 2023
1cabfdc
[1443]: Tweak that wording again.
SpicyLemon Jul 21, 2023
251da3c
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Jul 31, 2023
e9e61b1
Merge branch 'main' into dwedul/1443-simpler-md-queries
iramiller Aug 1, 2023
83ae897
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Aug 2, 2023
25d6e75
Merge branch 'main' into dwedul/1443-simpler-md-queries
SpicyLemon Aug 7, 2023
de8da4a
Merge branch 'main' into dwedul/1443-simpler-md-queries
iramiller Aug 11, 2023
7238001
Merge branch 'main' into dwedul/1443-simpler-md-queries
iramiller Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,29 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

### Features

* New `GetByAddr` metadata query [#1443](https://github.com/provenance-io/provenance/issues/1443).

### Improvements

* Update ibcnet ports so they don't conflict with host machine. [#1622](https://github.com/provenance-io/provenance/issues/1622)
* Replace custom ibc-go v6.1.1 fork with official module. [#1616](https://github.com/provenance-io/provenance/issues/1616)
* Updated metadata queries to optionally include the request and id info [#1443](https://github.com/provenance-io/provenance/issues/1443).

### Bug Fixes

* Fix ibcnet relayer creating multiple connections on restart [#1620](https://github.com/provenance-io/provenance/issues/1620).

### Client Breaking

* Metadata queries no longer include the request and id info by default [#1443](https://github.com/provenance-io/provenance/issues/1443).
* The `provenanced query metadata get` command has been changed to use the new `GetByAddr` query [#1443](https://github.com/provenance-io/provenance/issues/1443).
The command can now take in multiple ids.
The output of this command reflects the `GetByAddrResponse` instead of specific type queries.
The command no longer has any `--include-<thing>` flags since they don't pertain to the `GetByAddr` query.
The specific queries (e.g. `provenanced query metadata scope`) are still available with all appropriate flags.

---

## [v1.16.0](https://github.com/provenance-io/provenance/releases/tag/v1.16.0) - 2023-06-23
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

3,993 changes: 3,383 additions & 610 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

99 changes: 90 additions & 9 deletions docs/proto-docs.md

Large diffs are not rendered by default.

144 changes: 130 additions & 14 deletions proto/provenance/metadata/v1/query.proto

Large diffs are not rendered by default.

60 changes: 43 additions & 17 deletions x/metadata/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func ownerPartyList(addresses ...string) []metadatatypes.Party {
return retval
}

// indent breaks the str into lines and adds the desired number of spaces at the start of each line.
func indent(str string, spaces int) string {
var sb strings.Builder
lines := strings.Split(str, "\n")
Expand All @@ -536,6 +537,27 @@ func indent(str string, spaces int) string {
return sb.String()
}

// entryIndent is similar to indent except the very first line will include the - that a yaml entry would have.
// Panics if spaces < 2.
func entryIndent(str string, spaces int) string {
var sb strings.Builder
lines := strings.Split(str, "\n")
maxI := len(lines) - 1
s := strings.Repeat(" ", spaces)
for i, l := range lines {
if i == 0 {
sb.WriteString(strings.Repeat(" ", spaces-2) + "- ")
} else {
sb.WriteString(s)
}
sb.WriteString(l)
if i != maxI {
sb.WriteString("\n")
}
}
return sb.String()
}

func yamlListEntry(str string) string {
var sb strings.Builder
lines := strings.Split(str, "\n")
Expand Down Expand Up @@ -621,7 +643,11 @@ func runQueryCmdTestCases(s *IntegrationCLITestSuite, cmdGen func() *cobra.Comma
require.NoErrorf(t, err, "%s error", cmdName)
}
for _, exp := range tc.expOut {
assert.Contains(t, outStr, exp, "%s command output", cmdName)
if !assert.Contains(t, outStr, exp, "%s command output", cmdName) {
// The expected entry is easily lost in the failure message, so log it now too.
// Logging it instead of putting it in the assertion message so it lines up with the deferrable.
t.Logf("Not Found:\n%s", exp)
}
}
})
}
Expand Down Expand Up @@ -649,7 +675,7 @@ func (s *IntegrationCLITestSuite) TestGetMetadataParamsCmd() {
{
name: "get params as json output including request",
args: []string{s.asJson, s.includeRequest},
expOut: []string{"\"params\":{}", "\"request\":{}"},
expOut: []string{"\"params\":{}", "\"request\":{\"include_request\":true}"},
},
{
name: "get locator params as json",
Expand All @@ -659,7 +685,7 @@ func (s *IntegrationCLITestSuite) TestGetMetadataParamsCmd() {
{
name: "get locator params as text including request",
args: []string{"locator", s.asText, s.includeRequest},
expOut: []string{"params:", "max_uri_length: 2048", "request: {}"},
expOut: []string{"params:", "max_uri_length: 2048", "request:", "include_request: true"},
},
}

Expand All @@ -678,12 +704,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - scope id as text",
args: []string{s.scopeID.String(), s.asText},
expOut: []string{indent(s.scopeAsText, 4)},
expOut: []string{entryIndent(s.scopeAsText, 2)},
},
{
name: "get metadata by id - scope id does not exist",
args: []string{"scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel"},
expOut: []string{"scope: null", "scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel"},
expOut: []string{"not_found:\n- scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel"},
},
{
name: "get metadata by id - session id as json",
Expand All @@ -693,12 +719,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - session id as text",
args: []string{s.sessionID.String(), s.asText},
expOut: []string{indent(s.sessionAsText, 4)},
expOut: []string{entryIndent(s.sessionAsText, 2)},
},
{
name: "get metadata by id - session id does not exist",
args: []string{"session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr"},
expOut: []string{"session: null", "session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr"},
expOut: []string{"not_found:\n- session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr"},
},
{
name: "get metadata by id - record id as json",
Expand All @@ -708,12 +734,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - record id as text",
args: []string{s.recordID.String(), s.asText},
expOut: []string{indent(s.recordAsText, 4)},
expOut: []string{entryIndent(s.recordAsText, 2)},
},
{
name: "get metadata by id - record id does not exist",
args: []string{"record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3"},
expOut: []string{"record: null", "record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3"},
expOut: []string{"not_found:\n- record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3"},
},
{
name: "get metadata by id - scope spec id as json",
Expand All @@ -723,12 +749,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - scope spec id as text",
args: []string{s.scopeSpecID.String(), s.asText},
expOut: []string{indent(s.scopeSpecAsText, 4)},
expOut: []string{entryIndent(s.scopeSpecAsText, 2)},
},
{
name: "get metadata by id - scope spec id does not exist",
args: []string{"scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m"},
expOut: []string{"specification: null", "scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m"},
expOut: []string{"not_found:\n- scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m"},
},
{
name: "get metadata by id - contract spec id as json",
Expand All @@ -738,12 +764,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - contract spec id as text",
args: []string{s.contractSpecID.String(), s.asText},
expOut: []string{indent(s.contractSpecAsText, 4)},
expOut: []string{entryIndent(s.contractSpecAsText, 2)},
},
{
name: "get metadata by id - contract spec id does not exist",
args: []string{"contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn"},
expOut: []string{"specification: null", "contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn"},
expOut: []string{"not_found:\n- contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn"},
},
{
name: "get metadata by id - record spec id as json",
Expand All @@ -753,12 +779,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - record spec id as text",
args: []string{s.recordSpecID.String(), s.asText},
expOut: []string{indent(s.recordSpecAsText, 4)},
expOut: []string{entryIndent(s.recordSpecAsText, 2)},
},
{
name: "get metadata by id - record spec id does not exist",
args: []string{"recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44"},
expOut: []string{"specification: null", "recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44"},
expOut: []string{"not_found:\n- recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44"},
},
{
name: "get metadata by id - bad prefix",
Expand All @@ -768,12 +794,12 @@ func (s *IntegrationCLITestSuite) TestGetMetadataByIDCmd() {
{
name: "get metadata by id - no args",
args: []string{},
expErr: "accepts 1 arg(s), received 0",
expErr: "requires at least 1 arg(s), only received 0",
},
{
name: "get metadata by id - two args",
args: []string{"scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel", "scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m"},
expErr: "accepts 1 arg(s), received 2",
expOut: []string{"not_found:\n- scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel\n- scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m"},
},
{
name: "get metadata by id - uuid",
Expand Down
Loading