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: added info for single validator page #15

Merged
merged 4 commits into from
May 15, 2024

Conversation

yevhen-burkovskyi
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented May 14, 2024

Walkthrough

This update introduces significant changes to the configuration and functionality of the staking module. Key highlights include modifications to environment variable values, the addition of Keybase API integration, and enhancements to validator delegation handling. New schemas, DTOs, and services have been added to support these features, alongside updates to existing enums and interfaces. The changes aim to improve the staking module's capabilities by providing more detailed validator information and integrating external services for enhanced functionality.

Changes

Files/Paths Change Summaries
.env.example Updated environment variable values for staking overview and added KEYBASE_URL.
src/core/config/config.dto.ts Added KeybaseConfig interface within ConfigDto.
src/core/config/config.schema.ts Added STAKING_VALIDATOR_DELEGATION and KEYBASE_URL to ConfigSchema.
src/core/config/config.ts Added validatorDelegation under staking and keybase object with url field in config.
src/core/lib/keybase/keybase.service.ts Introduced KeybaseService for handling interactions with the Keybase API.
src/core/lib/keybase/responses/failed.response.ts Introduced FailedResponse interface for error handling in Keybase responses.
src/core/lib/keybase/responses/generic-success-failed.response.ts Introduced GSFResponse<T> type for generic success/failed responses.
src/core/lib/keybase/responses/user-lookup.response.ts Introduced UserLookupResponse interface for user lookup responses.
src/core/lib/okp4/enums/endpoints.enum.ts Added VALIDATOR_DELEGATIONS endpoint.
src/core/lib/okp4/enums/route-param.enum.ts Added VALIDATOR_ADDRES to RouteParam enum.
src/core/lib/okp4/okp4.service.ts Added getValidatorDelegations method to Okp4Service.
src/core/lib/keybase/responses/validator-delegations.response.ts Introduced types and interfaces related to validator delegations response handling.
src/modules/staking/dtos/my-validator-delegation.dto.ts Introduced MyValidatorDelegationDto interface.
src/modules/staking/dtos/validator-delegations.dto.ts Introduced ValidatorDelegationsDto interface.
src/modules/staking/dtos/validators-view.dto.ts Enhanced ValidatorsViewDto by adding logo, description, and detailed commission fields, and removed name and commission fields.
src/modules/staking/enums/query-param.enum.ts Added VALIDATOR_ADDRESS to QueryParam enum.
src/modules/staking/enums/staking-cache-prefix.enum.ts Introduced StakingCachePrefix enum for cache prefix values.
src/modules/staking/enums/staking-endpoints.enum.ts Added MY_VALIDATOR_DELEGATION and VALIDATOR_DELEGATIONS endpoints to StakingEndpoints enum.
src/modules/staking/schemas/my-validator-delegation.schema.ts Introduced MyValidatorDelegationSchema for validating address and validatorAddress fields.
src/modules/staking/schemas/validator-delegations.schema.ts Introduced ValidatorDelegationsSchema for validator delegations.
src/modules/staking/services/staking.cache.ts Refactored cache prefixes and added methods for handling validator delegation and image caching.
src/modules/staking/staking.controller.ts Added new methods and imports for handling validator delegation endpoints.
src/modules/staking/staking.module.ts Imported and added KeybaseService to the list of providers.

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.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between a039a97 and 507775a.
Files selected for processing (24)
  • .env.example (1 hunks)
  • src/core/config/config.dto.ts (2 hunks)
  • src/core/config/config.schema.ts (1 hunks)
  • src/core/config/config.ts (1 hunks)
  • src/core/lib/keybase/keybase.service.ts (1 hunks)
  • src/core/lib/keybase/responses/failed.response.ts (1 hunks)
  • src/core/lib/keybase/responses/generic-success-failed.response.ts (1 hunks)
  • src/core/lib/keybase/responses/user-lookup.response.ts (1 hunks)
  • src/core/lib/okp4/enums/endpoints.enum.ts (1 hunks)
  • src/core/lib/okp4/enums/route-param.enum.ts (1 hunks)
  • src/core/lib/okp4/okp4.service.ts (2 hunks)
  • src/core/lib/okp4/responses/validator-delegations.response.ts (1 hunks)
  • src/modules/staking/dtos/my-validator-delegation.dto.ts (1 hunks)
  • src/modules/staking/dtos/validator-delegations.dto.ts (1 hunks)
  • src/modules/staking/dtos/validators-view.dto.ts (1 hunks)
  • src/modules/staking/enums/query-param.enum.ts (1 hunks)
  • src/modules/staking/enums/staking-cache-prefix.enum.ts (1 hunks)
  • src/modules/staking/enums/staking-endpoints.enum.ts (1 hunks)
  • src/modules/staking/schemas/my-validator-delegation.schema.ts (1 hunks)
  • src/modules/staking/schemas/validator-delegations.schema.ts (1 hunks)
  • src/modules/staking/services/staking.cache.ts (2 hunks)
  • src/modules/staking/services/staking.service.ts (4 hunks)
  • src/modules/staking/staking.controller.ts (2 hunks)
  • src/modules/staking/staking.module.ts (1 hunks)
