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

refactor!: migrate api package to use telescope #68

Merged
merged 9 commits into from
May 18, 2023
Merged

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented May 12, 2023

Closes: regen-network/groups-ui#33

This pull request migrates the regen-ts code to regen-js within a new package api-v1 and fixes the reported error. As far as I understand, this will eventually replace the need for the existing api package when we are ready to migrate.

An alternative to adding this as a new package would be creating a release branch (e.g. release/v0.x) and replacing api on the main branch. This would be my preference, which would allow us to use package name api (otherwise we would need to change the package name within package.json for publishing releases) and we would be able to continue maintaining the v0 series by merging fixes into the release branch and publishing from there.

Note: Updated to use alternative approach mentioned above ☝️

Credit to @haveanicedavid for getting this work started in: https://github.com/haveanicedavid/regen-ts

@haveanicedavid
Copy link

haveanicedavid commented May 15, 2023

Great work here @ryanchristo

I think when testing this, it would be ideal to look at the generated bundle file simply because this adds a fair amount of code. One of the downsides with telescope is that it doesn't handle code-splitting very well, and while the majority of bundle is through 3rd party libs we can't do much about (libsodium and some crypto libs), this could potentially have perf impact on the registry app if it bloats regen-js more than it already is.

I think to test would require:

  1. getting a baseline through a bundle analyzer
  2. pulling this branch locally, building,
  3. symlinking to the registry or groups apps and running a bundle analyzer, compare output of this branch vs what's currently on main

@ryanchristo ryanchristo marked this pull request as draft May 15, 2023 16:36
@ryanchristo ryanchristo changed the title feat: add api-v1 built with telescope refactor!: migrate api package to use telescope May 15, 2023
@@ -50,7 +50,7 @@ message GetTxsEventRequest {
// pagination defines a pagination for the request.
// Deprecated post v0.46.x: use page and limit instead.
cosmos.base.query.v1beta1.PageRequest pagination = 2 [deprecated = true];
;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra semicolon was causing telescope to fail

@@ -16,7 +16,7 @@ service Query {
rpc AnchorByIRI(QueryAnchorByIRIRequest) returns (QueryAnchorByIRIResponse) {
option (google.api.http) = {
get : "/regen/data/v1/anchor-by-iri/{iri}"
additional_bindings : [ {get : "/regen/data/v1/anchors/iri/{iri}"} ]
// additional_bindings : [ {get : "/regen/data/v1/anchors/iri/{iri}"} ]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Telescope was returning unexpected [ character error. Additional bindings are not necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean we'll need to comment those manually as long as there's not a fix on telescope side?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Eventually we shouldn't have to make any changes to the proto files and we could use buf to pull the proto files from buf registry and gitignore proto files. This would require adding a fix on telescope though as well as fixing the proto file with the extra ; (or adding a fix on telescope for this as well).

@@ -0,0 +1,6 @@
export const AMINO_MAP = {
// TODO: add amino types
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a separate issue once merged to track adding amino support.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#70

@@ -14,7 +14,7 @@
"build": "lerna run build --stream",
"format": "yarn lint --fix",
"lerna:deploy": "yarn build && lerna version --conventional-commits && lerna publish from-git",
"lint": "tsc --noEmit && eslint --ext js,ts,tsx .",
"lint": "eslint --ext js,ts,tsx .",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently there are typescript errors in the generated code. Removing ts compile from the lint script for now but we may want to add back when we have a solution.

@@ -1,19 +0,0 @@
syntax = "proto3";

package ibc.applications.transfer.v1;
Copy link
Member Author

@ryanchristo ryanchristo May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest proto from the ibc repository was causing errors when generating code due to an import that does not exist. I think I found the right file but received additional errors. I did not update ibc proto for now and maybe best to address as a separate issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add back the proto files that are in the current api package and then maybe we can address updating the ibc proto files in a separate issue. There are probably a few issues we need to resolve before this new version of the api package is ready for regen-web but hopefully those won't be too difficult to address in followups.

Copy link
Member Author

@ryanchristo ryanchristo May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proto 0211584 and codegen 7bfebc8

@ryanchristo ryanchristo marked this pull request as ready for review May 15, 2023 22:59
Copy link

@haveanicedavid haveanicedavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK - I didn't review the whole diff and haven't tested everything involved, but as long as we use tagged releases, I'm not sure there should be concern merging this as it shouldn't impact the registry app

@ryanchristo ryanchristo merged commit de30115 into main May 18, 2023
@ryanchristo ryanchristo deleted the ryan/api-v1 branch May 18, 2023 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct proto generation with telescope for regen ledger & move location to regen's github
3 participants