-
Notifications
You must be signed in to change notification settings - Fork 0
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: add wallet rewards history #57
Conversation
WalkthroughThe update introduces a configuration for wallet reward history TTL with extensive integration across multiple parts of the application. It includes the addition of a method to fetch and cache wallet reward history in the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (18)
- .env.example (1 hunks)
- src/core/config/config.dto.ts (1 hunks)
- src/core/config/config.schema.ts (1 hunks)
- src/core/config/config.ts (1 hunks)
- src/core/lib/okp4/enums/endpoints.enum.ts (1 hunks)
- src/core/lib/okp4/okp4.service.ts (2 hunks)
- src/core/lib/okp4/responses/rewards-history.response.ts (1 hunks)
- src/modules/governance/services/governance.service.ts (6 hunks)
- src/modules/wallet/dtos/get-wallet-rewards-history.dto.ts (1 hunks)
- src/modules/wallet/enums/wallet-prefix.enum.ts (1 hunks)
- src/modules/wallet/schemas/get-wallet-rewards-history.schema.ts (1 hunks)
- src/modules/wallet/wallet-cache.ts (1 hunks)
- src/modules/wallet/wallet-routes.enum.ts (1 hunks)
- src/modules/wallet/wallet.controller.ts (2 hunks)
- src/modules/wallet/wallet.module.ts (1 hunks)
- src/modules/wallet/wallet.service.ts (2 hunks)
- utils/create-hash.ts (1 hunks)
- utils/exctract-numbers.ts (1 hunks)
Files skipped from review due to trivial changes (7)
- .env.example
- src/core/config/config.dto.ts
- src/modules/wallet/dtos/get-wallet-rewards-history.dto.ts
- src/modules/wallet/enums/wallet-prefix.enum.ts
- src/modules/wallet/schemas/get-wallet-rewards-history.schema.ts
- src/modules/wallet/wallet-routes.enum.ts
- utils/create-hash.ts
Additional context used
Biome
src/modules/wallet/wallet.service.ts
[error] 58-58: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
Additional comments not posted (17)
src/modules/wallet/wallet.module.ts (1)
6-7
: LGTM! Ensure proper initialization of new providers.The addition of
WalletCache
andRedisService
as providers is correct. Verify that these services are properly initialized and configured.Also applies to: 11-11
Verification successful
Initialization and Configuration Verified
The
WalletCache
andRedisService
services are properly initialized and configured.
WalletCache
correctly injectsRedisService
via its constructor.RedisService
is set up with necessary configurations for Redis operations.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the proper initialization and configuration of WalletCache and RedisService. # Test: Check for the initialization of WalletCache and RedisService. rg --type ts 'WalletCache|RedisService' src/modules/wallet/Length of output: 808
Script:
#!/bin/bash # Description: Verify the proper initialization and configuration of WalletCache and RedisService. # Check the implementation of WalletCache class to ensure proper initialization ast-grep --lang typescript --pattern $'class WalletCache { constructor(private readonly redisService: RedisService) { $$$ } }' src/modules/wallet/wallet-cache.ts # Check for the RedisService class or its configuration rg --type ts 'class RedisService|RedisService' src/Length of output: 2463
Script:
#!/bin/bash # Description: Retrieve the contents of RedisService class for review. # Display the contents of RedisService class. cat src/core/lib/redis.service.tsLength of output: 683
src/core/config/config.schema.ts (1)
26-26
: LGTM! Ensure proper usage of the new configuration.The addition of the
WALLET_REWARD_HISTORY_TTL
configuration is correct. Verify that this configuration is properly used in the application.Verification successful
Proper usage of the new configuration verified.
The
WALLET_REWARD_HISTORY_TTL
configuration is correctly utilized in the application, specifically in the wallet service and wallet cache modules.
src/modules/wallet/wallet.service.ts
: Referenced in thewalletRewardHistoryView
method.src/modules/wallet/wallet-cache.ts
: Used directly inredisService.setWithTTL
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of WALLET_REWARD_HISTORY_TTL configuration in the application. # Test: Check for the usage of WALLET_REWARD_HISTORY_TTL in the application. rg --type ts 'WALLET_REWARD_HISTORY_TTL' src/Length of output: 224
Script:
#!/bin/bash # Description: Verify the usage of walletRewardHistory configuration in the application. # Test: Check for the usage of walletRewardHistory in the application. rg --type ts 'walletRewardHistory' src/Length of output: 587
Script:
#!/bin/bash # Description: Verify the usage of walletRewardHistory configuration in the application. # Test: Check for the context and usage of walletRewardHistory in wallet.service.ts. rg --type ts 'walletRewardHistory' src/modules/wallet/wallet.service.ts # Test: Check for the context and usage of walletRewardHistory in wallet-cache.ts. rg --type ts 'walletRewardHistory' src/modules/wallet/wallet-cache.tsLength of output: 427
src/modules/wallet/wallet-cache.ts (2)
31-33
: LGTM!The method follows best practices and the code changes are approved.
21-29
: Specify the type of the parsed object for better type safety.The type of the parsed object is not specified. Consider specifying the type of the parsed object for better type safety.
- private async getObjectFromRedis<T>(key: string): Promise<T | null> { + private async getObjectFromRedis<T>(key: string): Promise<RewardsHistory | null> {Likely invalid or redundant comment.
src/modules/wallet/wallet.controller.ts (2)
Line range hint
12-20
:
LGTM!The method follows best practices and the code changes are approved.
23-29
: LGTM!The method follows best practices and the code changes are approved.
src/core/lib/okp4/enums/endpoints.enum.ts (2)
19-19
: LGTM!The modification follows best practices and the code changes are approved.
20-20
: LGTM!The addition follows best practices and the code changes are approved.
src/core/config/config.ts (1)
33-33
: LGTM!The addition follows best practices and the code changes are approved.
src/modules/wallet/wallet.service.ts (3)
31-39
: LGTM!The
getWalletRewardsHistory
function correctly fetches wallet reward history from the cache or fetches and caches it if not present. The logic is clear and sound.
41-46
: LGTM!The
fetchAndCacheRewardsHistory
function effectively fetches wallet reward history, processes it, and caches the result using a hashed key. The logic is clear and efficient.
12-12
: LGTM!The constructor has been updated to include
WalletCache
, which is necessary for the caching functionality. The logic is clear and straightforward.src/modules/governance/services/governance.service.ts (3)
71-71
: LGTM!The
getProposals
function correctly fetches proposals from the cache or fetches and caches them if not present. The logic is clear and sound.
101-101
: LGTM!The
fetchProposals
function effectively fetches proposals, processes them, and caches the result using a hashed key. The logic is clear and efficient.
204-204
: LGTM!The
getProposalVotes
function correctly fetches proposal votes from the cache or fetches and caches them if not present. The logic is clear and sound.src/core/lib/okp4/okp4.service.ts (1)
312-335
: LGTM!The
getWalletRewardsHistory
function constructs the necessary parameters and fetches the wallet reward history using an external service. The logic is clear and sound.utils/exctract-numbers.ts (1)
1-7
: LGTM! Consider adding comments and unit tests.The function implementation is correct and efficient. Adding comments would improve readability, and unit tests would ensure correctness.
+ // Extracts all digit sequences from the input string and returns them as an array of numbers. + // Returns an empty array if no digit sequences are found.Would you like me to generate unit tests for this function or open a GitHub issue to track this task?
No description provided.