Files skipped from review due to trivial changes (8)
  • .env.example
  • src/core/lib/keybase/responses/generic-success-failed.response.ts
  • src/core/lib/okp4/enums/route-param.enum.ts
  • src/core/lib/okp4/responses/validator-delegations.response.ts
  • src/modules/staking/dtos/my-validator-delegation.dto.ts
  • src/modules/staking/dtos/validator-delegations.dto.ts
  • src/modules/staking/enums/staking-cache-prefix.enum.ts
  • src/modules/staking/schemas/validator-delegations.schema.ts
Additional comments not posted (31)
src/modules/staking/enums/query-param.enum.ts (1)

3-3: New enum entry VALIDATOR_ADDRESS looks good and follows the existing naming conventions.

src/modules/staking/schemas/my-validator-delegation.schema.ts (1)

1-6: The Joi schema for MyValidatorDelegationSchema is well-defined and follows best practices for validation.

src/modules/staking/enums/staking-endpoints.enum.ts (1)

3-4: New enum entries MY_VALIDATOR_DELEGATION and VALIDATOR_DELEGATIONS look good and follow the existing naming conventions.

src/modules/staking/dtos/validators-view.dto.ts (1)

2-15: The new fields logo, description, and commission in the ValidatorsViewDto interface are well-defined and add valuable information.

src/core/config/config.dto.ts (1)

7-7: The new entries for KeybaseConfig and validatorDelegation in CacheConfig are well-defined and follow the existing structure and conventions.

Also applies to: 35-36, 38-39

src/modules/staking/staking.module.ts (1)

8-8: Integration of KeybaseService looks good.

Also applies to: 15-15

src/core/config/config.schema.ts (1)

17-18: Addition of STAKING_VALIDATOR_DELEGATION and KEYBASE_URL to the configuration schema looks good.

src/core/config/config.ts (1)

25-28: Addition of validatorDelegation and keybase configuration fields looks good.

src/modules/staking/staking.controller.ts (3)

8-11: Imports for MyValidatorDelegationSchema, MyValidatorDelegationDto, ValidatorDelegationsSchema, and ValidatorDelegationsDto look good.


37-43: Addition of getMyValidatorDelegation endpoint looks good.


45-51: Addition of getValidatorDelegations endpoint looks good.

src/core/lib/keybase/keybase.service.ts (1)

1-59: Implementation of KeybaseService looks good.

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

Line range hint 4-81: Addition of methods for handling validator delegations and images, and modification of existing methods to use the new StakingCachePrefix enum looks good.

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

99-117: Addition of getValidatorDelegations method looks good.

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

30-36: onModuleInit method implementation looks good.


Line range hint 38-50: getMyStakedOverview method implementation looks good.


Line range hint 52-65: fetchAndCacheMyStakedOverview method implementation looks good.


66-74: fetchMyStakedAmount method implementation looks good.


76-78: fetchDelegatorsValidatorsAmount method implementation looks good.


82-89: fetchDelegatorsRewards method implementation looks good.


Line range hint 91-93: fetchAvailableBalance method implementation looks good.


Line range hint 95-107: getGlobalOverview method implementation looks good.


Line range hint 109-135: fetchAndCacheGlobalStakedOverview method implementation looks good.


Line range hint 136-150: getValidators method implementation looks good.


152-155: fetchAndCacheValidators method implementation looks good.


156-182: validatorsView method implementation looks good.


184-192: getMyValidatorDelegation method implementation looks good.


194-208: fetchAndSaveMyValidatorDelegation method implementation looks good.


210-224: getValidatorDelegations method implementation looks good.


226-233: validatorDelegationView method implementation looks good.


234-247: loadAndCacheValidatorImages method implementation looks good.

src/core/lib/okp4/enums/endpoints.enum.ts 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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 507775a and 4a39789.
Files selected for processing (2)
  • src/modules/staking/dtos/validators-view.dto.ts (1 hunks)
  • src/modules/staking/services/staking.service.ts (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/modules/staking/dtos/validators-view.dto.ts
  • src/modules/staking/services/staking.service.ts

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4a39789 and 8bea6bb.
Files selected for processing (1)
  • src/modules/staking/services/staking.service.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/modules/staking/services/staking.service.ts

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8bea6bb and 6483209.
Files selected for processing (2)
  • src/core/lib/okp4/enums/endpoints.enum.ts (1 hunks)
  • src/core/lib/okp4/okp4.service.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/core/lib/okp4/enums/endpoints.enum.ts
  • src/core/lib/okp4/okp4.service.ts

@dbatarin dbatarin merged commit 7514183 into main May 15, 2024
11 checks passed
@dbatarin dbatarin deleted the feat/single-validator-page branch May 15, 2024 07:37
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