-
Notifications
You must be signed in to change notification settings - Fork 139
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(multichain): token search endpoint #1164
Conversation
WalkthroughThe pull request introduces a comprehensive enhancement to the multichain aggregator's token and search capabilities. Two new public modules, Poem
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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: 1
🧹 Nitpick comments (13)
multichain-aggregator/multichain-aggregator-server/src/server.rs (1)
79-79
: Add error handling and timeouts for external HTTP calls.When initializing
token_info_client
withTokenInfoClient::new(settings.service.token_info_client.url)
, consider configuring sensible defaults such as timeouts and retry strategies to handle potential network failures or invalid URLs.multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (1)
117-146
: Newlist_tokens
method for enhanced coverage.This addition expands the aggregator to return token results. The error is logged if the external client call fails, and you return consistent pagination data. Consider adding unit tests covering edge cases like invalid query, empty results, and large
page_size
.multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (1)
18-18
: Addingpub tokens: Vec<Token>
toChainSearchResult
This change nicely integrates token data into the chain-level search result. As the quantity of tokens could grow large, consider potential impacts on performance or memory usage.multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs (2)
5-8
:TokenInfoClient
struct definition
The minimal fieldshttp
andurl
are sufficient to set up and manage requests. Consider later expansions like configurable timeouts or request headers if needed.
32-36
:TokenInfoClient::new
constructor
Establishes an HTTP client and URL. This design is a good starting point. Consider offering client injection for testability.multichain-aggregator/multichain-aggregator-server/src/settings.rs (2)
58-62
: Consider environment-driven configuration.Having a dedicated
TokenInfoClientSettings
struct is good for modularity. For production readiness, consider an environment-based override to align with typical deployment patterns (e.g., Docker, Kubernetes).
84-86
: Use environment variable for default URL in non-local deployments.Relying on a localhost URL is practical for development, but you may want to override this in real environments. Expose the URL through an environment variable for flexibility.
multichain-aggregator/multichain-aggregator-logic/src/search.rs (1)
99-111
: Thoroughly handle token search results.Good approach for capturing token results in the main search output. Ensure that partial failures (token search failing) are handled gracefully to avoid partial data confusion.
multichain-aggregator/multichain-aggregator-logic/src/error.rs (1)
32-33
: Add documentation for the Custom variantWhile the implementation is correct, consider adding documentation to explain when and how the Custom variant should be used. This helps maintain consistency in error handling across the codebase.
+ /// Represents a custom parsing error with a descriptive message. + /// Use this variant when other specific error variants don't apply. #[error("parse error: {0}")] Custom(String),multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml (4)
30-33
: LGTM! Consider adding parameter description.The
chain_id
parameter is correctly defined as an optional string parameter. However, adding a description field would help API consumers understand the expected format and valid values.- name: chain_id in: query required: false type: string + description: "Blockchain network identifier (e.g., '1' for Ethereum mainnet)"
84-115
: LGTM! Consider enhancing API documentation.The
/api/v1/tokens
endpoint is well-structured with appropriate parameters. A few suggestions to improve the API documentation:
- Add descriptions for query parameters
- Document additional response codes (e.g., 400 for invalid parameters)
parameters: - name: q in: query required: false type: string + description: "Search query to filter tokens by name or symbol" - name: chain_id in: query required: false type: string + description: "Blockchain network identifier to filter tokens" responses: "200": description: A successful response. schema: $ref: '#/definitions/v1ListTokensResponse' + "400": + description: Bad Request - Invalid parameters + schema: + $ref: '#/definitions/rpcStatus'
347-359
: Consider adding optional fields for enhanced token information.The
v1Token
model includes basic token information. Consider adding optional fields that might be useful for token search results:
decimals
: Token decimals for proper value displaytotal_supply
: Token's total supplyverified
: Boolean indicating if the token contract is verifiedv1Token: type: object properties: address: type: string icon_url: type: string name: type: string symbol: type: string chain_id: type: string + decimals: + type: integer + format: int32 + total_supply: + type: string + verified: + type: boolean
Line range hint
1-4
: Consider adding explicit version information.The API version is currently only reflected in the path (
/api/v1/
). Consider adding explicit version information in the info section:swagger: "2.0" info: title: v1/multichain-aggregator.proto - version: version not set + version: "1.0.0" + description: "Multichain Aggregator API for token and address information"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/error.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/import.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/lib.rs
(2 hunks)multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/search.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs
(2 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/hashes.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/token_info.rs
(1 hunks)multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml
(1 hunks)multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto
(4 hunks)multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml
(8 hunks)multichain-aggregator/multichain-aggregator-server/src/server.rs
(2 hunks)multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs
(6 hunks)multichain-aggregator/multichain-aggregator-server/src/settings.rs
(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- multichain-aggregator/multichain-aggregator-logic/src/lib.rs
🔇 Additional comments (44)
multichain-aggregator/multichain-aggregator-server/src/server.rs (2)
13-16
: Ensure concurrency safety for new client usage.
The added imports for DappClient
and TokenInfoClient
look coherent. However, verify that any shared usage of these clients supports concurrency. Given these clients likely perform network calls, consider whether Arc-based sharing or explicit concurrency control is needed to prevent race conditions and ensure thread-safety.
85-85
: Confirm tests cover this new dependency in the aggregator.
This logic now depends on token_info_client
. Ensure that integration tests validate responses from the aggregator when calls to the token info service fail or produce unexpected data, preventing uncaught exceptions or partial failures.
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (7)
10-15
: Good use of specialized imports.
Importing TokenInfoClient
alongside DappClient
helps keep external logic clearly compartmentalized. This approach makes the aggregator more flexible in handling both decentralized apps and tokens while promoting clean separation of concerns.
16-17
: Neat addition of token-specific request/response types.
Including ListTokensRequest
and ListTokensResponse
in the proto imports cleanly integrates token functionality at the gRPC layer. Make sure these types are well-documented so future maintainers understand their usage.
29-29
: New field for token lookup.
The token_info_client
field is a useful addition, allowing the aggregator to fetch token data. Verify that all consumers of this struct pass a properly initialized client to avoid runtime errors.
38-46
: Constructor updated with token_info_client
.
The constructor now properly handles the additional dependency for token retrieval. This design follows standard dependency injection patterns, enhancing testability and modularity.
77-77
: Enhanced error inspection for batch_import
.
Using .inspect_err
here is consistent with other methods in the file, ensuring errors are logged for easier debugging while still returning a Result
.
95-104
: Chain-aware address listing.
Including chain_id
in search_by_query_paginated
is a solid step to return chain-specific addresses. The usage of .inspect_err
is also consistently applied. Consider verifying that an invalid or unsupported chain_id
is handled gracefully at the repository level.
154-164
: Quick search now integrates tokens.
Including &self.token_info_client
aligns with the aggregator's expanded scope. Ensure any timeouts or service unavailability from the token service are handled or retried for more robust functionality.
multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs (1)
9-9
: Added token_info
module.
Introducing pub mod token_info;
is a clean way to organize new token-related types. Keep module boundaries well-defined to maintain code clarity.
multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs (2)
2-2
: Reorganized import structure for DappWithChainId
.
Switching to clients::dapp::DappWithChainId
clarifies ownership of the DappWithChainId
struct under the clients
module. This helps future contributors locate related client logic more easily.
34-34
: Converting chain_id
to string in the proto struct.
Serializing chain_id
as a string suits multi-chain use cases, where numeric or alphanumeric chain IDs might vary widely. Ensure any consumers correctly parse this back if numeric operations are needed.
multichain-aggregator/multichain-aggregator-logic/src/import.rs (1)
9-23
: Improved logging for upsert operations.
Using .inspect_err
to log specific failures during upsert improves troubleshooting, making issues more apparent. This consistent logging pattern across addresses, block ranges, and hashes leads to more maintainable error handling.
multichain-aggregator/multichain-aggregator-logic/src/types/token_info.rs (2)
13-29
: Robust conversion from TokenInfo
to Token
.
The TryFrom
implementation validates each field (including chain ID and required strings), neatly surfacing parsing errors via ParseError
. This explicit error handling prevents silent failures if the token data is malformed.
31-41
: Mapping Token
into proto layer cleanly.
Converting Token
into proto::Token
with string-based fields, including address
and chain_id
, is consistent with typical gRPC best practices. This ensures maximum compatibility across different services and languages.
multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs (2)
3-5
: Imports appear consistent and necessary.
Including token_info::Token
alongside existing imports seems appropriate for the new token functionality.
30-30
: Converting tokens in the From<ChainSearchResult>
implementation
Mapping the tokens to proto objects is correct and aligns with the behavior for other fields.
multichain-aggregator/multichain-aggregator-logic/src/types/hashes.rs (1)
40-40
: Including chain_id
string conversion
Adding chain_id: v.chain_id.to_string()
ensures the proto representation consistently includes the chain ID. Looks good.
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs (5)
1-4
: Imports for ServiceError
, ChainId
, Deserialize
, and Url
All are relevant for HTTP requests, JSON parsing, and referencing chain ID types. No issues noted.
10-18
: TokenInfo
struct
Captures essential token details, including optional fields for name and symbol. Using Option<>
is a good approach to handle tokens lacking some metadata.
20-24
: TokenInfoSearchResponse
struct
Contains a list of TokenInfo
and pagination details. Straightforward and consistent with typical patterns for paginated responses.
26-30
: Pagination
struct
Clean implementation for page tokens and sizes. Should integrate well with other standard paginated endpoints.
38-70
: search_tokens
method
Uses query parameters appropriately, with robust error handling mapped into ServiceError
. The logic is sound and aligns with typical async HTTP request flows in Rust.
multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto (7)
11-11
: New RPC method: ListTokens
This new method is consistent with the existing style of the service and fits the need for token retrieval.
37-37
: Introducing chain_id
fields in multiple messages
Standardizing on a string
type for chain ID is flexible. Ensure all references to chain_id
are consistent throughout the codebase for conversions and validations.
Also applies to: 43-43, 55-55, 63-63, 71-71
66-71
: New Token
message
Matches the structure used by TokenInfo
in the logic layer. The field names (address, icon_url, name, symbol, chain_id) align well.
99-99
: Adding repeated Token tokens
to ChainSearchResult
Enables returning token data from quick searches. Matches the approach in other repeated fields.
107-109
: Reordered fields in ListAddressesRequest
No issues spotted. The optional usage for these fields is appropriate.
117-122
: ListTokensRequest
definition
Includes q
, chain_id
, and pagination parameters. Aligns with the needs of token searches.
124-127
: ListTokensResponse
definition
Echoes the pattern for other listing endpoints, featuring a repeated Token
field and Pagination
.
multichain-aggregator/multichain-aggregator-server/src/settings.rs (1)
29-29
: Double-check usage of token_info_client
field throughout the codebase.
This new field is a welcome addition for token information requests. Ensure all referencing modules handle potential misconfigurations or unreachable endpoints gracefully.
multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs (1)
69-69
: Confirm string-based chain_id
usage.
Ensuring the chain_id
is a string in the proto struct appears consistent. Verify downstream services expect this format.
multichain-aggregator/multichain-aggregator-logic/src/search.rs (7)
2-2
: Consolidated client imports look good.
This unified structure promotes better maintainability.
9-9
: Token model import is consistent with the new functionality.
Adding the Token
import ensures the search results can incorporate tokens; looks fine.
16-16
: Instrumentation with tracing::instrument
is a good practice.
Enhances observability for debugging. Ensure logs are not overly verbose.
33-33
: Expanded quick_search
signature is logical.
The additional token_info_client
parameter aligns well with the new token search flow.
37-37
: Keep parameter naming consistent.
token_info_client
naming is clear and consistent. No issues here.
43-43
: Joining new async calls ensures parallel processing.
This call to token_info_client.search_tokens
capitalizes on concurrency for performance gains.
48-48
: Validate search constraints.
The request includes fixed pagination (Some(100)
). Validate if you need dynamic pagination for large search results.
multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs (4)
57-57
: Parameter passing to search_by_query_paginated
.
Passing None
for the chain ID maintains the original behavior. No issues spotted.
65-65
: New chain_id
parameter improves query specificity.
Optional filtering allows more granular searches. This is a beneficial extension.
88-90
: Conditional chain ID filter is correctly implemented.
The filter logic ensures narrower queries when chain_id
is provided. Good job!
91-91
: Highlight performance considerations for large data sets.
Be mindful of potential query costs if a chain ID is not provided. Index usage may still be efficient, but confirm actual performance in production.
multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml (1)
17-19
: LGTM! The endpoint configuration follows RESTful and versioning conventions.
The new /api/v1/tokens
endpoint is well-structured and properly placed in the configuration.
3f8ef40
to
a77599e
Compare
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
🧹 Nitpick comments (5)
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (1)
117-146
: Consider improvements to the token listing implementation.While the implementation is functional, consider the following improvements:
- The page size should be normalized using the existing
normalize_page_size
method:- .search_tokens(&inner.q, chain_id, inner.page_size, inner.page_token) + .search_tokens(&inner.q, chain_id, self.normalize_page_size(inner.page_size), inner.page_token)
- The token conversion error handling could be more specific to help with debugging:
- .map_err(ServiceError::from)?; + .map_err(|e| { + tracing::error!("Token conversion failed: {:?}", e); + ServiceError::from(e) + })?;
- Consider extracting the chain_id parsing into a reusable function since it's used in multiple methods.
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs (2)
21-24
: Add serde attribute toTokenInfoSearchResponse
for consistent deserializationThe
TokenInfoSearchResponse
struct lacks a serde attribute to handle potential naming mismatches between Rust and the JSON response from the API. To ensure fields are correctly deserialized, consider adding#[serde(rename_all = "camelCase")]
, matching the API's naming convention.Apply this diff to add the serde attribute:
#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct TokenInfoSearchResponse { pub token_infos: Vec<TokenInfo>, pub next_page_params: Option<Pagination>, }
26-30
: Add serde attribute toPagination
struct for consistencySimilarly, the
Pagination
struct may benefit from a serde attribute to ensure proper deserialization of JSON fields. Adding#[serde(rename_all = "camelCase")]
aligns field names with the expected JSON format.Apply this diff to update the
Pagination
struct:#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct Pagination { pub page_token: String, pub page_size: u32, }
multichain-aggregator/multichain-aggregator-logic/src/search.rs (1)
99-111
: Enhance error logging for token conversion failuresWhile the error handling pattern is consistent, silently dropping failed token conversions could hide issues. Consider logging conversion failures to aid debugging.
let tokens: Vec<Token> = token_infos .token_infos .into_iter() - .filter_map(|t| t.try_into().ok()) + .filter_map(|t| match t.try_into() { + Ok(token) => Some(token), + Err(e) => { + tracing::warn!(error = ?e, token = ?t, "failed to convert token info"); + None + } + }) .collect();multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml (1)
362-374
: Enhance token schema documentation and validationConsider adding:
- Field descriptions to improve API documentation
- Format specification for the
address
field to validate Ethereum addressesv1Token: type: object properties: address: type: string + description: The token contract address + pattern: ^0x[a-fA-F0-9]{40}$ icon_url: type: string + description: URL to the token's icon name: type: string + description: The token name symbol: type: string + description: The token symbol chain_id: type: string + description: The blockchain network identifier
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/error.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/import.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/lib.rs
(2 hunks)multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/search.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs
(2 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/hashes.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs
(3 hunks)multichain-aggregator/multichain-aggregator-logic/src/types/token_info.rs
(1 hunks)multichain-aggregator/multichain-aggregator-proto/build.rs
(1 hunks)multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml
(1 hunks)multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto
(3 hunks)multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml
(9 hunks)multichain-aggregator/multichain-aggregator-server/src/server.rs
(2 hunks)multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs
(6 hunks)multichain-aggregator/multichain-aggregator-server/src/settings.rs
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
- multichain-aggregator/multichain-aggregator-logic/src/clients/mod.rs
- multichain-aggregator/multichain-aggregator-proto/proto/v1/api_config_http.yaml
- multichain-aggregator/multichain-aggregator-logic/src/import.rs
- multichain-aggregator/multichain-aggregator-logic/src/error.rs
- multichain-aggregator/multichain-aggregator-logic/src/types/mod.rs
- multichain-aggregator/multichain-aggregator-logic/src/types/search_results.rs
- multichain-aggregator/multichain-aggregator-server/src/settings.rs
- multichain-aggregator/multichain-aggregator-logic/src/lib.rs
- multichain-aggregator/multichain-aggregator-logic/src/types/dapp.rs
- multichain-aggregator/multichain-aggregator-server/src/server.rs
- multichain-aggregator/multichain-aggregator-logic/src/types/token_info.rs
- multichain-aggregator/multichain-aggregator-logic/src/types/addresses.rs
- multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Linting / lint
- GitHub Check: Unit, doc and integration tests
🔇 Additional comments (14)
multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs (4)
10-17
: LGTM! Clean integration of token-related functionality.The new imports and struct field additions are well-organized and maintain consistency with the existing codebase structure.
Also applies to: 29-29
38-38
: LGTM! Constructor properly updated.The constructor changes cleanly integrate the new TokenInfoClient while maintaining good initialization patterns.
Also applies to: 46-46
77-79
: LGTM! Consistent error handling pattern.The use of
inspect_err
for error logging is a good improvement that enhances error visibility while maintaining the error chain.Also applies to: 104-106
154-164
: LGTM! Quick search properly integrated with token functionality.The changes maintain consistency with the established error handling pattern and properly integrate the token search capability.
multichain-aggregator/multichain-aggregator-logic/src/types/hashes.rs (2)
40-40
: Ensurechain_id
serialization aligns withproto::Hash
expectationsThe addition of
chain_id
in theFrom<Hash> for proto::Hash
implementation suggests thatproto::Hash
has achain_id
field expecting aString
. Verify thatv.chain_id.to_string()
produces the correct representation and that it matches the expected format inproto::Hash
.
45-55
: Confirm allHashType
variants are handledIn the functions
proto_hash_type_to_db_hash_type
anddb_hash_type_to_proto_hash_type
, ensure that all possible variants ofHashType
are accounted for. If new variants are added in the future, remember to update these functions to maintain exhaustive matching.multichain-aggregator/multichain-aggregator-proto/build.rs (1)
21-25
: Verify correctness of field attributes inbuild.rs
The
field_attribute
method calls have been updated to reflect new proto definitions. Ensure that the field paths:
.blockscout.multichainAggregator.v1.BatchImportRequest.AddressImport.token_type
.blockscout.multichainAggregator.v1.TokenType.TOKEN_TYPE_ERC_20
.blockscout.multichainAggregator.v1.TokenType.TOKEN_TYPE_ERC_721
.blockscout.multichainAggregator.v1.TokenType.TOKEN_TYPE_ERC_1155
.blockscout.multichainAggregator.v1.TokenType.TOKEN_TYPE_ERC_404
correctly correspond to the fields defined in your proto files. Incorrect paths could lead to compilation errors or incorrect serialization/deserialization behavior.
Consider running the following script to validate the field paths:
✅ Verification successful
Field attributes in
build.rs
are correctly definedAll field paths in the
build.rs
file accurately correspond to the proto definitions inmultichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto
. The package name, message structure, and enum values are perfectly aligned with the field attributes.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the field paths in build.rs match the proto definitions. # Expected: No errors should be reported. # Check for the existence of the fields in the proto files grep -E 'AddressImport|TokenType' proto/v1/multichain-aggregator.protoLength of output: 142
Script:
#!/bin/bash # First, find all proto files in the repository echo "=== Finding proto files ===" fd -e proto # Then search for relevant definitions in all proto files echo -e "\n=== Searching for package definition ===" rg "package blockscout.multichainAggregator.v1" -A 1 echo -e "\n=== Searching for TokenType enum ===" rg "enum TokenType" -A 10 echo -e "\n=== Searching for AddressImport message ===" rg "message AddressImport" -A 10Length of output: 6969
multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto (3)
11-12
: LGTM! Service definition follows established patterns.The new
ListTokens
RPC method aligns with the existing service design pattern for list operations.
73-92
: LGTM! Well-structured message organization.The restructuring of
BatchImportRequest
using nested message types improves code organization and maintainability.
136-146
: LGTM! Consistent with existing list operation patterns.The
ListTokensRequest
andListTokensResponse
messages follow the established patterns for paginated list operations.multichain-aggregator/multichain-aggregator-logic/src/search.rs (1)
2-2
: LGTM! Function signature updated appropriately.The addition of
TokenInfoClient
and its integration into thequick_search
function is consistent with the new token search feature.Also applies to: 37-37
multichain-aggregator/multichain-aggregator-proto/swagger/v1/multichain-aggregator.swagger.yaml (3)
84-115
: LGTM! Well-defined REST endpoint.The
/api/v1/tokens
endpoint follows REST API best practices and maintains consistency with other list endpoints in the API.
139-173
: LGTM! Clear and well-organized schema definitions.The separation of import types into distinct message definitions improves schema clarity while maintaining backward compatibility.
375-383
: LGTM! Well-defined token type enumeration.The
v1TokenType
enum properly defines the supported token standards and follows OpenAPI enum conventions.
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs
Outdated
Show resolved
Hide resolved
multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto
Show resolved
Hide resolved
multichain-aggregator/multichain-aggregator-proto/proto/v1/multichain-aggregator.proto
Show resolved
Hide resolved
multichain-aggregator/multichain-aggregator-logic/src/search.rs
Outdated
Show resolved
Hide resolved
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
♻️ Duplicate comments (1)
multichain-aggregator/multichain-aggregator-logic/src/search.rs (1)
53-60
: 🛠️ Refactor suggestionParameterize the hardcoded page size
The hardcoded page size of 100 should be configurable to allow for flexibility and performance tuning.
🧹 Nitpick comments (3)
multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs (1)
47-47
: Consider usingChainId
type forchain_id
fieldThe
chain_id
field in theTokenInfo
struct is currently aString
. For type safety and consistency across the codebase, consider using theChainId
type instead ofString
.Apply this diff to update the field type:
pub struct TokenInfo { pub token_address: String, - pub chain_id: String, + pub chain_id: ChainId, pub icon_url: String, pub token_name: Option<String>, pub token_symbol: Option<String>, }multichain-aggregator/multichain-aggregator-logic/src/clients/dapp.rs (1)
42-42
: Consider usingChainId
type forchain_id
fieldIn the
DappWithChainId
struct, thechain_id
field is defined as aString
. To enhance type safety and maintain consistency with other parts of the codebase, consider using theChainId
type.Apply this diff to update the field type:
pub struct DappWithChainId { pub dapp: Dapp, - pub chain_id: String, + pub chain_id: ChainId, }multichain-aggregator/multichain-aggregator-logic/src/search.rs (1)
118-130
: Consider logging conversion errorsThe
filter_map
withtry_into().ok()
silently drops conversion errors. Consider logging these errors for better visibility:- .filter_map(|t| t.try_into().ok()) + .filter_map(|t| match t.try_into() { + Ok(token) => Some(token), + Err(err) => { + tracing::warn!(error = ?err, "failed to convert token info"); + None + } + })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
multichain-aggregator/Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (8)
multichain-aggregator/Cargo.toml
(1 hunks)multichain-aggregator/multichain-aggregator-logic/Cargo.toml
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/clients/dapp.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/clients/token_info.rs
(1 hunks)multichain-aggregator/multichain-aggregator-logic/src/search.rs
(3 hunks)multichain-aggregator/multichain-aggregator-server/Cargo.toml
(1 hunks)multichain-aggregator/multichain-aggregator-server/src/server.rs
(2 hunks)multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- multichain-aggregator/multichain-aggregator-server/src/server.rs
- multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Linting / lint
- GitHub Check: Unit, doc and integration tests
🔇 Additional comments (6)
multichain-aggregator/Cargo.toml (1)
56-56
: Consider using a tagged version instead of commit hash.While using a specific commit hash (
d60c1d8
) ensures reproducibility, it's recommended to:
- Use a tagged version for better stability and maintenance, similar to how other blockscout dependencies are versioned in this file.
- Document the reason for using this specific commit if a tagged version cannot be used.
Please verify that this commit hash is the intended version and hasn't been superseded by a stable release. Run this script to check:
multichain-aggregator/multichain-aggregator-logic/Cargo.toml (1)
10-10
: New dependencies are appropriateThe addition of
api-client-framework
andserde_with
dependencies is appropriate for the new client implementations and serialization needs.Also applies to: 18-18
multichain-aggregator/multichain-aggregator-server/Cargo.toml (1)
14-14
: LGTM: Workspace dependency additionThe addition of
api-client-framework
as a workspace dependency is appropriate for implementing the token search functionality while maintaining version consistency across the workspace.multichain-aggregator/multichain-aggregator-logic/src/search.rs (3)
2-16
: LGTM: Clean import organizationThe imports are well-organized and properly scoped for the new token search functionality.
62-67
: LGTM: Efficient parallel executionGood use of
join!
macro to execute searches in parallel, improving response time.
37-44
: Breaking change: Function signature updateThe addition of
token_info_client
parameter makes this a breaking change. Ensure all callers ofquick_search
are updated accordingly.Let's verify all callers of this function:
Summary by CodeRabbit
New Features
TokenInfoClient
for retrieving token information, including a new API endpoint/api/v1/tokens
.quick_search
functionality to include token information retrieval.list_tokens
method in theMultichainAggregatorService
.chain_id
filtering to address search functionalities.Bug Fixes
Documentation
Refactor
Chores
TokenInfoClient
.