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

Chore/hub updates #49

Merged
merged 9 commits into from
May 24, 2024
Merged

Chore/hub updates #49

merged 9 commits into from
May 24, 2024

Conversation

shane-moore
Copy link
Contributor

@shane-moore shane-moore commented May 2, 2024

Summary by CodeRabbit

  • New Features

    • Introduced asset price fetching functionality using CoinGecko and Injective services.
    • Added session management to wallet state.
  • Enhancements

    • Improved error handling for asset price services.
    • Simplified asset microservice endpoint logic.
    • Added new constants for better configuration management.
  • Bug Fixes

    • Fixed redundant URL constants in asset price service.
  • Refactor

    • Reordered import statements for better readability.
    • Updated wallet strategy options with metadata.
  • Documentation

    • Updated interfaces to reflect new methods and structures in asset price services.

Copy link

coderabbitai bot commented May 2, 2024

Walkthrough

The recent update introduces the InjectiveAssetService and CoinGeckoApi for enhanced asset price fetching and coin data handling. Constants and utility functions were added or refactored to streamline endpoint management. Wallet state management was improved with session handling. Additionally, new constants and functions were introduced to support network-specific configurations and project metadata.

Changes

File(s) Change Summary
layer/Service.ts Added InjectiveAssetService and CoinGeckoApi imports, initialized services, reordered imports, and updated constants.
layer/services/assetPrice/CoinGeckoApi.ts Introduced CoinGeckoApi class with methods for fetching coin data, prices, charts, and historical data from CoinGecko API.
layer/services/assetPrice/assetService/index.ts Added InjectiveAssetService class with methods for fetching asset prices, coin details, coin lists, market charts, and historical data.
layer/services/assetPrice/assetService/types.ts Introduced CoinPriceFromInjectiveService interface for representing coin price data.
layer/services/assetPrice/index.ts Updated exports for asset price services, including CoinGeckoApi, assetService, and types.
layer/services/assetPrice/types.ts Added interfaces for handling responses from CoinGecko API.
layer/services/tokenPrice.ts Refactored getAssetMicroserviceEndpoint function to remove redundant URL constants and simplify logic.
layer/store/wallet.ts Added session to WalletStoreState, updated initialStateFactory, and modified useSharedWalletStore to handle session state.
layer/utils/constant/index.ts Added INJ_COIN_GECKO_ID constant.
layer/utils/constant/setup.ts Added VITE_WALLET_CONNECT_PROJECT_ID to env object, introduced asset price service URLs based on network, and added new constants for app configuration.
layer/utils/network.ts Added getBridgeUrl function to return different URLs based on IS_DEVNET value.
layer/wallet/wallet-strategy.ts Added metadata object to walletStrategy options with properties name, url, projectId, and description.

🐇
Amidst the code where data flows,
New services bloom, as logic grows.
Prices fetched with nimble grace,
Coins and charts in every place.
Constants set, and sessions stay,
A rabbit's work, now on display. 🌟

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

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

Out of diff range and nitpick comments (2)
layer/services/assetPrice/assetService/types.ts (1)

1-1: Consider enabling specific ESLint rules instead of disabling globally.

layer/services/assetPrice/types.ts (1)

1-1: Consider enabling specific ESLint rules instead of disabling globally.

@@ -64,6 +64,9 @@ if (endpointsNotProvided) {
)
}

// asset price service
export const ASSET_PRICE_SERVICE_URL = "https://k8s.mainnet.asset.injective.network/asset-price/v1";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The ASSET_PRICE_SERVICE_URL does not appear to point to an active service endpoint, as indicated by the HTTP 404 response. This needs to be addressed to ensure the URL is correct and the service is accessible:

  • Verify the correctness of the URL.
  • Check if the service is currently operational or if there are any issues with its deployment.
Analysis chain

Ensure the ASSET_PRICE_SERVICE_URL is secure and correctly points to the intended service endpoint.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the accessibility and security of the ASSET_PRICE_SERVICE_URL.

# Test: Attempt to fetch the endpoint using curl. Expect: Successful HTTP response.
curl -I ${ASSET_PRICE_SERVICE_URL}

Length of output: 97



Script:

#!/bin/bash
# Description: Verify the accessibility and security of the ASSET_PRICE_SERVICE_URL.

# Test: Attempt to fetch the endpoint using curl with the actual URL. Expect: Successful HTTP response.
curl -I "https://k8s.mainnet.asset.injective.network/asset-price/v1"

