-
Notifications
You must be signed in to change notification settings - Fork 9
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
Publish cosmos generated types in a separate package #4
Comments
Proposal 1: Regen-centric approachMy initial idea was to create a import {...} from '@regennetwork/proto/cosmos/bank/v1beta1/query';
import {...} from '@regennetwork/proto/regen/data/v1beta1/tx'; This might be the most intuitive solution, as users would only ever need to import from one package ( Proposal 2: Cosmos-centric approachExport cosmos and regen types in separate packages import {...} from '@regennetwork/proto-cosmos/bank/v1beta1/query';
import {...} from '@regennetwork/proto-regen/data/v1beta1/tx'; This is slightly more clunky, as there are two packages to import from. Users need to know which modules are in which package. But also a better separation of concerns, and other people in the cosmos community can use Proposal 3: A ts-proto community approachref: stephenh/ts-proto#58. Create a import {...} from '@ts-proto/cosmos/bank/v1beta1/query';
import {...} from '@ts-proto/regen/data/v1beta1/tx';
import {...} from '@ts-proto/google/protobuf/any'; Same as above regarding 2 packages. However, it's scalable, and dependencies (such as gogoproto, confio...) are explicit in package.json. |
In #7, I'm going with proposal 2. LMK if that sounds good to you. |
I agree with approach (2). We should put cosmos types under the |
That'd be really nice, but it seems taken https://www.npmjs.com/org/cosmos |
Hi Amaury and Aaron. I would like to contribute to the Regen Network Frontend. I assume this is the right repo and not regen-app. Is there any issue that would be a good one to get started with? Thanks, |
Hey @chris-chapin, thanks for your interest. In the next 2 weeks I'll publish a 1st version of @regen-network/api, which should at least give something working. I'll also create some self-contained issues that external contributors can pick up. For now, I think it's still a bit early, as there are a couple of design issues I'd like to work on first. You can watch this repo for updates! |
I recommend to put this on-ice, pending on cosmos/cosmjs#586. If cosmjs doesn't go with ts-proto, it's not worth to publish these types under an official cosmos org. |
Looks like going with ts-proto is quite decided I am also ready to think along and implement some of this. I have most resonance for option 3 above. However, if the repo is 90-100% automated with CI, it would be wicked. @AmauryM asked me to tag y'all: |
BSR is a way to go. We want to use it in SDK. We definitely need:
I'm curious if there is an implementation of that idea for NPM / Yarn registry. If not then the Option 3 is the closest one. |
yes but BSR will provide the protofiles, not the ts files... |
BSR also makes generation easy with plugins and templates |
Small note: FYI there are some talks about a dynamic CosmJS client cosmos/cosmjs#885, but I don't think that should be the way to go for regen-js, so I still approve the above ideas of generating .ts files using Buf (which seems to be happening in #29 🎉), and publishing them into separate npm packages.
I think an automatic publishing of npm packages directly from a buf plugin will however be hard, because of amino, and some manual hardcoded stuff needs to be done, like here. I still would root for a cosmos-centric approach (2 in the initial post), something in the vein of: // Inside package `@regennetwork/api`;
import { ecocredits } from '@regenetwork/ecocredits'; // Generated and published by buf, thou
import { data } from '@regenetwork/data'; // idem
import { bank } from '@cosmos-sdk/bank'; // idem
import { staking } from '@cosmos-sdk/staking'; // idem
import { gluecode } from '@regennetwork/gluecode'; // Find better name than "gluecode". Basically, handles non-module client code, like RPC, signing etc... can be mostly based on CosmJS components
export const Api = gluecode([
ecocredits(), data(), bank(), staking(), // add all necessary modules
]);
// There needs to be some advanced TypeScript magic, so that the Api object is correctly typed, e.g. `api.query.ecoc<tab>` autocompletes. in which case other chains could re-use this gluecode easily: // Inside package `@osmosis/api`;
// -- snip --
import { superfluid } from '@osmosis/superfluid'; // also generated by buf
export const Api = gludecode([bank(), superfluid(), ...]); |
I recently discovered https://github.com/osmosis-labs/telescope, so pasting it here in case it's not under your radar. It's a Protobuf->Typescript code generator. Seems like they generate (note that they unfortunately don't use protoc, so I'm not sure how it'll play with buf). |
Hey @AmauryM - I’m actually playing with telescope for the cosmos groups-UI work. FYI, when you run It’s been a fairly smooth experience for me so far, and the creator (Dan) is really helpful |
So that it can be reused separately.
The text was updated successfully, but these errors were encountered: