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

feat/proto generation #505

Merged
merged 9 commits into from
Sep 21, 2024
Merged

feat/proto generation #505

merged 9 commits into from
Sep 21, 2024

Conversation

bangjelkoski
Copy link
Collaborator

@bangjelkoski bangjelkoski commented Sep 20, 2024

Summary by CodeRabbit

  • New Features

    • Added scripts for generating and publishing TypeScript protocol files for core and indexer components.
    • Introduced comprehensive documentation for the TypeScript proto generation process.
    • Added a structured set of exports for various modules related to the Cosmos ecosystem and Injective protocol.
  • Bug Fixes

    • Implemented cleanup steps in scripts to ensure only necessary output remains.
  • Documentation

    • Added a README.md file detailing the proto generation process and contribution guidelines.
  • Chores

    • Introduced .gitignore to exclude specific directories from version control.

Copy link

coderabbitai bot commented Sep 20, 2024

Walkthrough

The changes introduce new scripts in the package.json for generating and publishing TypeScript protocol files for both core and indexer components. Additionally, new package.json files are created in the proto/core and proto/indexer directories to specify development dependencies. A .gitignore file is added to exclude certain directories from version control, and a README.md file is included to document the TypeScript proto generation process. New scripts for generating TypeScript code from proto definitions are also implemented in the gen.sh files for both core and indexer. Furthermore, the publish.sh scripts automate the versioning and publishing of the respective packages.

Changes

File(s) Change Summary
package.json Added scripts for generating and publishing TypeScript protocol files for core and indexer components.
proto/core/package.json, proto/indexer/package.json New files created specifying development dependencies for the core and indexer projects.
proto/.gitignore New file created to specify directories to be ignored by Git.
proto/README.md New documentation file outlining the TypeScript proto generation process and usage instructions.
proto/core/gen.sh, proto/indexer/gen.sh New scripts added to automate the generation of TypeScript code from proto definitions.
proto/core/publish.sh, proto/indexer/publish.sh New scripts added to automate the versioning and publishing of respective packages.
proto/core/stub/index.ts.template, proto/indexer/stub/index.ts.template New template files created to organize exports for core and indexer APIs.
packages/sdk-ts/src/core/accounts/PrivateKey.ts, packages/sdk-ts/src/core/modules/tx/utils/tx.ts Updated type references from InjectiveTypesV1TxExt to InjectiveTypesV1Beta1TxExt in relevant files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PackageManager
    participant CoreGenScript
    participant IndexerGenScript

    User->>PackageManager: run generate:core-proto-ts
    PackageManager->>CoreGenScript: Execute
    CoreGenScript->>CoreGenScript: Generate TypeScript from proto
    CoreGenScript-->>PackageManager: Return generated files

    User->>PackageManager: run generate:indexer-proto-ts
    PackageManager->>IndexerGenScript: Execute
    IndexerGenScript->>IndexerGenScript: Generate TypeScript from proto
    IndexerGenScript-->>PackageManager: Return generated files
Loading

🐇 In the meadow, scripts now play,
Generating types in a swift ballet.
Core and indexer, side by side,
With new files and docs, we take pride.
Hopping along, we code with glee,
In this patch, there's magic, you see! 🌼


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

socket-security bot commented Sep 20, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Critical CVE npm/protobufjs@6.11.3 ⚠︎

View full report↗︎

Next steps

What is a critical CVE?

Contains a Critical Common Vulnerability and Exposure (CVE).

Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/protobufjs@6.11.3

Copy link
Collaborator

@ThomasRalee ThomasRalee left a comment

Choose a reason for hiding this comment

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

Let's add a readme in the proto folder

Copy link

socket-security bot commented Sep 20, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@grpc/grpc-js@1.11.3 environment, filesystem, network +32 9.66 MB murgatroid99
npm/jsonschema@1.4.1 None 0 81.8 kB acubed
npm/lodash.values@4.3.0 None 0 14.9 kB jdalton
npm/ts-proto@1.141.1 Transitive: environment, filesystem, network, shell +22 73 MB shaberman
npm/ts-protoc-gen@0.15.0 None 0 179 kB jonnyreeves