Length of output: 553

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between deef3e1 and 40dba59.
Files selected for processing (12)
  • layer/Service.ts (3 hunks)
  • layer/services/assetPrice/CoinGeckoApi.ts (1 hunks)
  • layer/services/assetPrice/assetService/index.ts (1 hunks)
  • layer/services/assetPrice/assetService/types.ts (1 hunks)
  • layer/services/assetPrice/index.ts (1 hunks)
  • layer/services/assetPrice/types.ts (1 hunks)
  • layer/services/tokenPrice.ts (1 hunks)
  • layer/store/wallet.ts (18 hunks)
  • layer/utils/constant/index.ts (1 hunks)
  • layer/utils/constant/setup.ts (3 hunks)
  • layer/utils/network.ts (1 hunks)
  • layer/wallet/wallet-strategy.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • layer/services/assetPrice/index.ts
  • layer/utils/constant/index.ts
Additional comments not posted (9)
layer/services/assetPrice/assetService/types.ts (1)

1-27: Interface definition aligns with external API structure.

layer/wallet/wallet-strategy.ts (1)

18-24: Enhanced wallet strategy configuration with metadata.

layer/services/assetPrice/types.ts (1)

1-35: Interfaces correctly model the CoinGecko API responses.

layer/services/tokenPrice.ts (1)

Line range hint 8-134: Well-structured class with appropriate error handling and use of async-await.

layer/services/assetPrice/assetService/index.ts (1)

11-134: Well-structured class with appropriate error handling and use of async-await.

layer/Service.ts (1)

130-132: Correct instantiation of InjectiveAssetService enhances service configuration.

layer/utils/constant/setup.ts (1)

Line range hint 24-87: Well-defined constants and utility functions for network and environment configurations.

layer/services/assetPrice/CoinGeckoApi.ts (1)

10-209: Well-structured class with appropriate error handling and use of async-await.

layer/store/wallet.ts (1)

36-36: Ensure the session field is securely handled and correctly integrated across wallet connection functions.

Also applies to: 53-53, 70-70, 256-256, 262-263, 276-276, 282-283, 296-296, 304-305, 323-323, 329-330, 342-342, 348-349, 362-362, 368-369, 382-382, 388-389, 402-402, 408-409, 421-421, 427-428, 441-441, 447-448, 461-461, 467-468, 481-481, 487-488, 501-501, 507-508, 521-521, 527-528, 541-541, 547-548

Verification successful

The session field is consistently used across various wallet connection functions in layer/store/wallet.ts. The integration appears to be thorough, with multiple instances of session handling through walletStrategy.getSessionOrConfirm.

  • session field is defined and initialized.
  • session is checked in state conditions.
  • session is retrieved and assigned multiple times using walletStrategy.getSessionOrConfirm.

This indicates that the session field is correctly integrated into the state management logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the secure handling and correct integration of the `session` field in wallet connection functions.

# Test: Check for consistent usage of the `session` field across all wallet connection functions.
rg --type python 'session' layer/store/wallet.ts

Length of output: 79



Script:

#!/bin/bash
# Description: Verify the secure handling and correct integration of the `session` field in wallet connection functions.

# Test: Check for consistent usage of the `session` field across all wallet connection functions.
rg --type typescript 'session' layer/store/wallet.ts

Length of output: 87



Script:

#!/bin/bash
# Description: Verify the secure handling and correct integration of the `session` field in wallet connection functions.

# Test: Check for consistent usage of the `session` field across all wallet connection functions.
rg --type ts 'session' layer/store/wallet.ts

Length of output: 1454

