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

fix(release): please publish changes from develop #266

Closed
wants to merge 1 commit into from

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Dec 13, 2023



Summary by CodeRabbit

  • New Features

    • Search functionality now includes a new "Run examples" step for executing TypeScript scripts.
    • Documentation has been updated with new badges, links, and restructured examples for wallet creation and transactions.
    • New interface ABCIEvent and class Result<T> added to the SDK documentation.
  • Bug Fixes

    • Corrected the image source path for the Nibiru logo in the README.
    • Updated URLs in test files to point to the correct Nibiru network endpoints.
  • Documentation

    • Added and updated method descriptions and parameters in the SDK documentation.
    • Updated version references and line numbers in the documentation to reflect the latest changes.
  • Refactor

    • Renamed various classes and methods to improve clarity and consistency across the SDK.
    • Ignored example paths in module loader configuration to streamline testing.
  • Style

    • Enhanced code comments and documentation for better understanding and maintenance.
  • Tests

    • Expanded test coverage with new cases for blockchain network interactions and utility functions.
  • Chores

    • Updated internal references and links to match the new versioning and repository structure.

* feat(feat): develop/main

* fix(fix): fix

* fix(test): fix

* fix(nibijs): examples up-to-date + more docs + test examples in CI (#254)

* fix(fix): markdown (#256)

* fix(nibijs): NibiruQueryClient must expose methods from the Tendermint client (#257)

* refactor: custom chain for mainnet (#262)

* refactor: custom chain for mainnet

* test: increase open handle timeout

* test: adding --watchAll --no-cache

* ci: removing --watchall and --no-cache

* feat(nibijs): functions for humans + getTxByHash (exchange integration) (#260)

* fix(nibijs): NibiruQueryClient must expose methods from the Tendermint client

* feat(nibijs): functions for humans + getTxByHash

* chore(nibijs): build docs

* test(nibijs): fix import

* refactor(nibijs): remove unused fn, 'go', and use Result instead

* docs(nibijs-result): function docs

* test: fix by removing usage of go in test

* test: fix inactive chaint est

* test: fix inactive chaint est

* test: address PR comments

* chore(nibijs): rebuild docs

* Update packages/nibijs/src/result.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: initChainId couldn't handle number == 0 case

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: yarn merge

* fix: align chain id (#263)

* fix: align chain id

* fix: merge

* fix: merge

* fix: test

* fix: fix

* fix: fix

* fix: rem readme

* fix: point tests at devnet

* refactor(nibijs)!: NibiruSigningClient -> NibiruTxClient, NibiruQueryClient -> NibiruQuerier (#265)

* refactor(nibijs)!: NibiruSigningClient -> NibiruTxClient, NibiruQueryClient -> NibiruQuerier

* chore: rebuild docs + txClient file name

---------

Co-authored-by: Unique Divine <[email protected]>
Co-authored-by: Karim El Shenawy <[email protected]>
Co-authored-by: elshenak <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

coderabbitai bot commented Dec 13, 2023

Walkthrough

The updates reflect a significant overhaul of the Nibiru blockchain's TypeScript SDK, including workflow enhancements, documentation updates, and codebase improvements. Key changes include the renaming of classes and methods to better reflect their functionality, the addition of new features and helper functions, and the restructuring of examples to align with the updated SDK. The documentation has been meticulously updated to match the codebase changes, ensuring developers have accurate references.

Changes

File Path Change Summary
.github/workflows/... Updated workflow steps, including renaming, adding new steps, and enhancing scripts.
README.md Changed image source, added badges, updated links, and restructured examples.
jest.config.js Updated module loader ignore patterns.
packages/examples/... Added code for blockchain network interaction and examples.
packages/indexer-nibi/... Updated URLs in test files.
packages/nibijs/docs/... Updated documentation with new classes, methods, interfaces, and version references.
packages/nibijs/src/... Codebase updates including new functions, class renames, and export modifications.

Poem

🐇 "In the realm of code, where changes abound,
🌟 A rabbit hopped in, with updates profound.
📜 Docs aligned, and examples refined,
🚀 To the stars we go, with Nibiru entwined!"

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@Unique-Divine
Copy link
Member Author

Opened incorrectly

Copy link
Contributor

@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.

Review Status

Actionable comments generated: 17

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ea490c7 and 5a548d1.
Files ignored due to filter (9)
  • examples/package.json
  • examples/yarn.lock
  • img/nibijs.png
  • package-lock.json
  • package.json
  • packages/examples/package.json
  • packages/nibijs/package.json
  • packages/nibijs/tsconfig.json
  • yarn.lock
Files selected for processing (57)
  • .github/workflows/test-ts-sdk.yaml (3 hunks)
  • README.md (5 hunks)
  • jest.config.js (1 hunks)
  • packages/examples/README.md (1 hunks)
  • packages/examples/examples.test.ts (1 hunks)
  • packages/indexer-nibi/src/batchHandlers/queryBatchHandler.test.ts (1 hunks)
  • packages/indexer-nibi/src/heart-monitor.test.ts (1 hunks)
  • packages/nibijs/docs/classes/CustomChain.md (12 hunks)
  • packages/nibijs/docs/classes/MsgFactory.md (3 hunks)
  • packages/nibijs/docs/classes/NibiruQuerier.md (1 hunks)
  • packages/nibijs/docs/classes/NibiruTxClient.md (7 hunks)
  • packages/nibijs/docs/classes/PerpMsgFactory.md (8 hunks)
  • packages/nibijs/docs/classes/Result.md (1 hunks)
  • packages/nibijs/docs/classes/SpotMsgFactory.md (5 hunks)
  • packages/nibijs/docs/classes/StableSwap.md (11 hunks)
  • packages/nibijs/docs/enums/BECH32_PREFIX.md (7 hunks)
  • packages/nibijs/docs/enums/Signer.md (3 hunks)
  • packages/nibijs/docs/interfaces/ABCIEvent.md (1 hunks)
  • packages/nibijs/docs/interfaces/Chain.md (7 hunks)
  • packages/nibijs/docs/interfaces/ChainIdParts.md (2 hunks)
  • packages/nibijs/docs/interfaces/CoinMap.md (1 hunks)
  • packages/nibijs/docs/interfaces/EpochsExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/EventAttribute.md (1 hunks)
  • packages/nibijs/docs/interfaces/EventMap.md (1 hunks)
  • packages/nibijs/docs/interfaces/EventMapAttribute.md (1 hunks)
  • packages/nibijs/docs/interfaces/InflationExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/MsgAddMarginEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgClosePositionEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgCreatePoolEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgDonateToEcosystemFundEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgExitPoolEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgJoinPoolEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgMultiLiquidateEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgOpenPositionEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgPartialCloseEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgRemoveMarginEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgSwapAssetsEncodeObject.md (3 hunks)
  • packages/nibijs/docs/interfaces/MsgTypeUrls.md (1 hunks)
  • packages/nibijs/docs/interfaces/OracleExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/PageRequest.md (6 hunks)
  • packages/nibijs/docs/interfaces/PerpExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/SpotExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/SudoExtension.md (2 hunks)
  • packages/nibijs/docs/interfaces/TxLog.md (2 hunks)
  • packages/nibijs/docs/interfaces/TxMessage.md (1 hunks)
  • packages/nibijs/docs/intro.md (5 hunks)
  • packages/nibijs/docs/modules.md (46 hunks)
  • packages/nibijs/src/chain/chain.ts (6 hunks)
  • packages/nibijs/src/chain/parse.ts (3 hunks)
  • packages/nibijs/src/chain/types.ts (3 hunks)
  • packages/nibijs/src/hash.test.ts (1 hunks)
  • packages/nibijs/src/hash.ts (1 hunks)
  • packages/nibijs/src/index.ts (1 hunks)
  • packages/nibijs/src/msg/index.ts (1 hunks)
  • packages/nibijs/src/msg/perp.ts (1 hunks)
  • packages/nibijs/src/query/query.ts (5 hunks)
  • packages/nibijs/src/result.ts (1 hunks)
Files not processed due to max files limit (10)
  • packages/nibijs/src/test/chain.test.ts
  • packages/nibijs/src/test/faucet.test.ts
  • packages/nibijs/src/test/helpers.ts
  • packages/nibijs/src/test/query.test.ts
  • packages/nibijs/src/testutil.ts
  • packages/nibijs/src/tx/event.ts
  • packages/nibijs/src/tx/index.ts
  • packages/nibijs/src/tx/signer.ts
  • packages/nibijs/src/tx/txClient.test.ts
  • packages/nibijs/src/tx/txClient.ts
Files skipped from review due to trivial changes (31)
  • .github/workflows/test-ts-sdk.yaml
  • packages/examples/README.md
  • packages/indexer-nibi/src/batchHandlers/queryBatchHandler.test.ts
  • packages/nibijs/docs/classes/MsgFactory.md
  • packages/nibijs/docs/classes/NibiruTxClient.md
  • packages/nibijs/docs/classes/PerpMsgFactory.md
  • packages/nibijs/docs/classes/SpotMsgFactory.md
  • packages/nibijs/docs/enums/BECH32_PREFIX.md
  • packages/nibijs/docs/enums/Signer.md
  • packages/nibijs/docs/interfaces/Chain.md
  • packages/nibijs/docs/interfaces/CoinMap.md
  • packages/nibijs/docs/interfaces/EpochsExtension.md
  • packages/nibijs/docs/interfaces/EventAttribute.md
  • packages/nibijs/docs/interfaces/EventMapAttribute.md
  • packages/nibijs/docs/interfaces/InflationExtension.md
  • packages/nibijs/docs/interfaces/MsgAddMarginEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgClosePositionEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgCreatePoolEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgExitPoolEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgMultiLiquidateEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgOpenPositionEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgPartialCloseEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgRemoveMarginEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgSwapAssetsEncodeObject.md
  • packages/nibijs/docs/interfaces/MsgTypeUrls.md
  • packages/nibijs/docs/interfaces/OracleExtension.md
  • packages/nibijs/docs/interfaces/PageRequest.md
  • packages/nibijs/docs/interfaces/PerpExtension.md
  • packages/nibijs/docs/interfaces/SpotExtension.md
  • packages/nibijs/docs/interfaces/SudoExtension.md
  • packages/nibijs/docs/interfaces/TxMessage.md
Additional comments: 133
README.md (5)
  • 1-35: The addition of the image and badges to the README.md enhances the visual appeal and provides useful information at a glance.

  • 49-54: The update to the documentation link and the addition of the license section in the table of contents are clear and helpful for users.

  • 69-80: The newRandomWallet function is indeed part of the nibijs package, as it is found within the packages/nibijs/src/tx/signer.ts file. This confirms that the function is available for use as demonstrated in the README example.

Analysis chain

The example for creating a wallet is clear and demonstrates the usage of the newRandomWallet function. Ensure that this function is properly exported from @nibiruchain/nibijs.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `newRandomWallet` is exported from `@nibiruchain/nibijs`
ast-grep --lang javascript --pattern $'export function newRandomWallet($_) {
  $$$
}'

Length of output: 86



Script:

#!/bin/bash
# Broaden the search to find any export statement that includes `newRandomWallet`
ast-grep --lang javascript --pattern $'export {
  $$$
  newRandomWallet
  $$$
}'

Length of output: 81



Script:

#!/bin/bash
# Search for any file that contains an export of `newRandomWallet`
rg "export.*newRandomWallet" --files-with-matches

Length of output: 84

* 83-187: The search results confirm that the old class names `NibiruQueryClient` and `NibiruSigningClient` are not found in the codebase, which is consistent with the PR's objective to rename these classes. The new class names `NibiruQuerier` and `NibiruTxClient` are found in multiple files, indicating that the renaming has been applied throughout the codebase.

Based on the provided output, the changes have been successfully verified:

  • The old class names are not present in the codebase.
  • The new class names are being used in various files.
Analysis chain

The examples have been updated to reflect the renaming of core classes and the use of new imports from @cosmjs/proto-signing. Verify that these changes are consistent throughout the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `NibiruQuerier` and `NibiruTxClient` are used instead of the old names throughout the codebase.
rg 'NibiruQueryClient' || echo "Old class name 'NibiruQueryClient' not found."
rg 'NibiruSigningClient' || echo "Old class name 'NibiruSigningClient' not found."
rg 'NibiruQuerier' && echo "New class name 'NibiruQuerier' found."
rg 'NibiruTxClient' && echo "New class name 'NibiruTxClient' found."

Length of output: 9337

* 199-228: The development quick start steps are a useful addition for new contributors. Verify that the referenced `nvm` version and the steps provided are up to date and correct.
jest.config.js (1)
  • 97-97: The update to modulePathIgnorePatterns to include "packages/examples" is consistent with the PR's objective to enhance test configurations and aligns with the AI-generated summary.
packages/examples/examples.test.ts (3)
  • 1-14: The imports from @nibiruchain/nibijs reflect the updated class names (NibiruTxClient, NibiruQuerier) and other mentioned changes, which align with the PR objectives and AI-generated overview.

  • 85-92: Ensure that the mnemonic logged in exampleNewWallet is not a real user's mnemonic but a test mnemonic intended for example purposes only.

  • 116-116: The use of sleep to avoid account sequence issues is a workaround. If this is intended for example purposes only, it's acceptable, but for production code, a more robust solution should be implemented.

Also applies to: 175-175

packages/indexer-nibi/src/heart-monitor.test.ts (1)
  • 98-101: The change of the nibiruUrl constant from "itn-3" to "devnet-2" will affect the base URL used throughout the tests. Verify that "devnet-2" is the correct and intended environment for these tests and that the environment is properly set up to handle the requests made by the tests.
packages/nibijs/docs/classes/CustomChain.md (12)
  • 1-4: The version update in the documentation header is noted and appears to be correct.

  • 13-13: The update of the shortName property from "itn" to "testnet" in the example code is consistent with the PR objectives and AI-generated summary.

  • 57-57: The updated line number for the constructor definition in the documentation reflects the changes in the chain.ts file.

  • 73-73: The updated line number for the chainId property definition in the documentation reflects the changes in the chain.ts file.

  • 83-83: The updated line number for the chainIdParts property definition in the documentation reflects the changes in the chain.ts file.

  • 99-99: The updated line number for the chainName property definition in the documentation reflects the changes in the chain.ts file.

  • 115-115: The updated line number for the endptGrpc property definition in the documentation reflects the changes in the chain.ts file.

  • 131-131: The updated line number for the endptRest property definition in the documentation reflects the changes in the chain.ts file.

  • 147-147: The updated line number for the endptTm property definition in the documentation reflects the changes in the chain.ts file.

  • 163-163: The updated line number for the feeDenom property definition in the documentation reflects the changes in the chain.ts file.

  • 177-177: The updated line number for the initChainId method definition in the documentation reflects the changes in the chain.ts file.

  • 197-197: The updated line number for the fromChainId method definition in the documentation reflects the changes in the chain.ts file.

packages/nibijs/docs/classes/NibiruQuerier.md (1)
  • 3-39: The documentation updates for the NibiruQuerier class appear to be comprehensive and include the necessary details about constructors, properties, and methods. Ensure that the code examples provided are tested and functional, and that the links to the code definitions are verified to be correct.
packages/nibijs/docs/classes/Result.md (6)
  • 1-11: The introduction and reference to Rust's Result type provide a good context for the purpose of this class. It's important that the implementation of Result in the nibijs package follows the principles outlined here for error handling.

  • 13-37: The examples provided are clear and demonstrate both the common use-case with Result.ofSafeExec and direct construction of a Result object. This should help users understand how to use the class in different scenarios.

  • 39-61: The table of contents is well-organized, providing a quick overview of what's available in the Result class. It's important that the links to the source code are correct and that the actual source code matches this documentation.

  • 63-85: The constructor documentation correctly details the type parameters and destructured object parameter with optional err and ok properties. The link to the source code is provided, which is good practice for transparency and further exploration.

  • 87-105: The properties err and ok are documented with their types, which is crucial for users to understand what values they can expect from a Result object. The links to the source code are also provided.

  • 107-195: The methods are documented with their return types and a brief description. The ofSafeExecAsync method includes an example, which is useful for asynchronous use cases. It's important that these methods work as described and that the examples provided are accurate and functional.

packages/nibijs/docs/classes/StableSwap.md (11)
  • 1-4: Updated documentation version from v0.21.41 to v0.21.42.

  • 57-57: Updated source code reference for the constructor.

  • 67-67: Updated source code reference for the Amplification property.

  • 77-77: Updated source code reference for the fee property.

  • 87-87: Updated source code reference for the totalTokenSupply property.

  • 97-97: Updated source code reference for the totalTokensInPool property.

  • 120-120: Updated source code reference for the D method.

  • 148-148: Updated source code reference for the exchange method.

  • 168-168: Updated source code reference for the xp method.

  • 181-184: Modified mathematical equation in the y method description. Ensure that this change is accurate and reflects the intended logic of the y method.

  • 204-204: Updated source code reference for the y method.

packages/nibijs/docs/interfaces/ABCIEvent.md (1)
  • 1-36: The output from the latest script confirms that the attributes property is defined on line 23 and the type property is defined on line 22 in the event.ts file, as was indicated in the documentation links provided in the ABCIEvent.md file.

Therefore, the documentation for the ABCIEvent interface is accurate with respect to the source code links for the attributes and type properties.

The review comment can be addressed as follows:

The documentation for the ABCIEvent interface has been verified, and the source code links for the attributes and type properties correctly point to their definitions in the event.ts file.

Analysis chain

The documentation for the ABCIEvent interface appears to be correctly updated with descriptions and links to the source code. Verify that the source code links point to the correct lines where attributes and type are defined.


The shell script intended to verify the correct line numbers for the definitions of attributes and type properties within the ABCIEvent interface did not produce any output. This could mean that the properties are not defined on the lines specified in the documentation or that there was an issue with the script execution.

To ensure accuracy, I will generate a new script to check the entire event.ts file for the definitions of attributes and type without specifying line numbers. This will help confirm whether these properties are indeed present in the file and provide their correct line numbers.


The new script output confirms the presence of the attributes and type properties within the event.ts file. However, the output does not include line numbers, which are necessary to verify the accuracy of the documentation links provided in the ABCIEvent.md file.

To rectify this, I will generate a new script that includes the -n flag with the rg command to include line numbers in the output. This will allow us to confirm the exact line numbers where the attributes and type properties are defined.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the attributes property is defined on line 23 of event.ts
rg --context 2 'attributes' 'packages/nibijs/src/tx/event.ts' | grep -B 1 -A 1 '23:'

# Verify that the type property is defined on line 22 of event.ts
rg --context 2 'type' 'packages/nibijs/src/tx/event.ts' | grep -B 1 -A 1 '22:'

Length of output: 155



Script:

#!/bin/bash
# Search for the definition of the attributes property in event.ts
rg 'attributes' 'packages/nibijs/src/tx/event.ts'

# Search for the definition of the type property in event.ts
rg 'type' 'packages/nibijs/src/tx/event.ts'

Length of output: 814



Script:

#!/bin/bash
# Search for the definition of the attributes property in event.ts with line numbers
rg -n 'attributes' 'packages/nibijs/src/tx/event.ts'

# Search for the definition of the type property in event.ts with line numbers
rg -n 'type' 'packages/nibijs/src/tx/event.ts'

Length of output: 862

packages/nibijs/docs/interfaces/ChainIdParts.md (1)
  • 1-45: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-52]

The documentation for the ChainIdParts interface has been correctly updated to include the new optional mainnet property and to mark the prefix property as optional. The links to the source code are provided, which is good for maintainability and traceability.

packages/nibijs/docs/interfaces/EventMap.md (2)
  • 20-20: The representation of the amount as a string to avoid precision issues is correct.

  • 42-44: The use of a permalink in the Defined in section is good practice to ensure the documentation remains accurate over time.

packages/nibijs/docs/interfaces/MsgDonateToEcosystemFundEncodeObject.md (3)
  • 1-4: The version update in the documentation header is consistent with the PR's objectives of releasing new changes.

  • 30-30: The updated URL reference to the msg/perp.ts file is correct and points to the new commit d8a549e.

  • 44-44: The updated URL reference for the value property definition is correct and points to the new commit d8a549e.

packages/nibijs/docs/interfaces/MsgJoinPoolEncodeObject.md (3)
  • 1-4: The version update in the documentation header is consistent with the release preparation.

  • 30-30: The updated URL reference in the documentation ensures that it points to the correct version of the code associated with this release.

  • 44-44: The updated URL reference for the value property is also correctly pointing to the new commit hash in the repository.

packages/nibijs/docs/interfaces/TxLog.md (3)
  • 1-4: The version update in the documentation is noted and correct.

  • 13-19: The update of the events property type from Event[] to ABCIEvent[] in the TxLog interface is consistent with the PR objectives and the AI-generated summary.

  • 17-19: The documentation correctly updates the reference link to the new line number for the definition of events.

packages/nibijs/docs/intro.md (5)
  • 4-37: The addition of badges and updated image URL enhances the visual appeal and provides quick access to relevant information. These changes are consistent with the PR's objective to improve documentation.

  • 54-56: The addition of a link to Nibiru's documentation and the change in markdown header size for the license section are appropriate and improve the document's navigability and formatting.

  • 74-82: The new example for creating a wallet using newRandomWallet is clear and concise, effectively demonstrating the updated usage pattern.

  • 85-190: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [88-225]

The example code has been updated to reflect the renaming of classes and functions, aligning with the PR's objectives to rename NibiruSigningClient to NibiruTxClient, NibiruQueryClient to NibiruQuerier, and other related changes. The examples are updated to use the new Localnet constant and the new import paths, ensuring consistency with the latest codebase.

  • 204-230: The addition of development setup instructions is a valuable guide for new contributors or developers, enhancing the documentation's utility and aligning with the PR's goal of improving documentation.
packages/nibijs/docs/modules.md (46)
  • 1-6: The version number update in the documentation header is correct.

  • 13-22: The renaming of NibiruQueryClient to NibiruQuerier and NibiruSigningClient to NibiruTxClient, as well as the addition of the Result class, are correctly reflected in the documentation.

  • 23-35: The addition of new interfaces ABCIEvent, EventAttribute, EventMap, and EventMapAttribute is correctly documented.

  • 58-71: The addition of new variables ERR, TEST_ADDRESS, TEST_CHAIN, and TEST_MNEMONIC is correctly documented.

  • 74-95: The addition of new functions such as assertExpectedError, assertHasEventType, assertHasMsgType, assertValidBlock, assertValidBlockFromJsonRpc, bytesToHex, eventToMap, faucetUrlFromChain, findEvent, fromSdkDec, fromSdkInt, getRegistry, hexToBytes, isMsgAddMarginEncodeObject, isMsgClosePositionEncodeObject, and isMsgCreatePoolEncodeObject is correctly documented.

  • 125-131: The modification of the NibiruExtensions type declaration is correctly documented.

  • 133-149: The addition of the ERR variable and its type declaration is correctly documented.

  • 229-265: The addition of the TEST_ADDRESS, TEST_CHAIN, and TEST_MNEMONIC variables and their type declarations is correctly documented.

  • 108-109: The addition of the parseError and parseEventLogs functions is correctly documented.

  • 1162-1172: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1155-1169]

The addition of the queryChainIdWithRest function is correctly documented.

  • 385-407: The addition of the assert function is correctly documented.

  • 411-558: The addition of the assertExpectedError, assertHasEventType, assertHasMsgType, assertValidBlock, assertValidBlockFromJsonRpc, and bytesToHex functions is correctly documented.

  • 586-604: The addition of the eventToMap function is correctly documented.

  • 623-675: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [630-690]

The addition of the findEvent and fromSdkDec functions is correctly documented.

  • 623-675: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [654-710]

The addition of the fromSdkInt function is correctly documented.

  • 721-724: The addition of the getRegistry function is correctly documented.

  • 728-778: The addition of the hexToBytes function is correctly documented.

  • 795-798: The addition of the isMsgAddMarginEncodeObject function is correctly documented.

  • 815-818: The addition of the isMsgClosePositionEncodeObject function is correctly documented.

  • 835-838: The addition of the isMsgCreatePoolEncodeObject function is correctly documented.

  • 855-858: The addition of the isMsgDonateToEcosystemFundEncodeObject function is correctly documented.

  • 875-878: The addition of the isMsgExitPoolEncodeObject function is correctly documented.

  • 895-898: The addition of the isMsgJoinPoolEncodeObject function is correctly documented.

  • 915-918: The addition of the isMsgMultiLiquidateEncodeObject function is correctly documented.

  • 935-938: The addition of the isMsgOpenPositionEncodeObject function is correctly documented.

  • 955-958: The addition of the isMsgPartialCloseEncodeObject function is correctly documented.

  • 975-978: The addition of the isMsgRemoveMarginEncodeObject function is correctly documented.

  • 995-998: The addition of the isMsgSwapAssetsEncodeObject function is correctly documented.

  • 995-1011: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1002-1021]

The addition of the isRestEndptLive function is correctly documented.

  • 1038-1041: The addition of the newCoinMapFromCoins function is correctly documented.

  • 1065-1068: The addition of the newRandomWallet function is correctly documented.

  • 1092-1095: The addition of the newSignerFromMnemonic function is correctly documented.

  • 1099-1119: The addition of the parseError function is correctly documented.

  • 1123-1149: The addition of the parseEventLogs function is correctly documented.

  • 1162-1172: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1153-1169]

The addition of the queryChainIdWithRest function is correctly documented.

  • 1186-1189: The addition of the setupEpochsExtension function is correctly documented.

  • 1206-1209: The addition of the setupInflationExtension function is correctly documented.

  • 1226-1229: The addition of the setupOracleExtension function is correctly documented.

  • 1246-1249: The addition of the setupPerpExtension function is correctly documented.

  • 1266-1269: The addition of the setupSpotExtension function is correctly documented.

  • 1286-1289: The addition of the setupSudoExtension function is correctly documented.

  • 1296-1316: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1296-1336]

