Skip to content

Commit 88781ee

Browse files
ilgoozlumtisclockworkgr
authored
feat: codegen for frontend-X modules communication (#732)
* empty commit * feat: sdk msg discovery from app source (#734) * feat: sdk msg discovery from app source * `pkg/cosmosanalysis/msg.Discover()` discovers types that implements sdk.Msg. * added `pkg/protoanalysis` for proto file analysis. * fix linter * docs * docs Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * feat: add pkg/protobufjs (#744) * feat: add pkg/protobufjs protobufjs is made available for use as a Go pkg with the high level Generate() API. protobufjs binaries statically added to Starport's source code and they are instantly available. only the relavent protobufjs binary included to the final binary of Starport dependending on the OS. for Linux, it adds 17MB to the total binary size of Starport. * ci: enable lfs * fix lint * cleanup & docs * cleanup & an attempt to add ts defs for generated js * gitpod: install git-lfs * ci(pi): disable them temp because high LFS usage * rm pi files * gitpod: fix lfs * gitpod: fix lfs * gitpod: fix lfs * gitpod: fix lfs * docs: manual installation * gitpod: fix lfs * fix gitpod (#754) * fix(gitpod): drop lfs (#755) * fix(gitpod): drop lfs compress protobufjs binary manually instead of relying on go-bindata's. generated files now under 100MB. * tidy * cleanup * feat(pkg/cosmosanalysis): add more detailed msg info (#752) * feat(pkg/cosmosanalysis): add more detailed msg info most importantly, msg urls added to the analysis output. * docs Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * feat(nodetime): add sta pkg and refactor (#757) * feat(nodetime): add sta pkg and refactor a new pkg/ called nodetime added to host and use a single NodeJS runtime that has multiple CLIs bundled inside. * `swagger-typescript-api` CLI added alongside `protobufjs` CLI. * switched Starport's Go compiler to 1.16 beta to benefit from new the `embed` feature. it'll be switched to stable 1.16 release once it's available (likely this Feb). * fix integration tests * fix gitpod * feat: upgrade to stable Go 1.16 (#765) * fix: integration tests (#766) * feat: enable js proto generation (#751) * refactor(protoc): wrap protoc cmd as a pkg * enable js code generation for build & server out dir can be configured via `build.proto.js.out`. * generate js per module * change cosmosprotoc name to cosmosproto * docs * fix linter * chore(integration): disable parallel run to not bottleneck the CI * feat(codegen): generate rest client for js (#771) * feat(codegen): generate rest client for js * fix Go codegen * feat(codegen/ts-proto): generate app types with ts-proto (#795) * feat(codegen/ts-proto): generate app types with ts-proto previously, we were using `protobufjs` to generate app types. now, we have switched to `ts-proto` but also kept js support by placing `.js` and `.d.ts` files next to the generated `.ts` files. * refactored `nodetime` packaging. * added more detailed info to `pkg/cosmosanalysis/module.Discover()` output. * added more detailed info to `pkg/protoanalysis.DiscoverPackages()` output. * added plugin binary configurability option to `pkg/protoc` pkg. * improved `pkg/cosmosgen`'s public API. * added `pkg/nodetime/tsc`, `pkg/nodetime/ts-proto` and removed `pkg/nodetime/protobufjs`. * fix lint * fix err check * feat(codegen): generated js client (the wrapper) (#772) * feat(codegen): generate rest client for js * fix Go codegen * feat(codegen): generated js client (the wrapper) it wraps generated protobufjs types and rest client, uses cosmjs and exports high level `txClient()` and `queryClient()` funcs for: * creating messages, signing and broadcasting them, * querying. js client created individually for each module. within Vuex, it can be used like in below: ```js import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { txClient, queryClient } from "./store/tendermint/mars/mars/module"; async function main() { const wallet = await DirectSecp256k1HdWallet.fromMnemonic("alfa romeo..."); const t = await txClient(wallet); const q = await queryClient(); console.log(await t.signAndBroadcast([ t.msgCreateUser({ name: "mars", creator: wallet.address }) ])); console.log(await q.queryUserAll()); } main() ``` * fix(sta): sdk module name * docs * feat(codegen/ts-proto): generate app types with ts-proto previously, we were using `protobufjs` to generate app types. now, we have switched to `ts-proto` but also kept js support by placing `.js` and `.d.ts` files next to the generated `.ts` files. * refactored `nodetime` packaging. * added more detailed info to `pkg/cosmosanalysis/module.Discover()` output. * added more detailed info to `pkg/protoanalysis.DiscoverPackages()` output. * added plugin binary configurability option to `pkg/protoc` pkg. * improved `pkg/cosmosgen`'s public API. * added `pkg/nodetime/tsc`, `pkg/nodetime/ts-proto` and removed `pkg/nodetime/protobufjs`. * fix lint * fix err check * migrate wrapper to ts(-proto) and new version of cosmjs * several code generation improvements made. * add customizable fee * fix default amount * feat(codegen): add code generation for 3rd party modules (#797) * feat(codegen): generate rest client for js * fix Go codegen * feat(codegen): generated js client (the wrapper) it wraps generated protobufjs types and rest client, uses cosmjs and exports high level `txClient()` and `queryClient()` funcs for: * creating messages, signing and broadcasting them, * querying. js client created individually for each module. within Vuex, it can be used like in below: ```js import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { txClient, queryClient } from "./store/tendermint/mars/mars/module"; async function main() { const wallet = await DirectSecp256k1HdWallet.fromMnemonic("alfa romeo..."); const t = await txClient(wallet); const q = await queryClient(); console.log(await t.signAndBroadcast([ t.msgCreateUser({ name: "mars", creator: wallet.address }) ])); console.log(await q.queryUserAll()); } main() ``` * fix(sta): sdk module name * docs * feat(codegen/ts-proto): generate app types with ts-proto previously, we were using `protobufjs` to generate app types. now, we have switched to `ts-proto` but also kept js support by placing `.js` and `.d.ts` files next to the generated `.ts` files. * refactored `nodetime` packaging. * added more detailed info to `pkg/cosmosanalysis/module.Discover()` output. * added more detailed info to `pkg/protoanalysis.DiscoverPackages()` output. * added plugin binary configurability option to `pkg/protoc` pkg. * improved `pkg/cosmosgen`'s public API. * added `pkg/nodetime/tsc`, `pkg/nodetime/ts-proto` and removed `pkg/nodetime/protobufjs`. * fix lint * fix err check * migrate wrapper to ts(-proto) and new version of cosmjs * several code generation improvements made. * feat(codegen): add code generation for dependency modules optionally enable js related code code generation for the 3rd party modules -including the sdk- that used by an app. * several improvements mode on code generation logic. * fix lint & err checking * fix go codegen * scaffolding(stargate): add generated 3rd party js clients * enable code gen for 3rd party modules on demand * docs * fix: add chain to path (#802) Co-authored-by: Alex Megalokonomos <alex@clockwork.gr> * chore: sync stargate scaffolding for new js gen path (#803) * feat: Updated vue template for codegen (#807) * feat: Updated vue template * package.json fixes * chrore(ui): update versions , add plain eslint config (#812) * feat: (codegen/vuex): add Vuex code generation & refactor (#824) * codegen(vuex): add Vuex code generation & refactor code generation related packages. * fix err handling & linter errors * fix err handling * fix msg discovery * cosmosanalysis: add metadata about grpc gateway * docs: fix typo * fix linter err * feat: provide more tpl data to loader & add user-side warnings (#857) * feat: provide more tpl data to loader & add user-side warnings about not modifying generated dirs/files. * cosmetic * fix: Template updates (#825) * fix: Template updates * feat: sendMsg* actions, Msg* message creation * feat: Add true Error()s * fix: Change `chain` to `generated` * fix: tsc ignore imported dependency * Updated generated JS/TS for SDK modules * feat: Add get all pages option to queries * fiix: Pass all option to subscription * feat: Add query returns from store * WIP v0.15 Layout * Regenerated JS/TS * fix: stale state, return from getters * Regenerated TS/JS * JS Template changes * Regenerated JS/TS * Additional template changes * fix: Template changes * Regenerated TS/JS * templates: sync pre generated js Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: Alex Megalokonomos <alex@clockwork.gr>
1 parent 0918d76 commit 88781ee

File tree

669 files changed

+335676
-12373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

669 files changed

+335676
-12373
lines changed

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 6
1313
steps:
14+
- name: Set up Go
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.16
1418
- uses: actions/checkout@v2
1519
- uses: technote-space/get-diff-action@v4
1620
with:

.github/workflows/test-e2e.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
uses: actions/setup-go@v2
1818
with:
1919
go-version: 1.16
20-
stable: false
2120

2221
- name: Set up Node
2322
uses: actions/setup-node@v2-beta

.github/workflows/test-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v2
1919
with:
20-
go-version: "1.16"
20+
go-version: 1.16
2121

2222
- name: "Get Go 1.15"
2323
run: |

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-go@v2
1616
with:
17-
go-version: "1.16"
17+
go-version: 1.16
1818
- run: ./scripts/test-unit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build/
22
dist
3+
nodetime-*
34
node_modules
45
.DS_Store
56
apps/

docs/1 Introduction/2 Install.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ brew install tendermint/tap/starport
2929
```
3030

3131
## Build from source
32+
Starport uses [Git LFS](https://git-lfs.github.com/). Please make sure that it is installed before cloning Starport.
33+
If you have installed Git LFS after cloning Starport, checkout to your preferred branch to trigger a pull for large files or run `git lfs pull`.
3234

3335
```
3436
git clone https://github.com/tendermint/starport --depth=1

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/cosmos/relayer v1.0.0-rc1.0.20210205103857-f4b56856caeb
1313
github.com/dariubs/percent v0.0.0-20200128140941-b7801cf1c7e2
1414
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
15+
github.com/emicklei/proto v1.9.0
1516
github.com/fatih/color v1.10.0
1617
github.com/gertd/go-pluralize v0.1.7
1718
github.com/go-bindata/go-bindata v3.1.2+incompatible
@@ -22,12 +23,14 @@ require (
2223
github.com/gobuffalo/plush v3.8.3+incompatible
2324
github.com/gobuffalo/plushgen v0.1.2
2425
github.com/goccy/go-yaml v1.8.0
25-
github.com/gookit/color v1.3.6
26+
github.com/gookit/color v1.2.7
2627
github.com/gorilla/mux v1.8.0
2728
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
29+
github.com/iancoleman/strcase v0.1.3
2830
github.com/imdario/mergo v0.3.11
2931
github.com/improbable-eng/grpc-web v0.13.0
3032
github.com/jpillora/chisel v1.7.3
33+
github.com/kr/pretty v0.1.0
3134
github.com/magefile/mage v1.11.0 // indirect
3235
github.com/manifoldco/promptui v0.8.0
3336
github.com/mattn/go-zglob v0.0.3

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
197197
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
198198
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
199199
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
200+
github.com/emicklei/proto v1.9.0 h1:l0QiNT6Qs7Yj0Mb4X6dnWBQer4ebei2BFcgQLbGqUDc=
201+
github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
200202
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
201203
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
202204
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 h1:2vLKys4RBU4pn2T/hjXMbvwTr1Cvy5THHrQkbeY9HRk=
@@ -352,9 +354,8 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
352354
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
353355
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
354356
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
357+
github.com/gookit/color v1.2.7 h1:4qePMNWZhrmbfYJDix+J4V2l0iVW+6jQGjicELlN14E=
355358
github.com/gookit/color v1.2.7/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg=
356-
github.com/gookit/color v1.3.6 h1:Rgbazd4JO5AgSTVGS3o0nvaSdwdrS8bzvIXwtK6OiMk=
357-
github.com/gookit/color v1.3.6/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
358359
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
359360
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
360361
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
@@ -422,6 +423,8 @@ github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDG
422423
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
423424
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
424425
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
426+
github.com/iancoleman/strcase v0.1.3 h1:dJBk1m2/qjL1twPLf68JND55vvivMupZ4wIzE8CTdBw=
427+
github.com/iancoleman/strcase v0.1.3/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
425428
github.com/ilgooz/analytics-go v3.1.1-0.20200723195510-acde4190c655+incompatible/go.mod h1:36xDpOWfOEZLx5a4Qra2Ntu7by75m/qwZZx9/YrPrtY=
426429
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
427430
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=

scripts/data/gen-nodetime/nodetime

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
3+
var mode = process.argv[2];
4+
process.argv.splice(2, 1);
5+
6+
switch (mode) {
7+
case "ts-proto":
8+
require("./node_modules/ts-proto/protoc-gen-ts_proto");
9+
break;
10+
11+
case "tsc":
12+
require("./node_modules/typescript/bin/tsc");
13+
break;
14+
15+
case "sta":
16+
require("./node_modules/swagger-typescript-api/index");
17+
break;
18+
19+
default:
20+
console.error("unknown cli command");
21+
}

0 commit comments

Comments
 (0)