Comment on lines +40 to +46
export const getBridgeUrl = (): string => {
if (IS_DEVNET) {
return 'https://devnet.bridge.injective.dev'
}

return 'https://bridge.injective.network'
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The search results indicate that there are additional network conditions (IS_TESTNET and IS_MAINNET) defined in the codebase. The getBridgeUrl function currently only handles IS_DEVNET and the default case. To ensure completeness, the function should also handle IS_TESTNET and IS_MAINNET conditions if applicable.

  • layer/utils/network.ts contains references to IS_TESTNET.
  • layer/utils/constant/setup.ts defines IS_TESTNET and IS_MAINNET.

Please update the getBridgeUrl function to handle these additional network conditions if they are relevant.

Analysis chain

Ensure the URLs in getBridgeUrl are correct for each network condition.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of URLs returned by `getBridgeUrl`.

# Test: Check if the URLs are reachable and correct.
curl -I https://devnet.bridge.injective.dev
curl -I https://bridge.injective.network

Length of output: 1692



Script:

#!/bin/bash
# Search for network-related constants or conditions in the codebase to ensure completeness of `getBridgeUrl`.

# Find all occurrences of network-related constants or conditions.
rg 'IS_DEVNET|IS_TESTNET|IS_MAINNET|IS_STAGING' --type js --type ts

Length of output: 2336

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 40dba59 and fea5e56.
Files selected for processing (1)
  • layer/services/tokenPrice.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • layer/services/tokenPrice.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 fea5e56 and 2e44a78.
Files selected for processing (2)
  • layer/Service.ts (2 hunks)
  • layer/services/assetPrice/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • layer/Service.ts
  • layer/services/assetPrice/index.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: 1

Outside diff range and nitpick comments (3)
layer/services/tokenPrice.ts (2)

Line range hint 54-54: Consider replacing the spread syntax in reducers with more efficient methods to avoid performance issues.

- prices = { ...prices, [chunk[i]]: price }
+ prices[chunk[i]] = price

Also applies to: 76-76, 82-82, 104-104, 174-174


Line range hint 155-155: Change let to const for variable prices as it is only assigned once.

- let prices = {} as Record<string, number>
+ const prices = {} as Record<string, number>
layer/utils/constant/setup.ts (1)

Line range hint 49-49: Replace parseInt with Number.parseInt for better clarity and to avoid using the global scope.

- parseInt(import.meta.env.VITE_ETHEREUM_CHAIN_ID as string)
+ Number.parseInt(import.meta.env.VITE_ETHEREUM_CHAIN_ID as string)

Also applies to: 50-50

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2e44a78 and 1920207.
Files selected for processing (7)
  • layer/Service.ts (2 hunks)
  • layer/services/CoinGeckoApi.ts (1 hunks)
  • layer/services/tokenPrice.ts (3 hunks)
  • layer/types/coinGecko.ts (1 hunks)
  • layer/types/index.ts (1 hunks)
  • layer/utils/constant/index.ts (1 hunks)
  • layer/utils/constant/setup.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • layer/Service.ts
  • layer/utils/constant/index.ts
Additional Context Used
Biome (24)
layer/services/CoinGeckoApi.ts (16)

18-18: Unexpected any. Specify a different type.


32-32: Unexpected any. Specify a different type.


56-56: Unexpected any. Specify a different type.


62-62: Unexpected any. Specify a different type.


81-81: Unexpected any. Specify a different type.


87-87: Unexpected any. Specify a different type.


111-111: Unexpected any. Specify a different type.


117-117: Unexpected any. Specify a different type.


141-141: Unexpected any. Specify a different type.


145-145: Unexpected any. Specify a different type.


162-162: Unexpected any. Specify a different type.


166-166: Unexpected any. Specify a different type.


184-184: Unexpected any. Specify a different type.


188-188: Unexpected any. Specify a different type.


206-206: Unexpected any. Specify a different type.


2-8: All these imports are only used as types.

layer/services/tokenPrice.ts (6)

54-54: Avoid the use of spread (...) syntax on accumulators.


76-76: Avoid the use of spread (...) syntax on accumulators.


82-82: Avoid the use of spread (...) syntax on accumulators.


104-104: Avoid the use of spread (...) syntax on accumulators.


155-155: This let declares a variable that is only assigned once.


174-174: Avoid the use of spread (...) syntax on accumulators.

layer/utils/constant/setup.ts (2)

49-49: Use Number.parseInt instead of the equivalent global.


50-50: Use Number.parseInt instead of the equivalent global.

Additional comments not posted (3)
layer/types/index.ts (1)

7-7: Export addition of coinGecko aligns with new CoinGeckoApi functionalities.

layer/types/coinGecko.ts (1)

1-53: Interface definitions for CoinGecko API responses are correctly implemented.

layer/services/CoinGeckoApi.ts (1)

2-8: Imports are only used as types, which is appropriate and does not affect runtime.

constructor({ apiKey, baseUrl }: { apiKey: string; baseUrl: string }) {
const headers = {
'Content-Type': 'application/json'
} as any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace any with more specific types to enhance type safety and maintainability.

- headers: any
+ headers: Record<string, string>

Also applies to: 32-32, 56-56, 62-62, 81-81, 87-87, 111-111, 117-117, 141-141, 145-145, 162-162, 166-166, 184-184, 188-188, 206-206


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
} as any
} as Record<string, string>

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 1920207 and 6fdfa5c.
Files selected for processing (1)
  • layer/Service.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • layer/Service.ts

@ThomasRalee ThomasRalee merged commit e529900 into master May 24, 2024
2 checks passed
@ThomasRalee ThomasRalee deleted the chore/hub-updates branch May 24, 2024 13:24
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.

None yet

2 participants