Skip to content

Conversation

@codebycarson
Copy link
Collaborator

@codebycarson codebycarson commented Nov 22, 2024

Add @sei-js/cosmos

Adds a new package called @sei-js/cosmos which is meant to replace and expand upon @sei-js/proto. It uses buf to build the protos, and then node scripts to extract only relevant into simplified libraries.

  • In the future, writing our own buf compiler could remove the need for the node scripts to extract and parse the data.

Libraries

@sei-js/cosmos/types

A library exporting Typescript types for all modules used on Sei. Additionally it contains query Request/Response types, and other base types like Coin, Account, etc.

@sei-js/cosmos/encoding

A replacement to the old @sei-js/proto library, which was generated by telescope. Contains protobuf encoding and decoding functions for all Sei data types including all Query and Execute Msg types and all Sei base types. Additionally it includes registries and aminoConverters for easy use with @cosmjs clients. Uses types from @sei-js/cosmos/types.

@sei-js/cosmos/types

A replacement to the LCD client generated in the old @sei-js/proto library. This uses simple fetch requests to query the chain state. Uses types from @sei-js/cosmos/types.

Review Notes

Look into the ./generated folder to see the output from the yarn generate command. See the README.md file for usage or local generation instructions

Testing

This project has been tested by me extensively, has been used to test ledger signing on the Cosmos app, has been integrated for months into QA tests, and is now used on the Sei App via the NPM internal release.

- Removed the need for telescope and instead generate TS files with buf.build and cherry pick what we want.
- Adds @sei-js/cosmos/types for easy typescript types imports
- Adds @sei-js/cosmos/encoding for easy proto/direct message encoding
- Adds @sei-js/cosmos/rest which allows for querying cosmos REST nodes
- Removes leading zeros from @sei-js/ledger bytes and bumps the sei ledger package version
- Remove tsconfig in favor of biome for this package.
- Added ts-configs back
- Fixed a few typescript warnings inside the encoding library.
- Update README.md
-Removed npx, added tsx to cosmos package
- Compiled outputs for cjs, esm, and ts types imports respectively

- Added @ts-nocheck to index files
Replace the old Amino type structure (module.package.type) to the more standard amino way (module/type), which is required for Ledger signing.
@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: dbde1da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sei-js/ledger Patch
@sei-js/cosmos Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

just wanted to confirm - is /generated supposed to be checked into git?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah cuz otherwise people won't be able to view the files on github. They would have to install the module and build, which isn't ideal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But I did add it to .npmignore, so that way it's only when viewing the repo it will get them.

Used the old `/gen` instead of newer `/generated`
@codebycarson codebycarson merged commit 590bbcf into main Dec 4, 2024
0 of 2 checks passed
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.

3 participants