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: devgas query #325

Merged
merged 1 commit into from
Feb 28, 2024
Merged

feat: devgas query #325

merged 1 commit into from
Feb 28, 2024

Conversation

cgilbe27
Copy link
Contributor

@cgilbe27 cgilbe27 commented Feb 28, 2024

Summary by CodeRabbit

  • New Features
    • Introduced functionality for interacting with Devgas extension, enabling querying of fee shares and related parameters.
    • Expanded SDK capabilities to include Devgas extension setup and querying.

Copy link
Contributor

coderabbitai bot commented Feb 28, 2024

Walkthrough

The recent updates introduce the Devgas extension to the SDK, enhancing its functionality by allowing interactions with Devgas for querying fee shares and parameters. The integration spans across multiple files, setting up the necessary exports and initializing the DevgasExtension alongside other existing extensions, thus broadening the SDK's capability to interact with new blockchain features.

Changes

Files Change Summary
.../query/devgas.ts Introduces Devgas extension functionality for querying fee shares and parameters.
.../query/index.ts Adds export for Devgas alongside existing exports.
.../query/query.ts Includes DevgasExtension in NibiruExtensions and updates NibiruQuerier initialization.
.../tx/txClient.ts Adds setupDevgasExtension function to NibiruTxClient class initialization.

🐰🎉
To the code, we hop and leap,
With Devgas now, the dive is deep.
Extensions grow, the blockchain sings,
In digital realms, our work takes wings.
🌟 For every line, a purpose true,
Together bound, in skies of code-blue.
🚀🐇

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 your favorite social media?

Share

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@CalicoNino CalicoNino merged commit 769831a into develop Feb 28, 2024
1 of 2 checks passed
@CalicoNino CalicoNino deleted the feat/devgas-query branch February 28, 2024 18:45
cgilbe27 added a commit that referenced this pull request Feb 28, 2024
nibibot pushed a commit that referenced this pull request Feb 28, 2024
## [3.1.0](v3.0.14...v3.1.0) (2024-02-28)

### Features

