Skip to content

Commit

Permalink
fix: correct TS code generation to generate paginated fields (#3808)
Browse files Browse the repository at this point in the history
* fix: correct TS code generation to generate paginated fields

* chore: update changelog
  • Loading branch information
jeronimoalbi authored Dec 5, 2023
1 parent 296e226 commit 9aa965c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -790,4 +791,4 @@ Our new name is **Ignite CLI**!

## `v0.0.9`

Initial release.
Initial release.
19 changes: 12 additions & 7 deletions ignite/pkg/cosmosanalysis/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
Expand Down

0 comments on commit 9aa965c

Please sign in to comment.