The addition of the toSdkDec function is correctly documented.

  • 1353-1356: The addition of the toSdkInt function is correctly documented.

  • 1373-1376: The addition of the transformPool function is correctly documented.

  • 1393-1396: The addition of the transformPoolParams function is correctly documented.

  • 1422-1425: The addition of the useFaucet function is correctly documented.

packages/nibijs/src/chain/chain.ts (3)
  • 28-32: The ast-grep command has successfully identified the ChainIdParts interface within the chain.ts file, which is the file we are reviewing. Since no other occurrences were found, it suggests that ChainIdParts is not used elsewhere in the codebase, or at least not in a way that ast-grep could detect with the provided pattern.

Given this information, it seems that the changes to the ChainIdParts interface are localized to the chain.ts file, and there are no other direct usages that need to be updated as a result of making the prefix property optional and adding the mainnet property.

Analysis chain

The ChainIdParts interface now includes an optional mainnet property and an optional prefix. Ensure that all usages of ChainIdParts throughout the codebase are updated to handle these changes correctly.


I'll correct the syntax error in the ast-grep pattern and rerun the command to search for usages of the ChainIdParts interface.


I'll combine the patterns into a single --pattern flag and rerun the ast-grep command to search for usages of the ChainIdParts interface.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for `ChainIdParts` usage to ensure it's correctly handled with the new optional properties.
ast-grep --lang typescript --pattern $'ChainIdParts { $$$ }'

