From 24d6be19a6072c37aa95452edb5257fb1fe02a03 Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 10:01:24 +0200 Subject: [PATCH 1/6] fix: Optimise ts-client generation --- ignite/pkg/cosmosgen/generate_openapi.go | 17 +++++++++++++---- .../programs/swagger-combine/swagger-combine.go | 9 +-------- ignite/templates/app/files/go.mod.plush | 2 +- .../templates/app/files/proto/buf.gen.sta.yaml | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ignite/pkg/cosmosgen/generate_openapi.go b/ignite/pkg/cosmosgen/generate_openapi.go index f4897d5472..84623e6b68 100644 --- a/ignite/pkg/cosmosgen/generate_openapi.go +++ b/ignite/pkg/cosmosgen/generate_openapi.go @@ -12,6 +12,7 @@ import ( "github.com/ignite/cli/ignite/pkg/cache" "github.com/ignite/cli/ignite/pkg/cosmosanalysis/module" "github.com/ignite/cli/ignite/pkg/dirchange" + "github.com/ignite/cli/ignite/pkg/nodetime" swaggercombine "github.com/ignite/cli/ignite/pkg/nodetime/programs/swagger-combine" "github.com/ignite/cli/ignite/pkg/xos" ) @@ -39,7 +40,11 @@ func (g *generator) generateOpenAPISpec() error { }, } ) - + command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) + if err != nil { + return err + } + defer cleanup() defer func() { for _, dir := range specDirs { os.RemoveAll(dir) @@ -157,7 +162,7 @@ func (g *generator) generateOpenAPISpec() error { } // combine specs into one and save to out. - if err := swaggercombine.Combine(g.ctx, conf, out); err != nil { + if err := swaggercombine.Combine(g.ctx, conf, command, out); err != nil { return err } @@ -174,6 +179,11 @@ func (g *generator) generateModuleOpenAPISpec(m module.Module, out string) error }, } ) + command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) + if err != nil { + return err + } + defer cleanup() defer func() { for _, dir := range specDirs { @@ -242,7 +252,6 @@ func (g *generator) generateModuleOpenAPISpec(m module.Module, out string) error if err := os.MkdirAll(outDir, 0o766); err != nil { return err } - // combine specs into one and save to out. - return swaggercombine.Combine(g.ctx, conf, out) + return swaggercombine.Combine(g.ctx, conf, command, out) } diff --git a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go b/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go index a1ec01ede4..2b0c3da375 100644 --- a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go +++ b/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go @@ -8,7 +8,6 @@ import ( "regexp" "github.com/ignite/cli/ignite/pkg/cmdrunner/exec" - "github.com/ignite/cli/ignite/pkg/nodetime" ) // Config represent swagger-combine config. @@ -81,13 +80,7 @@ func (c *Config) AddSpec(id, path string, makeUnique bool) error { // Combine combines openapi specs into one and saves to out path. // specs is a spec id-fs path pair. -func Combine(ctx context.Context, c Config, out string) error { - command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) - if err != nil { - return err - } - defer cleanup() - +func Combine(ctx context.Context, c Config, command []string, out string) error { f, err := os.CreateTemp("", "*.json") if err != nil { return err diff --git a/ignite/templates/app/files/go.mod.plush b/ignite/templates/app/files/go.mod.plush index 578f6def14..6dab72199d 100644 --- a/ignite/templates/app/files/go.mod.plush +++ b/ignite/templates/app/files/go.mod.plush @@ -18,7 +18,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 diff --git a/ignite/templates/app/files/proto/buf.gen.sta.yaml b/ignite/templates/app/files/proto/buf.gen.sta.yaml index d8cea8b342..4444f5e75c 100644 --- a/ignite/templates/app/files/proto/buf.gen.sta.yaml +++ b/ignite/templates/app/files/proto/buf.gen.sta.yaml @@ -10,5 +10,6 @@ plugins: opt: - logtostderr=true - openapi_naming_strategy=simple + - ignore_comments=true - simple_operation_ids=false - json_names_for_fields=false From 6e5bd1c5a12507be2cc23c668557bc64a345e217 Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 11:04:29 +0200 Subject: [PATCH 2/6] chore: Update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 3c6ba3b648..e66c21b220 100644 --- a/changelog.md +++ b/changelog.md @@ -36,6 +36,7 @@ - [#3655](https://github.com/ignite/cli/pull/3655) Re-enable TS client generation - [#3661](https://github.com/ignite/cli/pull/3661) Change `pkg/cosmosanalysis` to find Cosmos SDK runtime app registered modules - [#3716](https://github.com/ignite/cli/pull/3716) Fix invalid plugin hook check +- [#3725](https://github.com/ignite/cli/pull/3725) Fix flaky TS client generation issues on linux ## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0) From aa3e256ad6df66bc8d7d7d276ee6834e2b651e7c Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 13:10:20 +0200 Subject: [PATCH 3/6] chore: Bump cosmjs to 0.31.1 --- .../cosmosgen/templates/module/module.ts.tpl | 5 ++--- .../pkg/cosmosgen/templates/root/client.ts.tpl | 5 ++--- .../cosmosgen/templates/root/package.json.tpl | 17 +++++++++-------- .../cosmosgen/templates/root/tsconfig.json.tpl | 1 + 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ignite/pkg/cosmosgen/templates/module/module.ts.tpl b/ignite/pkg/cosmosgen/templates/module/module.ts.tpl index ed30d21601..4797df2b06 100644 --- a/ignite/pkg/cosmosgen/templates/module/module.ts.tpl +++ b/ignite/pkg/cosmosgen/templates/module/module.ts.tpl @@ -1,7 +1,6 @@ // Generated by Ignite ignite.com/cli -import { StdFee } from "@cosmjs/launchpad"; -import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { SigningStargateClient, DeliverTxResponse, StdFee } from "@cosmjs/stargate"; import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; import { msgTypes } from './registry'; import { IgniteClient } from "../client" @@ -60,7 +59,7 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht } try { const { address } = (await signer.getAccounts())[0]; - const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry}); let msg = this.{{ camelCase .Name }}({ value: {{ .Name }}.fromPartial(value) }) return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) } catch (e: any) { diff --git a/ignite/pkg/cosmosgen/templates/root/client.ts.tpl b/ignite/pkg/cosmosgen/templates/root/client.ts.tpl index fe54755d5a..a7b30495b6 100644 --- a/ignite/pkg/cosmosgen/templates/root/client.ts.tpl +++ b/ignite/pkg/cosmosgen/templates/root/client.ts.tpl @@ -5,8 +5,7 @@ import { EncodeObject, Registry, } from "@cosmjs/proto-signing"; -import { StdFee } from "@cosmjs/launchpad"; -import { SigningStargateClient } from "@cosmjs/stargate"; +import { SigningStargateClient, StdFee } from "@cosmjs/stargate"; import { Env } from "./env"; import { UnionToIntersection, Return, Constructor } from "./helpers"; import { Module } from "./modules"; @@ -42,7 +41,7 @@ export class IgniteClient extends EventEmitter { async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) { if (this.signer) { const { address } = (await this.signer.getAccounts())[0]; - const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, { registry: new Registry(this.registry), prefix: this.env.prefix }); + const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, { registry: new Registry(this.registry) }); return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo) } else { throw new Error(" Signer is not present."); diff --git a/ignite/pkg/cosmosgen/templates/root/package.json.tpl b/ignite/pkg/cosmosgen/templates/root/package.json.tpl index fbf415d830..b0babc1b29 100644 --- a/ignite/pkg/cosmosgen/templates/root/package.json.tpl +++ b/ignite/pkg/cosmosgen/templates/root/package.json.tpl @@ -10,23 +10,24 @@ "url": "http://www.apache.org/licenses/LICENSE-2.0" } ], - "main": "index.ts", + "main": "lib/index.js", "publishConfig": { "access": "public" }, - "dependencies": { - "@cosmjs/launchpad": "0.27.0", - "@cosmjs/proto-signing": "0.27.0", - "@cosmjs/stargate": "0.27.0", + "scripts": { + "build": "NODE_OPTIONS='--max-old-space-size=16384' tsc" + }, + "dependencies": { + "@cosmjs/proto-signing": "0.31.1", + "@cosmjs/stargate": "0.31.1", "@keplr-wallet/types": "^0.11.3", "axios": "0.21.4", "buffer": "^6.0.3", "events": "^3.3.0" }, "peerDependencies": { - "@cosmjs/launchpad": "0.27.0", - "@cosmjs/proto-signing": "0.27.0", - "@cosmjs/stargate": "0.27.0" + "@cosmjs/proto-signing": "0.31.1", + "@cosmjs/stargate": "0.31.1" }, "devDependencies": { "@types/events": "^3.0.0", diff --git a/ignite/pkg/cosmosgen/templates/root/tsconfig.json.tpl b/ignite/pkg/cosmosgen/templates/root/tsconfig.json.tpl index 5e4ca71186..9f65e2249e 100644 --- a/ignite/pkg/cosmosgen/templates/root/tsconfig.json.tpl +++ b/ignite/pkg/cosmosgen/templates/root/tsconfig.json.tpl @@ -4,6 +4,7 @@ "module": "ES2020", "moduleResolution": "node", "outDir": "./lib", + "declaration": true, "allowSyntheticDefaultImports": true, "esModuleInterop": false, "strict": false, From a593486159eb5537d7894b581d7237074c36207a Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 13:12:48 +0200 Subject: [PATCH 4/6] chore: Update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index e66c21b220..32c4cb2168 100644 --- a/changelog.md +++ b/changelog.md @@ -37,6 +37,7 @@ - [#3661](https://github.com/ignite/cli/pull/3661) Change `pkg/cosmosanalysis` to find Cosmos SDK runtime app registered modules - [#3716](https://github.com/ignite/cli/pull/3716) Fix invalid plugin hook check - [#3725](https://github.com/ignite/cli/pull/3725) Fix flaky TS client generation issues on linux +- [#3726](https://github.com/ignite/cli/pull/3726) Update TS client dependencies. Bump vue/react template versions ## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0) From 6945648fa13198d52fc7cd7df90f37cf13757e63 Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 14:12:33 +0200 Subject: [PATCH 5/6] chore: bump templates to 0.5.1 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7481359fae..388b80d1cb 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/iancoleman/strcase v0.2.0 github.com/ignite/ignite-files/nodetime v0.0.2 github.com/ignite/ignite-files/protoc v0.0.1 - github.com/ignite/web v0.4.3 + github.com/ignite/web v0.5.1 github.com/imdario/mergo v0.3.15 github.com/jpillora/chisel v1.8.1 github.com/lib/pq v1.10.9 diff --git a/go.sum b/go.sum index 624e6325ba..97179bf296 100644 --- a/go.sum +++ b/go.sum @@ -769,8 +769,8 @@ github.com/ignite/ignite-files/nodetime v0.0.2 h1:9Aj0OEa7FWI22J/Zdq7M2JvsjgFLng github.com/ignite/ignite-files/nodetime v0.0.2/go.mod h1:GKDsXdeazHyhSBPdVLp7mNIo/m9LmZ6/h8RmQ0/CoaM= github.com/ignite/ignite-files/protoc v0.0.1 h1:wXxU1dzruUgSVl1diAuAOA+xv0NQKXJFsDWht2+tAP8= github.com/ignite/ignite-files/protoc v0.0.1/go.mod h1:cVCHJbEHPIeKHMPk3ZoPS0Xw4XQfUc76BAMAPU9Fwjg= -github.com/ignite/web v0.4.3 h1:LHucUEXttzCf5JmxO5/xLKVx1Qz1o124HqF4Nii5uWQ= -github.com/ignite/web v0.4.3/go.mod h1:WZWBaBYF8RazN7dE462BLpvXDY8ScacxcJ07BKwX/jY= +github.com/ignite/web v0.5.1 h1:xGOt8wJG7WIrNO30e8Zbm669VFyo6sje/vWnusLPp6k= +github.com/ignite/web v0.5.1/go.mod h1:WZWBaBYF8RazN7dE462BLpvXDY8ScacxcJ07BKwX/jY= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= From 556631c39c1beda9049d0c16abf922b3d0fd1dc3 Mon Sep 17 00:00:00 2001 From: Clockwork Date: Thu, 2 Nov 2023 14:14:14 +0200 Subject: [PATCH 6/6] fix: main module is now js so we must build after installing --- ignite/pkg/cosmosgen/templates/root/package.json.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ignite/pkg/cosmosgen/templates/root/package.json.tpl b/ignite/pkg/cosmosgen/templates/root/package.json.tpl index b0babc1b29..8cd8cdea6b 100644 --- a/ignite/pkg/cosmosgen/templates/root/package.json.tpl +++ b/ignite/pkg/cosmosgen/templates/root/package.json.tpl @@ -15,7 +15,8 @@ "access": "public" }, "scripts": { - "build": "NODE_OPTIONS='--max-old-space-size=16384' tsc" + "build": "NODE_OPTIONS='--max-old-space-size=16384' tsc", + "postinstall": "npm run build" }, "dependencies": { "@cosmjs/proto-signing": "0.31.1",