🚮 Removed packages: npm/@babel/helpers@7.20.7, npm/@babel/plugin-syntax-bigint@7.8.3, npm/@babel/plugin-syntax-import-meta@7.10.4, npm/@babel/plugin-syntax-jsx@7.18.6, npm/@babel/plugin-syntax-typescript@7.20.0, npm/@bcoe/v8-coverage@0.2.3, npm/@eslint/eslintrc@0.4.3, npm/@humanwhocodes/config-array@0.5.0, npm/@humanwhocodes/object-schema@1.2.1, npm/@isaacs/string-locale-compare@1.1.0, npm/@istanbuljs/load-nyc-config@1.1.0, npm/@istanbuljs/schema@0.1.3, npm/@jest/console@29.4.3, npm/@jest/core@29.4.3, npm/@jest/environment@29.4.3, npm/@jest/expect@29.4.3, npm/@jest/fake-timers@29.4.3, npm/@jest/globals@29.4.3, npm/@jest/reporters@29.4.3, npm/@jest/source-map@29.4.3, npm/@jest/test-result@29.4.3, npm/@jest/test-sequencer@29.4.3, npm/@lerna/child-process@6.6.1, npm/@lerna/create@6.6.1, npm/@lerna/legacy-package-management@6.6.1, npm/@npmcli/arborist@6.2.3, npm/@npmcli/fs@3.1.0, npm/@npmcli/installed-package-contents@1.0.7, npm/@npmcli/map-workspaces@3.0.4, npm/@npmcli/metavuln-calculator@5.0.1, npm/@npmcli/name-from-folder@2.0.0, npm/@npmcli/node-gyp@2.0.0, npm/@npmcli/package-json@3.0.0, npm/@npmcli/promise-spawn@6.0.2, npm/@npmcli/query@3.0.0, npm/@npmcli/run-script@6.0.1, npm/@nrwl/cli@15.9.3, npm/@nrwl/devkit@15.9.3, npm/@nrwl/tao@15.9.3, npm/@octokit/core@4.2.0, npm/@octokit/plugin-enterprise-rest@6.0.1, npm/@octokit/plugin-paginate-rest@3.1.0, npm/@octokit/plugin-request-log@1.0.4, npm/@octokit/plugin-rest-endpoint-methods@6.8.1, npm/@octokit/rest@19.0.3, npm/@parcel/watcher@2.0.4, npm/@sinonjs/commons@2.0.0, npm/@sinonjs/fake-timers@10.0.2, npm/@types/babel__generator@7.6.4, npm/@types/babel__template@7.4.1, npm/@types/babel__traverse@7.18.3, npm/@types/graceful-fs@4.1.5, npm/@types/json5@0.0.29, npm/@types/mdast@3.0.10, npm/@types/minimatch@3.0.5, npm/@types/prettier@2.7.2, npm/@types/unist@2.0.6, npm/@yarnpkg/lockfile@1.1.0, npm/@yarnpkg/parsers@3.0.0-rc.43, npm/@zkochan/js-yaml@0.0.6, npm/acorn-jsx@5.3.2, npm/acorn@7.4.1, npm/add-stream@1.0.0, npm/ajv@6.12.6, npm/ansi-colors@4.1.3, npm/ansi-escapes@4.3.2, npm/anymatch@3.1.3, npm/aproba@2.0.0, npm/are-we-there-yet@4.0.0, npm/argparse@1.0.10, npm/array-differ@3.0.0, npm/array-includes@3.1.6, npm/array.prototype.flat@1.3.1, npm/astral-regex@2.0.0, npm/available-typed-arrays@1.0.5, npm/axios@1.4.0, npm/babel-plugin-jest-hoist@29.4.3, npm/babel-preset-current-node-syntax@1.0.1, npm/base64-js@1.5.1, npm/bin-links@4.0.1, npm/bl@4.1.0, npm/bser@2.1.1, npm/byte-size@7.0.0, npm/cacache@17.1.0, npm/cachedir@2.3.0, npm/call-bind@1.0.2, npm/char-regex@1.0.2, npm/character-entities-legacy@1.1.4, npm/character-entities@1.2.4, npm/character-reference-invalid@1.1.4, npm/chardet@0.7.0, npm/cjs-module-lexer@1.2.2, npm/cli-cursor@3.1.0, npm/cli-spinners@2.7.0, npm/cli-width@3.0.0, npm/clone-deep@4.0.1, npm/clone@1.0.4, npm/cmd-shim@5.0.0, npm/co@4.6.0, npm/collect-v8-coverage@1.0.1, npm/columnify@1.6.0, npm/commitizen@4.2.6, npm/common-ancestor-path@1.0.1, npm/concat-stream@2.0.0, npm/config-chain@1.1.12, npm/confusing-browser-globals@1.0.11, npm/console-control-strings@1.1.0, npm/conventional-changelog-core@4.2.4, npm/conventional-changelog-preset-loader@2.3.4, npm/conventional-changelog-writer@5.0.1, npm/conventional-commit-types@3.0.0, npm/conventional-commits-filter@2.0.7, npm/conventional-recommended-bump@6.1.0, npm/cross-env@7.0.3, npm/cz-conventional-changelog@3.3.0, npm/dateformat@3.0.3, npm/dedent@0.7.0, npm/deep-is@0.1.4, npm/deepmerge@4.2.2, npm/defaults@1.0.4, npm/define-properties@1.1.4, npm/detect-file@1.0.0, npm/detect-indent@6.1.0, npm/detect-newline@3.1.0, npm/doctrine@3.0.0, npm/dotenv@16.0.3, npm/ejs@3.1.9, npm/emittery@0.13.1, npm/enquirer@2.3.6, npm/envinfo@7.8.1, npm/es-abstract@1.21.0, npm/es-set-tostringtag@2.0.0, npm/es-shim-unscopables@1.0.0, npm/es-to-primitive@1.2.1, npm/eslint-config-airbnb-base@14.2.1, npm/eslint-config-airbnb@18.2.1, npm/eslint-config-prettier@8.6.0, npm/eslint-import-resolver-node@0.3.6, npm/eslint-import-resolver-typescript@2.7.1, npm/eslint-module-utils@2.7.4, npm/eslint-plugin-import@2.26.0, npm/eslint-plugin-jest@27.2.1, npm/eslint-plugin-markdown@2.2.1, npm/eslint-plugin-prettier@4.2.1, npm/eslint-scope@5.1.1, npm/eslint-utils@2.1.0, npm/eslint@7.32.0, npm/espree@7.3.1, npm/esprima@4.0.1, npm/esquery@1.4.0, npm/esrecurse@4.3.0, npm/estraverse@5.3.0, npm/exit@0.1.2, npm/expand-tilde@2.0.2, npm/external-editor@3.1.0, npm/fast-deep-equal@3.1.3, npm/fast-diff@1.2.0, npm/fast-levenshtein@2.0.6, npm/fb-watchman@2.0.2, npm/figures@3.2.0, npm/file-entry-cache@6.0.1, npm/file-url@3.0.0, npm/find-node-modules@2.1.3, npm/find-root@1.1.0, npm/findup-sync@4.0.0, npm/flat-cache@3.0.4, npm/flat@5.0.2, npm/flatted@3.2.7, npm/for-each@0.3.3, npm/fs.realpath@1.0.0, npm/fsevents@2.3.2, npm/function.prototype.name@1.1.5, npm/functional-red-black-tree@1.0.1, npm/functions-have-names@1.2.3, npm/gauge@5.0.1, npm/gensync@1.0.0-beta.2, npm/get-intrinsic@1.1.3, npm/get-package-type@0.1.0, npm/get-pkg-repo@4.2.1, npm/get-port@5.1.1, npm/get-symbol-description@1.0.0, npm/git-remote-origin-url@2.0.0, npm/git-semver-tags@4.1.1, npm/git-up@7.0.0, npm/git-url-parse@13.1.0, npm/global-modules@1.0.0, npm/global-prefix@1.0.2, npm/globalthis@1.0.3, npm/gopd@1.0.1, npm/has-bigints@1.0.2, npm/has-property-descriptors@1.0.0, npm/has-proto@1.0.1, npm/has-symbols@1.0.3, npm/has-tostringtag@1.0.0, npm/has-unicode@2.0.1, npm/homedir-polyfill@1.0.3, npm/html-escaper@2.0.2, npm/husky@7.0.4, npm/iconv-lite@0.4.24, npm/ieee754@1.2.1, npm/ignore-walk@5.0.1, npm/import-local@3.1.0, npm/imurmurhash@0.1.4, npm/inflight@1.0.6, npm/init-package-json@3.0.2, npm/inquirer@8.2.4, npm/internal-slot@1.0.4, npm/is-alphabetical@1.0.4, npm/is-alphanumerical@1.0.4, npm/is-array-buffer@3.0.0, npm/is-bigint@1.0.4, npm/is-boolean-object@1.1.2, npm/is-callable@1.2.7, npm/is-ci@2.0.0, npm/is-date-object@1.0.5, npm/is-decimal@1.0.4, npm/is-generator-fn@2.1.0, npm/is-hexadecimal@1.0.4, npm/is-interactive@1.0.0, npm/is-negative-zero@2.0.2, npm/is-number-object@1.0.7, npm/is-plain-object@2.0.4, npm/is-regex@1.1.4, npm/is-shared-array-buffer@1.0.2, npm/is-string@1.0.7, npm/is-symbol@1.0.4, npm/is-typed-array@1.1.10, npm/is-unicode-supported@0.1.0, npm/is-utf8@0.2.1, npm/is-weakref@1.0.2, npm/is-windows@1.0.2, npm/istanbul-lib-coverage@3.2.0, npm/istanbul-lib-instrument@5.2.1, npm/istanbul-lib-report@3.0.0, npm/istanbul-lib-source-maps@4.0.1, npm/istanbul-reports@3.1.5, npm/jest-changed-files@29.4.3, npm/jest-circus@29.4.3, npm/jest-cli@29.4.3, npm/jest-config@29.4.3, npm/jest-docblock@29.4.3, npm/jest-each@29.4.3, npm/jest-environment-node@29.4.3, npm/jest-junit@15.0.0, npm/jest-leak-detector@29.4.3, npm/jest-mock@29.4.3, npm/jest-pnp-resolver@1.2.3, npm/jest-regex-util@29.4.3, npm/jest-resolve-dependencies@29.4.3, npm/jest-resolve@29.4.3, npm/jest-runner@29.4.3, npm/jest-runtime@29.4.3, npm/jest-snapshot@29.4.3, npm/jest-validate@29.4.3, npm/jest-watcher@29.4.3, npm/jest-worker@29.4.3, npm/jest@29.4.3, npm/js-yaml@3.14.1, npm/json-schema-traverse@0.4.1, npm/json-stable-stringify-without-jsonify@1.0.1, npm/json-stringify-nice@1.1.4, npm/json5@2.2.3, npm/kleur@3.0.3, npm/lerna@6.6.1, npm/leven@3.1.0, npm/levn@0.4.1, npm/libnpmaccess@6.0.3, npm/libnpmpublish@6.0.4, npm/load-json-file@6.2.0, npm/lodash.map@4.6.0, npm/lodash.merge@4.6.2, npm/lodash.truncate@4.4.2, npm/log-symbols@4.1.0, npm/longest@2.0.1, npm/make-dir@3.1.0, npm/make-fetch-happen@10.2.1, npm/makeerror@1.0.12, npm/mdast-util-from-markdown@0.8.5, npm/mdast-util-to-string@2.0.0, npm/merge@2.1.1, npm/micromark@2.11.4, npm/minimist@1.2.6, npm/minipass-fetch@3.0.3, npm/minipass-json-stream@1.0.1, npm/minipass@5.0.0, npm/minizlib@2.1.2, npm/mkdirp-infer-owner@2.0.0, npm/mkdirp@1.0.4, npm/multimatch@5.0.0, npm/mute-stream@0.0.8, npm/node-fetch@2.6.7, npm/node-gyp@9.3.1, npm/node-int64@0.4.0, npm/nopt@7.1.0, npm/normalize-path@3.0.0, npm/npm-bundled@3.0.0, npm/npm-install-checks@6.1.1, npm/npm-normalize-package-bin@1.0.1, npm/npm-package-arg@9.1.2, npm/npm-packlist@5.1.1, npm/npm-pick-manifest@7.0.2, npm/npm-registry-fetch@13.3.1, npm/npmlog@7.0.1, npm/nx@15.9.3, npm/object-inspect@1.12.2, npm/object-keys@1.1.1, npm/object.assign@4.1.4, npm/object.entries@1.1.6, npm/object.values@1.1.6, npm/once@1.4.0, npm/optionator@0.9.1, npm/ora@5.4.1, npm/os-tmpdir@1.0.2, npm/p-map-series@2.1.0, npm/p-map@4.0.0, npm/p-pipe@3.1.0, npm/p-queue@6.6.2, npm/p-reduce@2.1.0, npm/p-waterfall@2.1.1, npm/pacote@15.1.3, npm/parse-conflict-json@3.0.1, npm/parse-entities@2.0.0, npm/parse-passwd@1.0.0, npm/path-is-absolute@1.0.1, npm/pify@5.0.0, npm/pirates@4.0.5, npm/pkg-dir@4.2.0, npm/prelude-ls@1.2.1, npm/prettier-linter-helpers@1.0.0, npm/proc-log@3.0.0, npm/progress@2.0.3, npm/promise-all-reject-late@1.0.1, npm/promise-call-limit@1.0.2, npm/prompts@2.4.2, npm/promzard@0.3.0, npm/proto-list@1.2.4, npm/punycode@2.1.1, npm/read-cmd-shim@3.0.0, npm/read-package-json-fast@3.0.2, npm/read-package-json@5.0.2, npm/read@1.0.7, npm/regexp.prototype.flags@1.4.3, npm/regexpp@3.2.0, npm/resolve-cwd@3.0.0, npm/resolve-dir@1.0.1, npm/resolve.exports@2.0.0, npm/restore-cursor@3.1.0, npm/rimraf@3.0.2, npm/run-async@2.4.1, npm/rxjs@7.8.0, npm/safe-regex-test@1.0.0, npm/safer-buffer@2.1.2, npm/set-blocking@2.0.0, npm/shallow-clone@3.0.1, npm/side-channel@1.0.4, npm/sisteransi@1.0.5, npm/slice-ansi@4.0.0, npm/sprintf-js@1.0.3, npm/ssri@9.0.1, npm/string-length@4.0.2, npm/string.prototype.trimend@1.0.6, npm/string.prototype.trimstart@1.0.6, npm/strip-bom@4.0.0, npm/strip-json-comments@3.1.1, npm/strong-log-transformer@2.1.0, npm/table@6.8.1, npm/tar@6.1.14, npm/temp-dir@1.0.0, npm/tempy@1.0.0, npm/test-exclude@6.0.0, npm/text-table@0.2.0, npm/tmp@0.0.33, npm/tmpl@1.0.5, npm/treeverse@3.0.0, npm/tsconfig-paths@4.2.0, npm/type-check@0.4.0, npm/type-detect@4.0.8, npm/typed-array-length@1.0.4, npm/unbox-primitive@1.0.2, npm/unist-util-stringify-position@2.0.3, npm/upath@2.0.1, npm/uri-js@4.4.1, npm/v8-compile-cache@2.3.0, npm/v8-to-istanbul@9.0.1, npm/validate-npm-package-name@3.0.0, npm/walk-up-path@1.0.0, npm/walker@1.0.8, npm/wcwidth@1.0.1, npm/whatwg-url@5.0.0, npm/which-boxed-primitive@1.0.2, npm/which-typed-array@1.1.9, npm/word-wrap@1.2.3, npm/wrappy@1.0.2, npm/write-file-atomic@4.0.2, npm/write-pkg@4.0.0, npm/xml@1.0.1