Length of output: 504



Script:

#!/bin/bash
# Search for `ChainIdParts` usage to ensure it's correctly handled with the new optional properties.
ast-grep --lang typescript --pattern $'interface $_ { $$$ }' --pattern $'ChainIdParts'

Length of output: 251



Script:

#!/bin/bash
# Search for `ChainIdParts` usage to ensure it's correctly handled with the new optional properties.
ast-grep --lang typescript --pattern $'interface ChainIdParts { $$$ }'

Length of output: 467

* 99-144:

The calls to queryChainIdWithRest in both chain.ts and chain.test.ts are correctly handling the new return type Promise<Result<string>>. The usage of res.isOk() and res.isErr() in the respective files indicates that the Result type is being utilized as intended.

Analysis chain

Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [139-151]

The queryChainIdWithRest function now returns a Promise<Result<string>>. Ensure that all calls to this function are updated to handle the new return type.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for `queryChainIdWithRest` calls to ensure the new return type is correctly handled.
ast-grep --lang typescript --pattern $'queryChainIdWithRest($_)'

Length of output: 353



Script:

#!/bin/bash
# Check the usage of the `res` variable after the calls to `queryChainIdWithRest` to ensure it's consistent with the `Result` type.
rg 'const res = await queryChainIdWithRest\(chain\)' ./packages/nibijs/src/chain/chain.ts -A 10
rg 'const result = await queryChainIdWithRest\(chain\)' ./packages/nibijs/src/test/chain.test.ts -A 10
rg 'const res = await queryChainIdWithRest\(inactiveChain\)' ./packages/nibijs/src/test/chain.test.ts -A 10

