-
Notifications
You must be signed in to change notification settings - Fork 193
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/denom holders and stats #502
Conversation
WalkthroughThe changes involve updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant IndexerGrpcArchiverApi
participant IndexerGrpcArchiverTransformer
Client->>IndexerGrpcArchiverApi: fetchDenomHolders({ denom, token, limit })
IndexerGrpcArchiverApi->>IndexerGrpcArchiverTransformer: grpcDenomHoldersResponseToDenomHolders(response)
IndexerGrpcArchiverTransformer-->>IndexerGrpcArchiverApi: Transformed DenomHolders
IndexerGrpcArchiverApi-->>Client: Return DenomHolders
sequenceDiagram
participant Client
participant IndexerGrpcExplorerApi
participant IndexerGrpcExplorerTransformer
Client->>IndexerGrpcExplorerApi: fetchExplorerStats()
IndexerGrpcExplorerApi->>IndexerGrpcExplorerTransformer: getExplorerStatsResponseToExplorerStats(response)
IndexerGrpcExplorerTransformer-->>IndexerGrpcExplorerApi: Transformed ExplorerStats
IndexerGrpcExplorerApi-->>Client: Return ExplorerStats
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is protestware?This package is a joke, parody, or includes undocumented or hidden behavior unrelated to its primary function. Consider that consuming this package may come along with functionality unrelated to its primary purpose. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
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: 0
Outside diff range, codebase verification and nitpick comments (2)
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcPortfolioApi.ts (1)
Impact on Test Suite Due to Method Removal
The removal of the
fetchAccountPortfolioTokenHolders
method affects the test suite, as it is referenced in the following test file:
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcPortfolioApi.spec.ts
The test case using this method will need to be updated or removed to align with the changes in the codebase. Please ensure that the test suite is adjusted accordingly.
Analysis chain
Line range hint
1-1
: Verify the impact of removing thefetchAccountPortfolioTokenHolders
method.The removal of the
fetchAccountPortfolioTokenHolders
method from theIndexerGrpcAccountPortfolioApi
class is a significant change that eliminates the ability to fetch account portfolio token holders through this API.Ensure that this removal does not break any dependent components or services that relied on this method for retrieving token holder information.
Run the following script to verify the usage of the removed method:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the removed `fetchAccountPortfolioTokenHolders` method. # Test: Search for the method usage. Expect: No occurrences of the method call. rg --type typescript -A 5 $'fetchAccountPortfolioTokenHolders'Length of output: 96
Script:
#!/bin/bash # Description: Verify the usage of the removed `fetchAccountPortfolioTokenHolders` method. # Test: Search for the method usage. Expect: No occurrences of the method call. rg --type ts -A 5 $'fetchAccountPortfolioTokenHolders'Length of output: 1442
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts (1)
9-10
: Verify the usage ofstartDate
andendDate
in numeric contexts.The change from numbers to strings for
startDate
andendDate
inIndexerGrpcArchiverApi.spec.ts
could lead to issues if these values are used in contexts expecting numeric types. Specifically, inIndexerCampaignTransformer.ts
, these values are parsed usingparseInt
, indicating an expectation for numeric types. Ensure that appropriate conversions are in place to prevent potential issues.
packages/sdk-ts/src/client/indexer/transformers/IndexerCampaignTransformer.ts
: Lines 46-47 useparseInt
onstartDate
andendDate
.Analysis chain
Verify the impact of modifying the data types of
startDate
andendDate
constants.The data types of the
startDate
andendDate
constants have been modified from numeric values to strings. This change may impact how these dates are processed in subsequent logic, particularly if any functions expect these values to be in a specific format.Verify that modifying the data types of these constants does not break any functionality by running the following script:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that modifying the data types of `startDate` and `endDate` constants does not break any functionality. # Test: Search for usages of the `startDate` and `endDate` constants. # Expect: Only occurrences within the `IndexerGrpcArchiverApi.spec.ts` file. rg --type typescript --line-number $'startDate|endDate'Length of output: 91
Script:
#!/bin/bash # Description: Verify that modifying the data types of `startDate` and `endDate` constants does not break any functionality. # Test: Search for usages of the `startDate` and `endDate` constants. # Expect: Only occurrences within the `IndexerGrpcArchiverApi.spec.ts` file. rg --type ts --line-number $'startDate|endDate'Length of output: 3843
Script:
#!/bin/bash # Description: Search for function definitions and usages involving `startDate` and `endDate` to identify potential type mismatches. # Search for function definitions that include `startDate` or `endDate` as parameters. rg --type ts --line-number 'function .*startDate|endDate' # Search for usages of `startDate` and `endDate` in function calls. rg --type ts --line-number '\(.*startDate|endDate.*\)'Length of output: 2320
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
Files selected for processing (12)
- packages/sdk-ts/package.json (1 hunks)
- packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts (2 hunks)
- packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts (1 hunks)
- packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.spec.ts (1 hunks)
- packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.ts (1 hunks)
- packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcPortfolioApi.ts (1 hunks)
- packages/sdk-ts/src/client/indexer/transformers/IndexerAccountPortfolioTransformer.ts (2 hunks)
- packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts (2 hunks)
- packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcExplorerTransformer.ts (2 hunks)
- packages/sdk-ts/src/client/indexer/types/account-portfolio.ts (1 hunks)
- packages/sdk-ts/src/client/indexer/types/archiver.ts (2 hunks)
- packages/sdk-ts/src/client/indexer/types/explorer.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- packages/sdk-ts/src/client/indexer/types/account-portfolio.ts
Additional comments not posted (13)
packages/sdk-ts/src/client/indexer/types/archiver.ts (3)
37-40
: LGTM!The
Holder
interface is correctly defined with appropriate property types.
42-45
: LGTM!The
DenomHolders
interface is correctly defined with appropriate property types.Observation: The
next
property, which is an array of strings, could be used for pagination or continuation purposes.
57-57
: LGTM!The
GrpcDenomHolders
type alias is correctly defined and maps to the appropriate gRPC response type.packages/sdk-ts/package.json (1)
47-47
: Verify the changes introduced in the new version of the@injectivelabs/indexer-proto-ts
package.The version of the
@injectivelabs/indexer-proto-ts
package has been updated from1.11.49
to1.11.52
. This update suggests that there may be new features, bug fixes, or improvements included in the updated package version.Review the changelog or release notes of the
@injectivelabs/indexer-proto-ts
package to understand the specific changes introduced in version1.11.52
. Ensure that these changes are compatible with the SDK and do not introduce any breaking changes or unexpected behavior.Run the following script to retrieve the changelog:
packages/sdk-ts/src/client/indexer/transformers/IndexerAccountPortfolioTransformer.ts (1)
Line range hint
1-100
: Verify the impact of removing thetokenHoldersResponseToTokenHolders
method.The
tokenHoldersResponseToTokenHolders
static method has been removed entirely from theIndexerGrpcAccountPortfolioTransformer
class. This method was responsible for transforming aTokenHoldersResponse
from the Injective Portfolio RPC into aTokenHolders
object.Removing this method eliminates the capability to convert token holder responses into a structured format, potentially impacting any dependent components or services that relied on this transformation for processing token holder data.
Verify that removing this method does not break any functionality by running the following script:
packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts (1)
2-2
: LGTM!The changes are approved:
- The new import for
DenomHolders
from the../types/archiver
module is necessary for the new functionality.- The new static method
grpcDenomHoldersResponseToDenomHolders
enhances the class's capability to handle responses from the Injective Archiver RPC, specifically for denom holders, thereby expanding its functionality.Also applies to: 137-148
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts (1)
178-198
: LGTM!The addition of the new test case is approved. The new test case named
fetchDenomHolders
verifies the functionality of thefetchDenomHolders
method, which retrieves holders of a specific denomination (INJ_DENOM) with a specified limit.The test checks that the response is defined and matches the expected structure, utilizing the
grpcDenomHoldersResponseToDenomHolders
transformer for validation. The inclusion of error handling within the test also indicates a focus on robustness, ensuring that any exceptions during the API call are logged appropriately.packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.spec.ts (1)
226-243
: LGTM!The test case for the
fetchExplorerStats
method looks good. It covers the following aspects:
- Asynchronously calls the
fetchExplorerStats
method.- Verifies that the response is defined.
- Checks that the response matches the expected structure using
expect.objectContaining
and the return type ofIndexerGrpcExplorerTransformer.getExplorerStatsResponseToExplorerStats
.- Includes error handling to log any exceptions encountered during the execution of the
fetchExplorerStats
method.The test case is well-structured and ensures that the
fetchExplorerStats
method behaves as expected.packages/sdk-ts/src/client/indexer/types/explorer.ts (1)
Line range hint
382-401
: LGTM!The new interface
ExplorerStats
and typeGrpcExplorerStats
look good. They serve the following purposes:
The
ExplorerStats
interface defines several properties related to explorer statistics, such asassets
,txsTotal
,addresses
,injSupply
,txsInPast24Hours
,blockCountInPast24Hours
,txsPerSecondInPast24Hours
, andtxsPerSecondInPast100Blocks
, all of which are of typestring
. This provides a structured way to represent and access various statistics related to the blockchain explorer.The
GrpcExplorerStats
type maps toInjectiveExplorerRpc.GetStatsResponse
, which is likely the gRPC response type for the explorer stats endpoint. This type alias improves code readability and maintainability by providing a clear and concise name for the gRPC response type.Overall, these additions enhance the module's functionality and usability by providing a well-defined structure for explorer statistics.
packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts (1)
309-354
: LGTM!The new method
fetchDenomHolders
in theIndexerGrpcArchiverApi
class looks good. It follows the existing patterns in the class and enhances the API by allowing clients to fetch denom holders with additional parameters. Here's a breakdown of the method:
- It accepts an object with three properties:
denom
(a required string),token
(an optional string), andlimit
(an optional number).- It constructs a request using
InjectiveArchiverRpc.DenomHoldersRequest
, setting thedenom
property directly and conditionally assigning thetoken
andlimit
properties if they are provided.- It attempts to execute a gRPC call to fetch the denom holders using the constructed request.
- It employs a retry mechanism to handle the request, which is consistent with other methods in the class.
- It returns the transformed response using
IndexerGrpcArchiverTransformer.grpcDenomHoldersResponseToDenomHolders
, ensuring that the response is in the expected format.- It handles errors by distinguishing between a
GrpcWebError
and other types of errors, throwing aGrpcUnaryRequestException
with appropriate context and error codes.Overall, this new method is a valuable addition to the
IndexerGrpcArchiverApi
class, providing clients with the ability to fetch denom holders with additional parameters in a consistent and error-handled manner.packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcExplorerTransformer.ts (2)
6-6
: LGTM!The changes to the import statements improve code organization and are necessary for the new
getExplorerStatsResponseToExplorerStats
method.Also applies to: 8-8, 10-11, 15-15, 17-19, 21-23
400-413
: LGTM!The new
getExplorerStatsResponseToExplorerStats
method correctly transforms the gRPC response into a more usableExplorerStats
object. It enhances the functionality of the class by providing a new utility for handling explorer statistics.packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcExplorerApi.ts (1)
544-570
: LGTM!The new
fetchExplorerStats
method correctly implements the logic for fetching explorer statistics and handles errors appropriately. It uses theIndexerGrpcExplorerTransformer.getExplorerStatsResponseToExplorerStats
method to transform the response into a more usable format.
const startDate = String(1622505600) | ||
const endDate = String(1625097600) |
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.
Lets do this instead
'1622505600'
limit, | ||
}: { | ||
denom: string | ||
token?: string |
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.
whats the difference between token and symbol?
Maybe we should rename this as symbol, at least on the FE side it will be clearer
request.token = symbol
Changes
Note: this will stay in draft til data validation is complete
Summary by CodeRabbit
New Features
fetchDenomHolders
andfetchExplorerStats
for enhanced data retrieval capabilities.Holder
,DenomHolders
, andExplorerStats
to improve data structure and usability.Bug Fixes
Removals
Tests
fetchDenomHolders
andfetchExplorerStats
methods.