From 9aa965c24489125a6fb10cbf68514fc930af8eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20Albi?= Date: Tue, 5 Dec 2023 13:02:12 +0100 Subject: [PATCH] fix: correct TS code generation to generate paginated fields (#3808) * fix: correct TS code generation to generate paginated fields * chore: update changelog --- changelog.md | 3 ++- ignite/pkg/cosmosanalysis/module/module.go | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 5da32152a6..f288295562 100644 --- a/changelog.md +++ b/changelog.md @@ -55,6 +55,7 @@ - [#3728](https://github.com/ignite/cli/pull/3728) Fix wrong parser for proto package names - [#3729](https://github.com/ignite/cli/pull/3729) Fix broken generator due to caching /tmp include folders - [#3767](https://github.com/ignite/cli/pull/3767) Fix `v0.50` ibc genesis issue +- [#3808](https://github.com/ignite/cli/pull/3808) Correct TS code generation to generate paginated fields ## [`v0.27.2`](https://github.com/ignite/cli/releases/tag/v0.27.2) @@ -790,4 +791,4 @@ Our new name is **Ignite CLI**! ## `v0.0.9` -Initial release. \ No newline at end of file +Initial release. diff --git a/ignite/pkg/cosmosanalysis/module/module.go b/ignite/pkg/cosmosanalysis/module/module.go index cdfe90e9d6..55514d6970 100644 --- a/ignite/pkg/cosmosanalysis/module/module.go +++ b/ignite/pkg/cosmosanalysis/module/module.go @@ -257,7 +257,6 @@ func (d *moduleDiscoverer) discover(pkg protoanalysis.Package) (Module, error) { Pkg: pkg, } - // fill sdk Msgs. for _, msg := range msgs { pkgmsg, err := pkg.MessageByName(msg) if err != nil { @@ -290,13 +289,8 @@ func (d *moduleDiscoverer) discover(pkg protoanalysis.Package) (Module, error) { // do not use if used as a request/return type of RPC. for _, s := range pkg.Services { - for i, q := range s.RPCFuncs { + for _, q := range s.RPCFuncs { if q.RequestType == protomsg.Name || q.ReturnsType == protomsg.Name { - // Check if the service response message is using pagination and - // update the RPC function. This is done here to avoid extra loops - // just to update the pagination property. - s.RPCFuncs[i].Paginated = hasPagination(protomsg) - return false } } @@ -307,6 +301,17 @@ func (d *moduleDiscoverer) discover(pkg protoanalysis.Package) (Module, error) { // fill types. for _, protomsg := range pkg.Messages { + // Update pagination for RPC functions when a service response uses pagination + if hasPagination(protomsg) { + for _, s := range pkg.Services { + for i, q := range s.RPCFuncs { + if q.RequestType == protomsg.Name || q.ReturnsType == protomsg.Name { + s.RPCFuncs[i].Paginated = true + } + } + } + } + if !isType(protomsg) { continue }