Length of output: 1279

* 154-158: The new `isRestEndptLive` function has been added to check the liveliness of the REST endpoint. Review this function for correctness and potential side effects, such as handling network errors or timeouts.
packages/nibijs/src/chain/parse.ts (4)
  • 4-30: The expanded comment block and the explicit return type annotation for the toSdkDec function improve code documentation and type safety.

  • 96-113: The new comment block for the fromSdkDec function adds valuable information about the SdkDec type and its protobuf representation, aiding in understanding the function's usage.

  • 113-113: The explicit return type of number for the fromSdkDec function is a good addition for type clarity and safety.

  • 20-20: The contract comment about not mutating the input string in the toSdkDec function is a good practice for clarity and to prevent side effects.

packages/nibijs/src/chain/types.ts (2)
  • 14-20: The assert function's return type has been changed to boolean | string, which is unconventional for assert functions as they typically do not return a value but throw an error on failure. Please confirm if this change is intentional and aligns with the usage expectations throughout the codebase.

  • 40-42: The update to the TxLog interface to use ABCIEvent[] instead of Event[] aligns with the PR objectives and the AI-generated summaries. Ensure that all references and usages of TxLog are updated to handle the new ABCIEvent type.

packages/nibijs/src/hash.test.ts (1)
  • 41-57:

The Result class has been located in the nibijs/src/result.ts file, and it is structured to support the methods and properties used in the tests (isOk, isErr, ok, and err). This confirms that the tests for the bytesToHex and hexToBytes functions are correctly using the Result type as intended.

Analysis chain

The tests for bytesToHex and hexToBytes functions appear to be comprehensive, covering both successful and erroneous inputs. However, ensure that the Result type used in these functions indeed has the isOk, isErr, ok, and err methods and properties, and that they behave as expected. The non-null assertion operator ! should be used with caution and only when the presence of the property is guaranteed.


The initial script did not yield any results, which suggests that the Result type may not be a class or does not have the exact structure we searched for. To verify the existence and structure of the Result type, I will run a more inclusive search.


The previous script contained a syntax error in the ast-grep pattern. I will correct the pattern and run a new search to find any declaration of Result.


The previous script contained a syntax error in the ast-grep pattern. I will refer to the ast-grep pattern syntax guide to construct a valid pattern and run a new search to find any declaration of Result that is a type or interface.


Given the difficulties in locating the Result type or interface with ast-grep, I will use rg (ripgrep) to perform a broader search for the string "Result" in the codebase to find its declaration.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Result type has isOk and isErr methods, and ok and err properties.
ast-grep --lang typescript --pattern $'class Result {
  isOk() {
    $$$
  }
  isErr() {
    $$$
  }
  ok: $_;
  err: $_;
}'

