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

fix: correct TS code generation to generate paginated fields #3808

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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