View full report↗︎

@bangjelkoski
Copy link
Collaborator Author

@coderabbitai summary

Copy link

coderabbitai bot commented Sep 20, 2024

Actions performed

Summary regeneration triggered.

proto/core/publish.sh Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 16

Outside diff range and nitpick comments (12)
proto/.gitignore (1)

6-6: Add a trailing slash for consistency.

For consistency with the other .gitignore entries, add a trailing slash to the core/proto-ts entry.

Apply this diff:

-core/proto-ts
+core/proto-ts/
proto/core/publish.sh (1)

17-26: Remove the commented-out code.

The commented-out code seems to be related to publishing the @injectivelabs/chain-api package, which is no longer needed. Consider removing this code to improve the script's readability and maintainability.

Apply this diff to remove the commented-out code:

-## Publish chain-api
-# cd ./../chain-api || exit
-
-# v=$(npm view @injectivelabs/chain-api version)
-# echo "current package version: $v"
-
-# v1="${v%.*}.$((${v##*.}+1))"
-# echo "new package version: $v1"
-
-# npm version $v1
-# npm publish
proto/core/stub/package.json.chain-api.template (1)

5-7: Update the placeholder test script.

The scripts section includes a placeholder test script that should be replaced with actual tests to ensure the package's functionality. Consider adding meaningful tests to verify the expected behavior of the package.

proto/core/stub/package.json.core-proto-ts.template (1)

5-7: Consider adding relevant scripts.

The test script is just a placeholder that always fails. Consider adding scripts for common tasks such as:

  • Building the package
  • Running tests (once implemented)
  • Linting the code
  • Generating documentation

Having these scripts defined in the package.json makes it easier for developers to perform these tasks consistently.

proto/README.md (6)

3-3: Add a comma to improve readability.

Consider adding a comma after "Within this folder" to improve the readability of the sentence.

Apply this diff to add the comma:

-Within this folder we have the logic to generate proto definitions from the `injective-core` and `injective-indexer` repos.
+Within this folder, we have the logic to generate proto definitions from the `injective-core` and `injective-indexer` repos.
Tools
LanguageTool

[typographical] ~3-~3: It appears that a comma is missing.
Context: # 🌟 TS Proto Generation Within this folder we have the logic to generate proto def...

(DURING_THAT_TIME_COMMA)


9-9: Use "ensure" instead of "make sure" to strengthen the wording.

Consider replacing "make sure" with "ensure" to strengthen the wording of the sentence.

Apply this diff to make the change:

-please make sure you read them before you open a PR.
+please ensure you read them before you open a PR.
Tools
LanguageTool

[style] ~9-~9: Consider using a different verb to strengthen your wording.
Context: ...ge-specific contribution guides, please make sure you read them before you open a PR. --...

(MAKE_SURE_ENSURE)


26-26: Use an en dash for the year range.

Consider using an en dash (–) instead of a hyphen (-) for the year range to adhere to typographical conventions.

Apply this diff to make the change:

-Copyright © 2021 - 2022 Injective Labs Inc. (https://injectivelabs.org/)
+Copyright © 2021 – 2022 Injective Labs Inc. (https://injectivelabs.org/)
Tools
LanguageTool

[typographical] ~26-~26: If you want to indicate numerical ranges or time ranges, consider using an en dash.
Context: ...a> --- ## 🔓 License Copyright © 2021 - 2022 Injective Labs Inc. (https://inject...

(DASH_RULE)

Markdownlint

26-26: null
Bare URL used

(MD034, no-bare-urls)


26-26: Convert the bare URL to a link.

The bare URL should be converted to a link to improve readability and make it clickable.

Apply this diff to make the change:

-Copyright © 2021 – 2022 Injective Labs Inc. (https://injectivelabs.org/)
+Copyright © 2021 – 2022 Injective Labs Inc. ([https://injectivelabs.org/](https://injectivelabs.org/))
Tools
LanguageTool

[typographical] ~26-~26: If you want to indicate numerical ranges or time ranges, consider using an en dash.
Context: ...a> --- ## 🔓 License Copyright © 2021 - 2022 Injective Labs Inc. (https://inject...

(DASH_RULE)

Markdownlint

26-26: null
Bare URL used

(MD034, no-bare-urls)


28-28: Add alt text for the image.

The image should have an alt text to improve accessibility for users with screen readers.

Apply this diff to add the alt text:

-<a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" style="width: 300px; max-width: 100%; height: auto" />
+<a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" alt="Injective Labs Inc." style="width: 300px; max-width: 100%; height: auto" />
Tools
Markdownlint

28-28: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


33-33: Convert the bare URL to a link.

The bare URL should be converted to a link to improve readability and make it clickable.

Apply this diff to make the change:

-http://www.apache.org/licenses/
+[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
Tools
Markdownlint

33-33: null
Bare URL used

(MD034, no-bare-urls)

proto/core/stub/index.ts.template (2)

24-25: Check if the commented-out exports are necessary

Lines 24 and 25 contain commented-out exports for CosmosCapabilityV1Beta1Capability and CosmosCapabilityV1Beta1Genesis. If these modules are required, consider uncommenting them to include them in the export list.


85-89: Review the need for commented-out IBC Transfer V2 exports

Lines 85 to 89 have commented-out exports related to IBC Transfer V2 modules. If these exports are needed for your project, you might want to uncomment them.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d08eb99 and 5e3cac2.

Files ignored due to path filters (2)
  • proto/core/package-lock.json is excluded by !**/package-lock.json
  • proto/indexer/package-lock.json is excluded by !**/package-lock.json
Files selected for processing (23)
  • package.json (1 hunks)
  • proto/.gitignore (1 hunks)
  • proto/README.md (1 hunks)
  • proto/core/gen.sh (1 hunks)
  • proto/core/package.json (1 hunks)
  • proto/core/publish.sh (1 hunks)
  • proto/core/stub/index.ts.template (1 hunks)
  • proto/core/stub/package.json.chain-api.template (1 hunks)
  • proto/core/stub/package.json.cjs.template (1 hunks)
  • proto/core/stub/package.json.core-proto-ts.template (1 hunks)
  • proto/core/stub/package.json.esm.template (1 hunks)
  • proto/core/stub/tsconfig.json.cjs.template (1 hunks)
  • proto/core/stub/tsconfig.json.esm.template (1 hunks)
  • proto/indexer/gen.sh (1 hunks)
  • proto/indexer/package.json (1 hunks)
  • proto/indexer/publish.sh (1 hunks)
  • proto/indexer/stub/index.ts.template (1 hunks)
  • proto/indexer/stub/package.json.cjs.template (1 hunks)
  • proto/indexer/stub/package.json.esm.template (1 hunks)
  • proto/indexer/stub/package.json.indexer-api.template (1 hunks)
  • proto/indexer/stub/package.json.indexer-proto-ts.template (1 hunks)
  • proto/indexer/stub/tsconfig.json.cjs.template (1 hunks)
  • proto/indexer/stub/tsconfig.json.esm.template (1 hunks)
Additional context used
LanguageTool
proto/README.md

[typographical] ~3-~3: It appears that a comma is missing.
Context: # 🌟 TS Proto Generation Within this folder we have the logic to generate proto def...

(DURING_THAT_TIME_COMMA)


[style] ~9-~9: Consider using a different verb to strengthen your wording.
Context: ...ge-specific contribution guides, please make sure you read them before you open a PR. --...

(MAKE_SURE_ENSURE)


[typographical] ~26-~26: If you want to indicate numerical ranges or time ranges, consider using an en dash.
Context: ...a> --- ## 🔓 License Copyright © 2021 - 2022 Injective Labs Inc. (https://inject...

(DASH_RULE)


[typographical] ~30-~30: Do not use a colon (:) before a series that is introduced by a preposition (‘under’). Remove the colon or add a noun or a noun phrase after the preposition.
Context: ...ginally released by Injective Labs Inc. under:
Apache License
Version 2....

(RP_COLON)

Markdownlint
proto/README.md

26-26: null
Bare URL used

(MD034, no-bare-urls)


33-33: null
Bare URL used

(MD034, no-bare-urls)


28-28: null
Images should have alternate text (alt text)

(MD045, no-alt-text)

Shellcheck
proto/core/gen.sh

[warning] 9-9: TS_PROTO_TEMPLATE appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 23-23: counter appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 75-75: Quote this to prevent word splitting.

(SC2046)

proto/core/publish.sh

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

proto/indexer/gen.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 54-54: Quote this to prevent word splitting.

(SC2046)

proto/indexer/publish.sh

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

Additional comments not posted (36)
proto/.gitignore (1)

1-5: LGTM!

The .gitignore entries are correctly excluding the generated files and directories related to the TypeScript proto generation process.

proto/core/package.json (1)

1-8: LGTM!

The package.json file correctly specifies the necessary development dependencies for generating TypeScript code from proto definitions. The versions specified are the latest stable versions at the time of writing.

proto/indexer/package.json (1)

1-8: LGTM!

The package.json file specifies the necessary development dependencies for generating TypeScript code from proto definitions. The versions specified are the latest stable versions at the time of writing.

proto/indexer/stub/package.json.esm.template (1)

1-17: LGTM!

The package.json.esm.template file is well-structured and includes the necessary configuration for an ESM package. The dependencies and scripts are appropriate for a package that generates TypeScript code from protocol buffer definitions and facilitates gRPC communication.

proto/indexer/stub/package.json.cjs.template (1)

1-17: LGTM!

The package.json file is well-structured and includes the necessary dependencies and scripts for a TypeScript CommonJS module. The dependencies are standard libraries commonly used in TypeScript projects, and the gen script is appropriately defined to run the TypeScript compiler.

proto/core/stub/package.json.esm.template (1)

1-18: LGTM!

The package.json file for the proto/core/stub directory is well-structured and includes the necessary configuration for a TypeScript project involving protocol buffers and gRPC.

  • The "type" field is correctly set to "module" for using ECMAScript modules.
  • The "scripts" section includes a "gen" script to run the TypeScript compiler.
  • The "dependencies" section lists the required libraries for working with protobuf and gRPC, such as @injectivelabs/grpc-web, google-protobuf, @bufbuild/protobuf, protobufjs, and rxjs.
  • The "devDependencies" section includes the necessary type definitions for "long" and "node", as well as the TypeScript compiler.

The package configuration looks good and is ready to be used for the TypeScript proto generation process.

proto/core/stub/package.json.cjs.template (4)

1-18: LGTM!

The package.json file is well-structured and includes the necessary fields for a CommonJS module.


6-12: Review the dependencies.

The dependencies section includes the required libraries for working with gRPC, protobuf, and RxJS. The versions seem to be properly specified.


13-17: Review the devDependencies.

The devDependencies section includes the necessary type definitions and the TypeScript compiler. The versions seem to be properly specified.


3-5: Verify the gen script.

The gen script runs the TypeScript compiler (tsc). Ensure that the TypeScript configuration file (tsconfig.json) is present in the same directory or a parent directory.

Run the following script to verify the presence of the tsconfig.json file:

Verification successful

To gather more information about the file generation process and verify the content of the tsconfig.json.cjs.template, I'll run the following scripts:


The gen script is correctly configured for TypeScript compilation.

The tsconfig.json.cjs.template file contains a valid TypeScript configuration for CommonJS modules, with appropriate settings for the project. When the actual tsconfig.json file is generated from this template, it will work correctly with the tsc command specified in the gen script.

While we couldn't find specific file generation scripts in the immediate directory, the presence of template files suggests that there's likely a higher-level build process or CI/CD pipeline that handles the generation of actual files from these templates.

To ensure everything works as expected:

  • Verify that the higher-level build process correctly generates the package.json and tsconfig.json files from their respective templates.
  • Confirm that the generated files are placed in the correct locations relative to each other.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of the `tsconfig.json` file.

# Test: Search for the `tsconfig.json` file in the current and parent directories.
# Expect: At least one occurrence of the file.
fd tsconfig.json proto/core/stub

Length of output: 120


Script:

#!/bin/bash
# Search for scripts that might generate files from templates
echo "Searching for file generation scripts:"
rg -i "template|generate" proto/core/stub

# Display the content of tsconfig.json.cjs.template
echo -e "\nContent of tsconfig.json.cjs.template:"
cat proto/core/stub/tsconfig.json.cjs.template

# Check for build or setup scripts in parent directories
echo -e "\nSearching for build or setup scripts in parent directories:"
fd -e sh -e js -e ts -p "build|setup" proto/core

Length of output: 1101

proto/core/stub/tsconfig.json.esm.template (1)

1-16: LGTM!

The TypeScript configuration for ESM modules looks good:

  • It targets modern JavaScript features with "es6" and "esnext".
  • Strict type checking is enabled to catch potential issues.
  • The output directory is set correctly.
  • Interoperability with CommonJS modules is enabled.
  • Relevant libraries are included.
  • The "node_modules" directory is properly excluded.

The configuration is well-suited for generating ESM modules with improved code quality and faster compilation.

proto/indexer/stub/tsconfig.json.esm.template (1)

1-16: LGTM! The TypeScript configuration looks good.

This configuration is set up for generating modern, ES module-compatible JavaScript code along with TypeScript declaration files. Here are the key aspects:

  • Targets ES6 and uses the ESNext module system.
  • Generates declaration files and outputs to the esm directory.
  • Enables strict type checking to catch potential issues.
  • Allows JavaScript files to be included, which is useful for gradual migration.
  • Includes specific lib files for compatibility with different environments and features.

Overall, this configuration is well-structured and suitable for its intended purpose.

proto/core/stub/tsconfig.json.cjs.template (1)

1-16: LGTM!

The TypeScript configuration for the CommonJS module looks good. The compiler options are appropriately set for a Node.js project, enabling strict type checking, generating declaration files, and supporting interoperability between CommonJS and ES modules. The inclusion of specific built-in type definitions allows the usage of necessary JavaScript features and APIs.

proto/indexer/stub/tsconfig.json.cjs.template (1)

1-16: LGTM!

The TypeScript configuration file for the indexer stub is set up correctly with appropriate compiler options for generating CommonJS modules. The configuration follows best practices by enabling strict type checking, compatibility options, and excluding the "node_modules" directory.

proto/core/publish.sh (2)

1-2: LGTM!

The shebang line correctly specifies bash as the interpreter for the script.


6-13: LGTM!

The code segment correctly retrieves the current version of the package, increments the patch version, updates the package version, and publishes the new version.

proto/indexer/publish.sh (1)

1-26: LGTM!

The script follows a clear and logical flow for publishing a new version of the @injectivelabs/indexer-proto-ts package. The package version is incremented using string manipulation and arithmetic operations, which is a common pattern in bash scripts.

The deprecated section for publishing the indexer-api package is properly commented out, providing clarity on its status.

Tools
Shellcheck

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

proto/core/stub/package.json.chain-api.template (1)

23-26: Dependencies look good.

The dependencies section correctly lists the required dependencies, @injectivelabs/grpc-web and google-protobuf, with specific versions. These dependencies seem necessary for the package's functionality.

proto/indexer/stub/package.json.indexer-api.template (2)

1-23: Package metadata looks good!

The package name, version, description, repository, author, license, and issue tracking information are properly specified and follow the recommended conventions.


24-27: Dependencies look fine.

The package dependencies are properly specified, and the versions are using the caret (^) to allow for compatible updates. The @injectivelabs/grpc-web dependency seems to be a custom package for gRPC-Web support, and the google-protobuf dependency is a well-known library for protocol buffers.

proto/indexer/stub/index.ts.template (1)

1-14: LGTM! The index file provides a clean and organized way to export sub-modules.

This index.ts.template file serves as a central entry point for exporting various sub-modules related to the Injective protocol. The approach of re-exporting the sub-modules using the export * as syntax offers several benefits:

  1. It allows other parts of the codebase to import the required sub-modules from a single location, improving code organization and maintainability.
  2. The consistent naming convention (Injective prefix + component name + Rpc suffix) makes it easy to understand the purpose of each sub-module.
  3. The relative import paths indicate that the sub-modules are located in the same directory, keeping the related files together.

Overall, this approach promotes a clean and modular structure for the Injective protocol's TypeScript code.

proto/core/stub/package.json.core-proto-ts.template (4)

1-25: LGTM!

The package metadata is complete and follows the expected format. The name, version, description, and other fields provide clear and relevant information about the package.


8-10: LGTM!

The package entry points are correctly defined for both CommonJS and ECMAScript module systems. This allows the package to be used in a variety of environments.


26-31: LGTM!

The package dependencies are appropriate for a package that provides generated gRPC bindings. The inclusion of google-protobuf, protobufjs, and rxjs aligns with the package's purpose.


32-36: LGTM!

The package development dependencies are appropriate for a TypeScript package. The inclusion of @types/long, @types/node, and typescript provides the necessary type definitions and compiler for developing the package.

proto/indexer/stub/package.json.indexer-proto-ts.template (4)

1-27: LGTM!

The package metadata is well-defined and follows good practices:

  • The package name follows the @scope/package-name convention.
  • The version indicates that this is the initial version of the package.
  • The description clearly explains the purpose of the package.
  • sideEffects is set to false for optimization.
  • Both CommonJS and ECMAScript module entry points are provided.
  • Important metadata like repository, author, and license are included.

28-33: LGTM!

The dependencies are appropriate for a package that provides generated gRPC bindings:

  • @injectivelabs/grpc-web is included for gRPC-Web support.
  • google-protobuf and protobufjs are necessary for working with Protocol Buffers.
  • rxjs is a common choice for reactive programming with gRPC-Web.

34-38: LGTM!

The devDependencies are suitable for a TypeScript package:

  • @types/long provides type definitions for the long library, which is often used with Protocol Buffers.
  • @types/node provides type definitions for Node.js, enabling the use of Node.js APIs in TypeScript.
  • typescript is necessary for compiling the TypeScript code.

1-39: LGTM!

The package.json file is well-structured and includes all the essential sections:

  • Metadata: name, version, description, entry points, repository, etc.
  • Scripts: build and test (placeholder)
  • Dependencies: required packages for the generated gRPC bindings
  • DevDependencies: TypeScript-related dependencies for development

The file provides a solid foundation for the @injectivelabs/indexer-proto-ts package.

proto/README.md (2)

13-20: LGTM!

The support section looks good. It provides a clear list of support channels with appropriate links.


36-38: LGTM!

The final section with the tagline looks good. It provides a clear and concise message that aligns with the project's vision.

package.json (4)

17-17: LGTM!

The addition of the generate:core-proto-ts script for generating TypeScript code from core protocol buffers is a valid and common approach for code generation tasks. It aligns with the PR objective of introducing protocol generation functionality.


18-18: Verify the publishing process.

The addition of the publish:core-proto-ts script for publishing the generated TypeScript code for core protocol buffers is a valid approach. It aligns with the PR objective of introducing protocol generation functionality.

Please ensure that the publish.sh script correctly handles the publishing process, such as authenticating with the package registry, versioning, and any necessary pre-publish steps.


19-19: LGTM!

The addition of the generate:indexer-proto-ts script for generating TypeScript code from indexer protocol buffers is a valid and common approach for code generation tasks. It aligns with the PR objective of introducing protocol generation functionality.


20-20: Verify the publishing process.

The addition of the publish:indexer-proto-ts script for publishing the generated TypeScript code for indexer protocol buffers is a valid approach. It aligns with the PR objective of introducing protocol generation functionality.

Please ensure that the publish.sh script correctly handles the publishing process, such as authenticating with the package registry, versioning, and any necessary pre-publish steps.

proto/indexer/gen.sh (1)

115-117: Verify the file extensions in cleanup commands

The find commands are deleting files with extensions *.jse, *.tse, and *.jsone. These seem uncommon and may indicate a typo or unintended deletions.

Double-check these extensions to ensure that only unwanted files are deleted and that important files are not accidentally removed.

proto/core/publish.sh Show resolved Hide resolved
proto/indexer/publish.sh Show resolved Hide resolved
proto/indexer/gen.sh Show resolved Hide resolved
proto/indexer/gen.sh Show resolved Hide resolved
proto/core/gen.sh Outdated Show resolved Hide resolved
proto/core/gen.sh Show resolved Hide resolved
proto/core/gen.sh Show resolved Hide resolved
proto/core/stub/index.ts.template Show resolved Hide resolved
proto/core/stub/index.ts.template Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e3cac2 and 75e767f.

Files selected for processing (7)
  • packages/sdk-ts/src/core/accounts/PrivateKey.ts (2 hunks)
  • packages/sdk-ts/src/core/modules/tx/utils/tx.ts (3 hunks)
  • proto/core/gen.sh (1 hunks)
  • proto/core/publish.sh (1 hunks)
  • proto/core/stub/index.ts.template (1 hunks)
  • proto/indexer/gen.sh (1 hunks)
  • proto/indexer/publish.sh (1 hunks)
Additional context used
Shellcheck
proto/core/gen.sh

[warning] 71-71: Quote this to prevent word splitting.

(SC2046)

proto/core/publish.sh

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

proto/indexer/gen.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 54-54: Quote this to prevent word splitting.

(SC2046)

proto/indexer/publish.sh

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

Additional comments not posted (20)
proto/core/publish.sh (1)

3-4: ** Use cd ... || exit for the first cd command.**

The past review comment is still valid and applicable to the current code segment. To handle the case where cd fails, use cd ... || exit for the first cd command. This will ensure that the script exits if it cannot change to the ./proto/core directory.

Apply this diff to fix the issue:

-cd ./proto/core
+cd ./proto/core || exit
 cd ./proto-ts || exit
Tools
Shellcheck

[warning] 3-3: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

proto/indexer/gen.sh (6)

1-1: Add a shebang line to specify the shell interpreter

As mentioned in a previous review, the script lacks a shebang line at the beginning, which specifies the interpreter to execute the script. It's recommended to add #!/bin/bash at the top to ensure it's interpreted correctly.

Tools
Shellcheck

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


32-32: Correct the find command in proto_dirs assignment

As pointed out in a previous review, the find command used to populate proto_dirs has an incorrect usage of the -path and -prune options, which might lead to unintended results or an empty variable.

Modify the command to correctly find directories containing .proto files:

-proto_dirs=$(find $PROTO_DIR -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
+proto_dirs=$(find $PROTO_DIR -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)

37-40: Fix the loop to correctly rename proto files in multiple directories

As mentioned in a previous review, the loop assumes $proto_dirs is a single directory, which may not be the case if multiple directories contain .proto files. This can cause the mv command to fail or skip files.

Adjust the loop to iterate over each directory and process the files within:

-for file in $proto_dirs/goadesign_goagen_*.proto; do
+for dir in $proto_dirs; do
+  for file in "$dir"/goadesign_goagen_*.proto; do
     new_file=$(basename "$file" | sed 's/^goadesign_goagen_//')
-    mv "$file" "$proto_dirs/$new_file"
+    mv "$file" "$dir/$new_file"
+  done
 done

54-54: Handle filenames with spaces in the protoc command

As pointed out in a previous review and flagged by Shellcheck, the unquoted command substitution may cause issues if any .proto filenames contain spaces. This could lead to protoc failing to process all intended files.

Modify the command to safely handle filenames with spaces:

-    $(find "${dir}" -maxdepth 1 -name '*.proto')
+    $(find "${dir}" -maxdepth 1 -name '*.proto' -print0 | xargs -0)
Tools
Shellcheck

[warning] 54-54: Quote this to prevent word splitting.

(SC2046)


57-58: Ensure .js and .d.ts files are available before deletion

As mentioned in a previous review, the script deletes all .js and .d.ts files in $TS_OUTPUT_DIR/proto, but later attempts to modify .d.ts files in lines 81-87. Deleting these files before modification may result in errors.

Reorder the script to delete these files after all necessary modifications are complete:

 # gen using ts-proto
 npm --prefix $ROOT_DIR install
 for dir in $proto_dirs; do
     protoc \
     --plugin="$ROOT_DIR/node_modules/.bin/protoc-gen-ts_proto" \
     --ts_proto_opt="esModuleInterop=true" \
     --ts_proto_opt="forceLong=string" \
     --ts_proto_opt="env=both" \
     --ts_proto_opt="useExactTypes=false" \
     --ts_proto_opt="outputClientImpl=grpc-web" \
     --ts_proto_out="$TS_OUTPUT_DIR/proto" \
     -I "$PROTO_DIR" \
     $(find "${dir}" -maxdepth 1 -name '*.proto' -print0 | xargs -0)
 done

+# Modify .d.ts files here (lines 81-87)
+
+# Now safe to delete .js and .d.ts files
 find $TS_OUTPUT_DIR/proto -name "*.js" -type f -delete
 find $TS_OUTPUT_DIR/proto -name "*.d.ts" -type f -delete

81-87: Confirm the existence of .d.ts files before modification

As pointed out in a previous review, after deleting .d.ts files in line 58, the script attempts to modify them here. This will fail if the files no longer exist.

Ensure that the modifications to .d.ts files occur before they are deleted, or remove the deletion if it's unnecessary.

proto/core/gen.sh (5)

17-19: ****

The comment from the previous review still applies:

Quote variables in rm -rf commands to prevent globbing and word splitting.

It's a good practice to quote variables in rm -rf commands to avoid unexpected behavior if variables contain spaces or are empty.

Apply the following diff to fix the issue:

-rm -rf $BUILD_DIR
-rm -rf $PROTO_DIR
-rm -rf $TS_OUTPUT_DIR
+rm -rf "$BUILD_DIR"
+rm -rf "$PROTO_DIR"
+rm -rf "$TS_OUTPUT_DIR"

40-41: ****

The comment from the previous review still applies:

Quote variables in commands to prevent word splitting and globbing.

Variables like $BUILD_DIR, $PROTO_DIR, and branch variables should be quoted when used in commands to prevent issues if they contain spaces.

Apply the following diff to fix the issue:

-git clone https://github.com/InjectiveLabs/injective-core.git $BUILD_DIR/injective-core -b $injective_core_branch --depth 1 --single-branch > /dev/null
-cp -r $BUILD_DIR/injective-core/proto/injective $PROTO_DIR
+git clone https://github.com/InjectiveLabs/injective-core.git "$BUILD_DIR"/injective-core -b "$injective_core_branch" --depth 1 --single-branch > /dev/null
+cp -r "$BUILD_DIR"/injective-core/proto/injective "$PROTO_DIR"

44-46: ****

The comment from the previous review about quoting variables also applies to these lines:

Quote variables in commands to prevent word splitting and globbing.

Apply the following diff to fix the issue:

-git clone https://github.com/InjectiveLabs/cosmos-sdk.git $BUILD_DIR/cosmos-sdk -b $cosmos_sdk_branch --depth 1 --single-branch > /dev/null
-git clone https://github.com/InjectiveLabs/wasmd $BUILD_DIR/wasmd -b $wasmd_branch --depth 1 --single-branch > /dev/null 
-git clone https://github.com/InjectiveLabs/ibc-go $BUILD_DIR/ibc-go -b $ibc_go_branch --depth 1 --single-branch > /dev/null
+git clone https://github.com/InjectiveLabs/cosmos-sdk.git "$BUILD_DIR"/cosmos-sdk -b "$cosmos_sdk_branch" --depth 1 --single-branch > /dev/null
+git clone https://github.com/InjectiveLabs/wasmd "$BUILD_DIR"/wasmd -b "$wasmd_branch" --depth 1 --single-branch > /dev/null
+git clone https://github.com/InjectiveLabs/ibc-go "$BUILD_DIR"/ibc-go -b "$ibc_go_branch" --depth 1 --single-branch > /dev/null

71-71: ****

The comment from the previous review still applies:

Quote the command substitution to prevent word splitting.

In the protoc command, the find command substitution should be quoted to prevent word splitting, which can cause issues if filenames contain spaces.

Apply the following diff to fix the issue:

-        $(find "${dir}" -maxdepth 1 -name '*.proto')
+        "$(find "${dir}" -maxdepth 1 -name '*.proto')"

This is also confirmed by the static analysis hint from Shellcheck.

Tools
Shellcheck

[warning] 71-71: Quote this to prevent word splitting.

(SC2046)


1-139: LGTM!

The overall script looks good with no additional issues found. It follows good practices such as:

  • Using set -eo pipefail for error handling
  • Using meaningful variable names and consistent naming convention
  • Well-structured with clear comments and sections for each step
  • Handling cleanup of temporary directories at the end

The script is complex but well-written and follows a logical flow for generating TypeScript code from proto definitions.

Tools
Shellcheck

[warning] 71-71: Quote this to prevent word splitting.

(SC2046)

packages/sdk-ts/src/core/modules/tx/utils/tx.ts (2)

Line range hint 203-216: LGTM!

The changes to the createTxRawEIP712 function are consistent with the migration from InjectiveTypesV1TxExt to InjectiveTypesV1Beta1TxExt. The logic remains the same, and the updated type is used correctly for the extension parameter.


Line range hint 227-239: LGTM!

The changes to the createWeb3Extension function are consistent with the migration from InjectiveTypesV1TxExt to InjectiveTypesV1Beta1TxExt. The logic remains the same, and the updated type is used correctly for creating the web3Extension.

packages/sdk-ts/src/core/accounts/PrivateKey.ts (2)

12-12: LGTM!

The import statement update from InjectiveTypesV1TxExt to InjectiveTypesV1Beta1TxExt aligns with the semantic versioning convention and is unlikely to cause breaking changes.


363-363: Verify the consistency of the type update across the codebase.

The usage of InjectiveTypesV1Beta1TxExt for decoding the extension value is consistent with the import statement update. However, please ensure that all other occurrences of InjectiveTypesV1TxExt have been consistently updated to InjectiveTypesV1Beta1TxExt to maintain coherence and avoid potential issues.

Run the following script to verify the consistency of the type update:

Verification successful

Type update consistently applied across the codebase

The verification process confirms that the update from InjectiveTypesV1TxExt to InjectiveTypesV1Beta1TxExt has been consistently applied throughout the codebase. No occurrences of the old type were found, and the new type is correctly used in both relevant files: PrivateKey.ts and tx.ts. This consistency ensures that the codebase maintains coherence and avoids potential issues related to type mismatches.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all occurrences of `InjectiveTypesV1TxExt` have been updated to `InjectiveTypesV1Beta1TxExt`.

# Test 1: Search for occurrences of `InjectiveTypesV1TxExt`. Expect: No results found.
rg --type ts 'InjectiveTypesV1TxExt'

# Test 2: Search for occurrences of `InjectiveTypesV1Beta1TxExt`. Expect: At least one result found.
rg --type ts 'InjectiveTypesV1Beta1TxExt'

Length of output: 737

proto/core/stub/index.ts.template (4)

107-108: Typo in 'IbcLightcients' remains

The typo in the module names on lines 107 and 108 is still present. It should be IbcLightclients instead of IbcLightcients.


153-153: Ensure consistent versioning in export names

The export on line 153 is missing the V1Beta1 version information, which is included in other exports for consistency.


24-25: Verify if the commented-out exports are intentional

Lines 24 and 25 contain exports that are commented out. Please verify if these modules are intentionally excluded or if they should be included.

You can run the following script to check if any code in the codebase imports these modules:

#!/bin/bash
# Description: Search for usages of the commented-out modules.

# Expected result: No files should import these modules.

rg 'from ".*\/capability\/v1\/' --type=typescript

85-89: Confirm the exclusion of IbcApplicationsTransferV2 modules

The exports for IbcApplicationsTransferV2 modules are commented out in lines 85 to 89. Please confirm whether these modules are intentionally excluded or should be included in the exports.

You can run the following script to check if these modules are used elsewhere in the codebase:

Verification successful

Exclusion of IbcApplicationsTransferV2 modules confirmed

After a thorough search of the codebase, it appears that the exclusion of IbcApplicationsTransferV2 modules is intentional. Our verification process included searching for:

  1. Imports of these modules
  2. Any mentions of the path 'ibc/applications/transfer/v2'
  3. Case-insensitive references to 'IbcApplicationsTransferV2'

None of these searches returned any results, indicating that these modules are not used anywhere in the codebase. Therefore, commenting out the exports for these modules (lines 85-89) is appropriate and doesn't seem to impact the rest of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for imports of the IbcApplicationsTransferV2 modules.

# Expected result: No files should import these modules.

rg 'from ".*\/ibc\/applications\/transfer\/v2\/' --type=typescript

Length of output: 246


Script:

#!/bin/bash
# Description: Search for imports and references of the IbcApplicationsTransferV2 modules.

# Search for imports
echo "Searching for imports of IbcApplicationsTransferV2 modules:"
rg 'from ".*\/ibc\/applications\/transfer\/v2\/' --type=typescript

# Search for any references to IbcApplicationsTransferV2
echo "Searching for references to IbcApplicationsTransferV2 modules:"
rg 'IbcApplicationsTransferV2' --type=typescript

Length of output: 534


Script:

#!/bin/bash
# Description: Search for imports and references of the IbcApplicationsTransferV2 modules.

# Search for imports
echo "Searching for imports of IbcApplicationsTransferV2 modules:"
rg 'from ".*\/ibc\/applications\/transfer\/v2\/' --type-add 'ts:*.ts,*.tsx' -t ts

# Search for any references to IbcApplicationsTransferV2
echo "Searching for references to IbcApplicationsTransferV2 modules:"
rg 'IbcApplicationsTransferV2' --type-add 'ts:*.ts,*.tsx' -t ts

# If the above searches don't yield results, search for any mentions of ibc/applications/transfer/v2
echo "Searching for any mentions of ibc/applications/transfer/v2:"
rg 'ibc\/applications\/transfer\/v2' --type-add 'ts:*.ts,*.tsx' -t ts

Length of output: 831


Script:

#!/bin/bash
# Description: Final search for imports and references of the IbcApplicationsTransferV2 modules.

# Search for imports
echo "Searching for imports of IbcApplicationsTransferV2 modules:"
rg 'from ".*/ibc/applications/transfer/v2/' --type-add 'ts:*.ts,*.tsx' -t ts

# Search for any mentions of ibc/applications/transfer/v2
echo "Searching for any mentions of ibc/applications/transfer/v2:"
rg 'ibc/applications/transfer/v2' --type-add 'ts:*.ts,*.tsx' -t ts

# Search for any mentions of IbcApplicationsTransferV2 (case-insensitive)
echo "Searching for any mentions of IbcApplicationsTransferV2 (case-insensitive):"
rg -i 'ibcapplicationstransferv2' --type-add 'ts:*.ts,*.tsx' -t ts

Length of output: 631

proto/core/stub/index.ts.template Show resolved Hide resolved
@bangjelkoski bangjelkoski merged commit 2ace9d0 into dev Sep 21, 2024
3 checks passed
@bangjelkoski bangjelkoski deleted the feat/proto-generation branch September 21, 2024 08:38
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