Length of output: 125



Script:

#!/bin/bash
# Search for any type, class, or interface named `Result` to verify its structure.
ast-grep --lang typescript --pattern $'$_ "Result" { $$$ }'

Length of output: 502



Script:

#!/bin/bash
# Search for any declaration of `Result` to verify its structure.
ast-grep --lang typescript --pattern $'$_ "Result"'

Length of output: 486



Script:

#!/bin/bash
# Search for any type or interface declaration named `Result`.
ast-grep --lang typescript --pattern $'type $_ = "Result" { $$$ }'

Length of output: 67


Script:

#!/bin/bash
# Alternatively, search for any interface declaration named `Result`.
ast-grep --lang typescript --pattern $'interface "Result" { $$$ }'

Length of output: 516



Script:

#!/bin/bash
# Use ripgrep to search for the string "Result" in the codebase.
rg 'Result' --type ts

Length of output: 8082

packages/nibijs/src/hash.ts (2)
  • 14-17: The bytesToHex function is correctly implemented and well-documented.

  • 51-73: The hexToBytes function is correctly implemented, with comprehensive error handling and documentation.

packages/nibijs/src/index.ts (1)
  • 3-8: The search results indicate that the old class names NibiruSigningClient and NibiruQueryClient do not appear in the codebase, suggesting that they have been successfully replaced. The new class names NibiruTxClient and NibiruQuerier are present in multiple files, including source files, test files, and documentation, which confirms that the renaming has been reflected across the entire codebase.

Based on the provided output, there are no instances of the old class names, and the new class names are used consistently. Therefore, the renaming appears to have been carried out correctly.

Analysis chain

Verify that the renaming of NibiruSigningClient to NibiruTxClient, and NibiruQueryClient to NibiruQuerier has been reflected across the entire codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for old class names to ensure they have been replaced.
rg 'NibiruSigningClient|NibiruQueryClient'

# Search for new class names to validate their usage.
rg 'NibiruTxClient|NibiruQuerier'

Length of output: 8733

packages/nibijs/src/msg/perp.ts (3)
  • 103-111: The addition of the removeMargin method to the PerpMsgFactory class is consistent with the PR objectives and the AI-generated overview. The method's implementation follows the pattern of other factory methods in the class, which is good for consistency. Ensure that all references to the old MsgRemoveMargin method are updated to use this new factory method.

  • 103-108: The comment block added for the PerpMsgFactory class provides useful documentation and a link to the relevant documentation. This is a good practice as it helps developers understand the purpose of the class and where to find more information.

  • 100-111: The new removeMargin method and the comment block are well-integrated into the existing codebase. The method is consistent with the class's design pattern, and the comment block provides valuable documentation. No further issues are apparent in the provided hunk.

packages/nibijs/src/query/query.ts (7)
  • 3-9: Renaming of QueryClient to StargateQueryClient aligns with the PR objectives and enhances clarity.

  • 22-22: Introduction of TxResponse import is consistent with the new methods added to the NibiruQuerier class.

  • 29-30: Addition of imports for Result and utility functions bytesToHex and hexToBytes supports the new functionality in NibiruQuerier.

  • 46-63: Renaming of NibiruQueryClient to NibiruQuerier is consistent with the PR objectives and reflects a more accurate description of the class's functionality.

  • 55-55: Addition of the tm property to the NibiruQuerier class is necessary for the new transaction querying methods.

  • 70-78: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [66-78]

Modification of the NibiruQuerier constructor to initialize tm and nibiruExtensions properties aligns with the new class structure.

  • 109-141: Addition of getTxByHash and getTxByHashBytes methods to the NibiruQuerier class provides new functionality for querying transactions and is consistent with the PR objectives.