* devgas query ([#325](#325)) ([769831a](769831a))

 [skip ci]
@nibibot
Copy link

nibibot commented Feb 28, 2024

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 64e028c and 5e3b0c7.
Files selected for processing (4)
  • src/sdk/query/devgas.ts (1 hunks)
  • src/sdk/query/index.ts (1 hunks)
  • src/sdk/query/query.ts (3 hunks)
  • src/sdk/tx/txClient.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/sdk/query/index.ts
Additional comments: 5
src/sdk/query/devgas.ts (1)
  • 14-22: The DevgasExtension interface is well-defined, providing a clear contract for interacting with the Devgas extension. Each method corresponds to a specific Devgas-related query, ensuring a modular and focused approach to querying Devgas data.
src/sdk/tx/txClient.ts (2)
  • 30-30: The inclusion of setupDevgasExtension in the import statement is correct and necessary for utilizing the Devgas extension within the NibiruTxClient class.
  • 53-53: The addition of setupDevgasExtension in the NibiruExtensions initialization within the NibiruTxClient constructor is correctly implemented. This ensures that the Devgas extension is available for transactional operations, aligning with the PR's objective to enhance the SDK's capabilities. However, ensure that the order of extension setup calls does not impact the initialization or usage of other extensions, as the order can sometimes be significant in composite setups.
Verification successful

The addition of setupDevgasExtension at the beginning of the extension setup calls in the NibiruTxClient constructor has been verified. The order of extension setup calls, as provided, does not indicate any obvious issues that could impact the initialization or usage of other extensions. However, without explicit documentation or comments indicating the significance of this order, it's advisable to consult the SDK's documentation or the developers to ensure that the order does not have specific implications that are not immediately apparent from the code alone.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the order of extension setup calls does not impact other extensions
echo "Manual verification recommended: Check the initialization order of extensions in NibiruTxClient."

Length of output: 202



Script:

#!/bin/bash
# Search for the NibiruTxClient constructor and examine the order of extension setup calls
rg "class NibiruTxClient" --context 10

Length of output: 1093



Script:

#!/bin/bash
# Search specifically for the constructor's body within the NibiruTxClient class, focusing on the initialization of extensions
rg "constructor" -A 20 src/sdk/tx/txClient.ts

Length of output: 654

src/sdk/query/query.ts (2)
  • 39-40: The inclusion of DevgasExtension in the NibiruExtensions type is correctly implemented, ensuring that the Devgas querying capabilities are recognized as part of the SDK's extension system. This change is crucial for type safety and code clarity.
  • 89-89: The setup of DevgasExtension in the NibiruQuerier class is correctly implemented, aligning with the SDK's pattern for initializing extensions. This ensures that the Devgas querying capabilities are seamlessly integrated into the SDK's querying system. As with the txClient.ts file, ensure that the order of extension setup calls does not inadvertently affect the initialization or functionality of other extensions.
Verification successful

The setup of DevgasExtension in the NibiruQuerier class is correctly implemented, aligning with the SDK's pattern for initializing extensions. The detailed context around the setupDevgasExtension occurrences and its placement among other extension setup calls does not indicate any potential issues with the initialization or functionality of other extensions. This verifies the original review comment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the order of extension setup calls does not impact other extensions
echo "Manual verification recommended: Check the initialization order of extensions in NibiruQuerier."

Length of output: 200



Script:

#!/bin/bash
# Find the file containing the NibiruQuerier class
fd "query.ts" --exec rg "class NibiruQuerier"

Length of output: 97



Script:

#!/bin/bash
# Inspect the initialization of extensions within the NibiruQuerier class in query.ts
rg "setupDevgasExtension" query.ts

Length of output: 83



Script:

#!/bin/bash
# Securely locate query.ts and inspect the initialization of extensions within the NibiruQuerier class
fd query.ts | xargs rg "setupDevgasExtension"

Length of output: 97



Script:

#!/bin/bash
# Extract more detailed context around setupDevgasExtension occurrences in query.ts
fd query.ts | xargs rg "setupDevgasExtension" -C 5

Length of output: 652

Comment on lines +25 to +55
export const setupDevgasExtension = (base: QueryClient): DevgasExtension => {
const rpcClient = createProtobufRpcClient(base)
const queryService = new QueryClientImpl(rpcClient)

return {
devgas: {
feeShare: async (args: QueryFeeShareRequest) => {
const req = QueryFeeShareRequest.fromPartial(args)
const resp = await queryService.FeeShare(req)
return resp
},
feeSharesByWithdrawer: async (
args: QueryFeeSharesByWithdrawerRequest
) => {
const req = QueryFeeSharesByWithdrawerRequest.fromPartial(args)
const resp = await queryService.FeeSharesByWithdrawer(req)
return resp
},
feeShares: async (args: QueryFeeSharesRequest) => {
const req = QueryFeeSharesRequest.fromPartial(args)
const resp = await queryService.FeeShares(req)
return resp
},
params: async (args: QueryParamsRequest) => {
const req = QueryParamsRequest.fromPartial(args)
const resp = await queryService.Params(req)
return resp
},
},
}
}
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 28, 2024

Choose a reason for hiding this comment

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

The setupDevgasExtension function correctly initializes the Devgas extension, leveraging the createProtobufRpcClient to create an RPC client and the QueryClientImpl for the query service. This setup is consistent with the expected pattern for initializing extensions in the SDK. However, consider adding error handling for the asynchronous operations within the method implementations to ensure robustness and reliability in case of RPC failures or data issues.

+ try {
+   const resp = await queryService.FeeShare(req);
+   return resp;
+ } catch (error) {
+   // Handle or log the error appropriately
+   throw new Error(`Failed to query fee share: ${error.message}`);
+ }

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 const setupDevgasExtension = (base: QueryClient): DevgasExtension => {
const rpcClient = createProtobufRpcClient(base)
const queryService = new QueryClientImpl(rpcClient)
return {
devgas: {
feeShare: async (args: QueryFeeShareRequest) => {
const req = QueryFeeShareRequest.fromPartial(args)
const resp = await queryService.FeeShare(req)
return resp
},
feeSharesByWithdrawer: async (
args: QueryFeeSharesByWithdrawerRequest
) => {
const req = QueryFeeSharesByWithdrawerRequest.fromPartial(args)
const resp = await queryService.FeeSharesByWithdrawer(req)
return resp
},
feeShares: async (args: QueryFeeSharesRequest) => {
const req = QueryFeeSharesRequest.fromPartial(args)
const resp = await queryService.FeeShares(req)
return resp
},
params: async (args: QueryParamsRequest) => {
const req = QueryParamsRequest.fromPartial(args)
const resp = await queryService.Params(req)
return resp
},
},
}
}
export const setupDevgasExtension = (base: QueryClient): DevgasExtension => {
const rpcClient = createProtobufRpcClient(base)
const queryService = new QueryClientImpl(rpcClient)
return {
devgas: {
feeShare: async (args: QueryFeeShareRequest) => {
const req = QueryFeeShareRequest.fromPartial(args)
try {
const resp = await queryService.FeeShare(req);
return resp;
} catch (error) {
// Handle or log the error appropriately
throw new Error(`Failed to query fee share: ${error.message}`);
}
},
feeSharesByWithdrawer: async (
args: QueryFeeSharesByWithdrawerRequest
) => {
const req = QueryFeeSharesByWithdrawerRequest.fromPartial(args)
const resp = await queryService.FeeSharesByWithdrawer(req)
return resp
},
feeShares: async (args: QueryFeeSharesRequest) => {
const req = QueryFeeSharesRequest.fromPartial(args)
const resp = await queryService.FeeShares(req)
return resp
},
params: async (args: QueryParamsRequest) => {
const req = QueryParamsRequest.fromPartial(args)
const resp = await queryService.Params(req)
return resp
},
},
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should not throw errors

Copy link
Contributor

Choose a reason for hiding this comment

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

@cgilbe27, understood. Instead of throwing errors, we could handle them in a way that aligns with your project's error handling strategy. One approach could be to log the error and return a specific error response that the calling function can check for. Here's an example modification for the feeShare method:

feeShare: async (args: QueryFeeShareRequest) => {
  const req = QueryFeeShareRequest.fromPartial(args)
  try {
    const resp = await queryService.FeeShare(req);
    return resp;
  } catch (error) {
    console.error(`Failed to query fee share: ${error.message}`);
    // Return a specific error response or null based on your project's strategy
    return null;
  }
},

This way, we avoid throwing errors and instead log them for debugging purposes, returning null (or another appropriate value) to indicate an error occurred. Would this approach be more in line with your project's practices?


New Learnings Added
User: cgilbe27
PR: NibiruChain/ts-sdk#325
File: src/sdk/query/devgas.ts:25-55
Timestamp: 2024-02-28T18:58:23.997Z
Learning: cgilbe27 prefers not to use thrown errors for error handling in the `src/sdk/query/devgas.ts` file.

Note: Learnings are effective only in the context of specific code segments. To apply general coding guidelines, please configure path-based instructions.

Copy link

Lines Statements Branches Functions
Coverage: 89%
91.2% (1265/1387) 86.28% (541/627) 78.28% (310/396)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants