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: updated bonded tokens formula #37

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

yevhen-burkovskyi
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Jun 19, 2024

Walkthrough

Several new changes have been introduced to enhance the staking functionality. A new endpoint STAKING_POOL has been added to the Endpoints enum. The Okp4Service class gained a new getStakingPool() method, and the StakingService now uses this method to fetch staking pool data. Additionally, a new StakingPoolResponse interface was added to define the structure of the staking pool response object, which includes details about bonded and not bonded tokens.

Changes

Files Change Summary
src/core/lib/okp4/enums/endpoints.enum.ts Added new endpoint STAKING_POOL to the Endpoints enum.
src/core/lib/okp4/okp4.service.ts Removed and added imports related to responses and enums, added getStakingPool() method.
src/core/lib/okp4/responses/staking-pool.response.ts Added new StakingPoolResponse interface defining the structure of a staking pool response object.
src/modules/staking/services/staking.service.ts Integrated getStakingPool() method and updated calculation for bondedTokens.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant StakingService
    participant Okp4Service
    participant Endpoints
    participant StakingPoolResponse

    Client->>StakingService: requestStakingInfo()
    StakingService->>Okp4Service: getStakingPool()
    Okp4Service->>Endpoints: STAKING_POOL
    Endpoints-->>Okp4Service: Send pool endpoint
    Okp4Service->>StakingPoolResponse: fetchData()
    StakingPoolResponse-->>Okp4Service: Return pool data
    Okp4Service-->>StakingService: Return StakingPoolResponse
    StakingService-->>Client: Send updated staking info
Loading

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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

@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

Outside diff range and nitpick comments (2)
src/core/lib/okp4/okp4.service.ts (1)

Line range hint 172-173: Consider using optional chaining to improve code safety and readability.

- if (status) {
+ if (status?) {
src/modules/staking/services/staking.service.ts (1)

Line range hint 474-474: Consider using optional chaining to improve code safety and readability.

- if (cache === null) {
+ if (cache?) {
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a3f960a and 8f9705c.

Files selected for processing (4)
  • src/core/lib/okp4/enums/endpoints.enum.ts (1 hunks)
  • src/core/lib/okp4/okp4.service.ts (3 hunks)
  • src/core/lib/okp4/responses/staking-pool.response.ts (1 hunks)
  • src/modules/staking/services/staking.service.ts (2 hunks)
Additional context used
Biome
src/core/lib/okp4/okp4.service.ts

[error] 172-173: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

src/modules/staking/services/staking.service.ts

[error] 474-474: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

Additional comments not posted (5)
src/core/lib/okp4/responses/staking-pool.response.ts (1)

1-6: The StakingPoolResponse interface is well-defined and correctly encapsulates the pool object with not_bonded_tokens and bonded_tokens.

src/core/lib/okp4/enums/endpoints.enum.ts (1)

15-15: The addition of the STAKING_POOL endpoint is correct and aligns well with the existing structure of the Endpoints enum.

src/core/lib/okp4/okp4.service.ts (2)

26-26: The import of StakingPoolResponse is appropriately placed and necessary for the new functionality.


245-247: The getStakingPool method is correctly implemented to fetch staking pool data using the new endpoint. Good use of existing infrastructure for error handling and URL construction.

src/modules/staking/services/staking.service.ts (1)

158-158: Correct integration of the getStakingPool method within the fetchAndCacheGlobalStakedOverview function.

@yevhen-burkovskyi yevhen-burkovskyi merged commit 656d0f0 into main Jun 19, 2024
11 checks passed
@yevhen-burkovskyi yevhen-burkovskyi deleted the fix/update-bonded-tokens-formula branch June 19, 2024 11:59
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