packages/nibijs/src/result.ts (6)
  • 30-69: The implementation of the Result class appears to be correct and follows the intended design pattern for explicit error handling. The class provides methods to check for errors (isErr) and success states (isOk), and static methods to create Result objects from synchronous (ofSafeExec) and asynchronous (ofSafeExecAsync) functions. The constructor ensures that ok and err are not both set, which aligns with the Rust Result type's behavior.

  • 33-41: The constructor of the Result class correctly enforces that either ok or err must be set, but not both, by throwing an error if this invariant is violated. This is a good practice to prevent misuse of the Result type.

  • 71-76: The parseError function is a useful utility that ensures all caught errors are of type Error, which is a good practice in JavaScript to handle cases where non-Error objects might be thrown.

  • 30-30: The Result class is exported, making it available for use throughout the codebase. This aligns with the PR's objective of adding new modules to the nibijs package.

  • 30-30: The Result class is implemented using generics without constraints on the type T, which is typical for a result type and allows it to handle any type of success value.

  • 44-45: The isOk method is correctly implemented as the negation of isErr, which is safe due to the constructor's invariant enforcement.

Comment on lines 4 to 7
export class MsgFactory {
spot = SpotMsgFactory

perp = PerpMsgFactory
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the provided hunk, there are no changes to the MsgFactory class. If the spot property was intended to be removed, this change is not reflected in the hunk. Please ensure that the code in the hunk matches the intended changes described in the PR objectives and AI-generated summary.

Comment on lines +16 to +17
export interface EventTransfer extends EventMap {
type: "wasm-tranfer-event"
Copy link
Contributor

Choose a reason for hiding this comment

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

The type property in the EventTransfer example should be a type, not a string literal.

-  type: "wasm-tranfer-event"
+  type: string

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
export interface EventTransfer extends EventMap {
type: "wasm-tranfer-event"
export interface EventTransfer extends EventMap {
type: string


```ts
export interface EventTransfer extends EventMap {
type: "wasm-tranfer-event"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a typo in the type property value; "transfer" is misspelled.

-  type: "wasm-tranfer-event"
+  type: "wasm-transfer-event"

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
type: "wasm-tranfer-event"
type: "wasm-transfer-event"


return Result.ofSafeExec(() =>
Uint8Array.from(
hex.match(/.{1,2}/g)!.map((hexTuple: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider handling the case where hex.match(/.{1,2}/g) returns null, which can occur if the input string is empty. This would prevent a potential runtime error.

- hex.match(/.{1,2}/g)!.map((hexTuple: string) => {
+ const matches = hex.match(/.{1,2}/g);
+ if (!matches) {
+   return new Result({
+     err: new Error("HexError: empty string cannot be converted to bytes"),
+   });
+ }
+ matches.map((hexTuple: string) => {

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
hex.match(/.{1,2}/g)!.map((hexTuple: string) => {
const matches = hex.match(/.{1,2}/g);
if (!matches) {
return new Result({
err: new Error("HexError: empty string cannot be converted to bytes"),
});
}
matches.map((hexTuple: string) => {

Comment on lines +10 to +12
import { NibiruQuerier, Tesnet } from "@nibiruchain/nibijs"
const chain = Testnet()
const querier = await NibiruQuerier.connect(chain.endptTm)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a typo in the import statement in the example code. It should be Testnet instead of Tesnet.

- import { NibiruQuerier, Tesnet } from "@nibiruchain/nibijs"
+ import { NibiruQuerier, Testnet } from "@nibiruchain/nibijs"

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
import { NibiruQuerier, Tesnet } from "@nibiruchain/nibijs"
const chain = Testnet()
const querier = await NibiruQuerier.connect(chain.endptTm)
import { NibiruQuerier, Testnet } from "@nibiruchain/nibijs"
const chain = Testnet()
const querier = await NibiruQuerier.connect(chain.endptTm)

Comment on lines +225 to +229
.catch((err) => {
if (!`${err}`.includes("account sequence mismatch")) {
throw err
}
logExampleName(exampleFunc.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error handling in the main execution path is based on the error message string, which could be brittle. Consider using error types or codes for more robust error handling.

Comment on lines +60 to +68
static ofSafeExecAsync = async <Y>(
fn: () => Promise<Y>
): Promise<Result<Y>> => {
try {
return new Result({ ok: await fn() })
} catch (err) {
return new Result({ err })
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The ofSafeExecAsync method does not accept arguments for the function it wraps. This could be a limitation if the function needs to be called with arguments. Consider updating the method to allow passing arguments if needed.

- static ofSafeExecAsync = async <Y>(fn: () => Promise<Y>): Promise<Result<Y>> => {
+ static ofSafeExecAsync = async <Y>(fn: (...args: any[]) => Promise<Y>, ...args: any[]): Promise<Result<Y>> => {
    try {
-     return new Result({ ok: await fn() })
+     return new Result({ ok: await fn(...args) })
    } catch (err) {
      return new Result({ err })
    }
  }

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
static ofSafeExecAsync = async <Y>(
fn: () => Promise<Y>
): Promise<Result<Y>> => {
try {
return new Result({ ok: await fn() })
} catch (err) {
return new Result({ err })
}
}
static ofSafeExecAsync = async <Y>(fn: (...args: any[]) => Promise<Y>, ...args: any[]): Promise<Result<Y>> => {
try {
return new Result({ ok: await fn(...args) })
} catch (err) {
return new Result({ err })
}
}

Comment on lines 3 to +8
export * from "./query"
export * from "./stableswap"
export * from "./tx"
export * from "./hash"
export * from "./result"
export * from "./testutil"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The search results indicate that the classes NibiruSigningClient and NibiruQueryClient have been successfully renamed throughout the codebase, as no instances of the old class names were found. However, there appears to be a lack of documentation for the new modules hash, result, and testutil in the README.md file, which should be addressed according to the PR's emphasis on documentation improvements.

  • The renaming of NibiruSigningClient to NibiruTxClient and NibiruQueryClient to NibiruQuerier has been successfully verified.

  • The presence of tests for the new modules hash, result, and testutil has been confirmed.

  • The absence of documentation for these new modules in the README.md file should be noted and potentially addressed.

  • Documentation for the new modules hash, result, and testutil is not present in the README.md file and should be added as per the PR's objectives.

Analysis chain

The addition of exports for hash, result, and testutil modules is consistent with the PR objectives and AI-generated summaries. Ensure that these new modules are properly documented and tested, as per the PR description.


The search for documentation in the README.md did not yield any results for the new modules hash, result, and testutil, which suggests that there may not be documentation for these modules in the README. However, the search in test files indicates that there are tests that reference these modules, which is consistent with the PR's emphasis on testing enhancements.

To continue the verification process, I will now generate a script to verify the renaming of NibiruSigningClient to NibiruTxClient, and NibiruQueryClient to NibiruQuerier across the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new modules have corresponding documentation.
fd 'README.md' --exec rg -- 'hash|result|testutil'

# Verify that the new modules have corresponding tests.
fd '.*\.test\.ts$' --exec rg -- 'hash|result|testutil'

Length of output: 6886



Script:

#!/bin/bash
# Verify that `NibiruSigningClient` has been renamed to `NibiruTxClient`
fd --type f --exec rg -- 'NibiruSigningClient'

# Verify that `NibiruQueryClient` has been renamed to `NibiruQuerier`
fd --type f --exec rg -- 'NibiruQueryClient'

Length of output: 91

Comment on lines 58 to +68
this.chainIdParts = chainIdParts
this.chainId = this.initChainId()
this.chainName = this.chainId
this.endptTm = `https://rpc.${chainIdParts.shortName}-${chainIdParts.number}.nibiru.fi`
this.endptRest = `https://lcd.${chainIdParts.shortName}-${chainIdParts.number}.nibiru.fi`
this.endptGrpc = `grpc.${chainIdParts.shortName}-${chainIdParts.number}.nibiru.fi`

const chainEndpt = chainIdParts.mainnet
? ""
: `.${chainIdParts.shortName}-${chainIdParts.number}`

this.endptTm = `https://rpc${chainEndpt}.nibiru.fi`
this.endptRest = `https://lcd${chainEndpt}.nibiru.fi`
this.endptGrpc = `grpc${chainEndpt}.nibiru.fi`
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The constructor implementation in chain.ts correctly handles the mainnet property by defaulting to a non-mainnet URL construction when mainnet is not provided or is false. However, the test output only shows a test case for when mainnet is explicitly set to true. There is no evidence of a test case covering the scenario where mainnet is not provided, which suggests that this scenario might not be covered by the tests.

  • The CustomChain constructor logic correctly handles the mainnet property, but there may be a lack of test coverage for scenarios where mainnet is not provided. It is recommended to add tests to cover these cases to ensure the constructor behaves as expected in all scenarios.
Analysis chain

The CustomChain class constructor now uses the mainnet property to conditionally construct endpoint URLs. Verify that this new logic is correctly implemented and tested, especially in scenarios where mainnet is not provided.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for `CustomChain` constructor calls to ensure the `mainnet` property is correctly handled.
ast-grep --lang typescript --pattern $'new CustomChain($_)'

Length of output: 1062



Script:

#!/bin/bash
# Check the implementation of the `CustomChain` constructor to see how it handles the `mainnet` property.
ast-grep --lang typescript --pattern $'class CustomChain {
  constructor($_) {
    $$$
  }
}'

# Search for tests related to the `CustomChain` constructor, especially those that might not provide the `mainnet` property.
rg "new CustomChain" ./packages/nibijs/src/test/

Length of output: 223



Script:

#!/bin/bash
# Retrieve the actual implementation of the `CustomChain` constructor from `chain.ts`.
rg "constructor" ./packages/nibijs/src/chain/chain.ts

# Search for tests in `chain.test.ts` that do not explicitly provide the `mainnet` property.
rg "new CustomChain" ./packages/nibijs/src/test/chain.test.ts -A 5 -B 5

Length of output: 415



Script:

#!/bin/bash
# Retrieve the full implementation of the `CustomChain` constructor from `chain.ts`.
rg "constructor" ./packages/nibijs/src/chain/chain.ts -A 10

# Search for tests in `chain.test.ts` that do not explicitly provide the `mainnet` property, including more context around the matches.
rg "new CustomChain" ./packages/nibijs/src/test/chain.test.ts -C 10

Length of output: 1169

Comment on lines 71 to +77
public static fromChainId(chainId: string): Chain {
const parts = chainId.split("-")
const chainIdParts = {
const chainIdParts: ChainIdParts = {
prefix: parts[0],
shortName: parts[1],
number: Number(parts[2]),
} as ChainIdParts
number: parseInt(parts[2]),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The test coverage in chain.test.ts for the CustomChain.fromChainId method does not explicitly include scenarios where the new optional mainnet property is not provided. It may be beneficial to expand the test cases to cover these scenarios to ensure that the method handles the new ChainIdParts interface correctly.

  • The "chain from chain-id" test case checks the chainId property but does not test the absence of mainnet.

  • The "Mainnet" test case tests the CustomChain constructor with mainnet set to true but does not test the fromChainId method with a mainnet property.

  • There are no test cases that check the behavior of CustomChain.fromChainId when the prefix and mainnet properties are not provided.

  • The chain.test.ts file lacks explicit test cases for CustomChain.fromChainId method to handle scenarios where the mainnet property is not provided. It is recommended to add such test cases to ensure proper handling of the new optional properties in the ChainIdParts interface.

Analysis chain

The CustomChain.fromChainId static method has been updated to handle the new ChainIdParts interface. Review this method to ensure that it correctly parses and handles chain IDs, especially in scenarios where mainnet is not provided.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for `CustomChain.fromChainId` calls to ensure the new `ChainIdParts` interface is correctly handled.
ast-grep --lang typescript --pattern $'CustomChain.fromChainId($_)'

Length of output: 174



Script:

#!/bin/bash
# Check the contents of the `chain.test.ts` file to see if it includes tests for the new `ChainIdParts` interface properties.
cat ./packages/nibijs/src/test/chain.test.ts

Length of output: 5443

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.

2 participants