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

Fix/inj tia new msg #1004

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Fix/inj tia new msg #1004

merged 3 commits into from
Oct 23, 2024

Conversation

haunv3
Copy link
Contributor

@haunv3 haunv3 commented Oct 23, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced token swapping logic with improved handling for Cosmos-based tokens.
    • Added support for broader swap scenarios without restrictions between Cosmos-based tokens.
  • Bug Fixes

    • Improved error handling for wallet address validation in specific networks.
  • Chores

    • Updated dependency version for @oraichain/oraidex-universal-swap to ensure compatibility and access to the latest features.

Copy link

coderabbitai bot commented Oct 23, 2024

Walkthrough

The pull request includes updates to the package.json file to change the version of the @oraichain/oraidex-universal-swap dependency from "1.1.14" to "1.1.15". Additionally, modifications to the useTokenFee.ts and helpers.ts files enhance the integration of the UniversalSwapHelper for handling swap simulations and network checks. These changes streamline the swap handling logic and refine the conditions for token swapping, particularly concerning Cosmos-based tokens.

Changes

File Change Summary
package.json Updated @oraichain/oraidex-universal-swap dependency version from "1.1.14" to "1.1.15".
src/hooks/useTokenFee.ts Integrated UniversalSwapHelper for swap simulations; updated function calls and logic for network checks.
src/pages/UniversalSwap/helpers.ts Enhanced token swapping logic; updated conditions for Cosmos-based token swaps and error handling.

Possibly related PRs

  • pumb version 1.1.12 fix swap 0x38 -> oraichain #985: The version of the @oraichain/oraidex-universal-swap dependency was updated from "1.1.10" to "1.1.12", which is directly related to the version update from "1.1.14" to "1.1.15" in the main PR.
  • Feat/osmosis oraidex #989: The version of the @oraichain/oraidex-universal-swap was incremented from "1.1.12" to "1.1.14", which is part of the same dependency update chain leading to the version change in the main PR.
  • pumb version sdk swap 1.1.4 fix swap with ledger #946: The version of the @oraichain/oraidex-universal-swap was updated from "1.1.3" to "1.1.4", indicating a similar type of change in the dependency versioning process.

Suggested reviewers

  • trung2891
  • quangdz1704

🐰 In the garden where swaps take flight,
A version change brings new delight.
With helpers strong and logic clear,
We hop along without a fear.
Cosmos tokens dance and play,
In this new world, we find our way! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

sonarcloud bot commented Oct 23, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

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 (1)
src/hooks/useTokenFee.ts (1)

Line range hint 149-158: Add simulateOption parameter to getRouterConfig call.

The getRouterConfig function signature was updated to accept simulateOption, but it's called without parameters here. This might cause undefined behavior.

-        routerConfig: getRouterConfig()
+        routerConfig: getRouterConfig({ useIbcWasm: true })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 59e4c32 and 10afbdb.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/hooks/useTokenFee.ts (5 hunks)
  • src/pages/UniversalSwap/helpers.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (6)
package.json (1)

27-27: Verify the dependency update and its implications.

The version update of @oraichain/oraidex-universal-swap from 1.1.14 to 1.1.15 appears to be related to fixing Injective/TIA message handling.

Let's verify the package version and changes:

Also, please ensure that the corresponding lock file (package-lock.json or yarn.lock) is updated to reflect this change.

src/hooks/useTokenFee.ts (4)

16-16: LGTM! Import changes look good.

The consolidation of helper functions under UniversalSwapHelper improves code organization and maintainability.

Also applies to: 21-21


71-73: LGTM! Well-structured simulation options.

The changes properly integrate:

  • Protocol selection based on token types
  • Conditional IBC WASM settings
  • Router configuration with appropriate options

Also applies to: 82-97


74-81: Verify the impact of setting ignoreFee to true.

The simulateOption includes ignoreFee: true which might affect fee calculations. Please verify if this is intentional and doesn't impact the relayer fee calculations.

#!/bin/bash
# Search for other instances of ignoreFee usage
rg "ignoreFee" --type ts

42-42: Verify the EVM network check behavior remains unchanged.

The migration to UniversalSwapHelper.isEvmNetworkNativeSwapSupported looks correct, but let's verify it maintains the same behavior.

✅ Verification successful

Let me generate additional scripts to verify the behavior by searching for both the old and new implementations.

Let's also check the previous implementation in the git history:

This will help us compare the old and new implementations to verify the behavior remains unchanged.


Based on the results, I can now generate the final response as we have sufficient evidence from the git history and codebase search.

The EVM network check behavior remains unchanged

The migration simply moves the isEvmNetworkNativeSwapSupported function from being a direct import to being accessed through the UniversalSwapHelper class. The git history shows the exact replacement:

  • Old: isEvmNetworkNativeSwapSupported(fromChainId)
  • New: UniversalSwapHelper.isEvmNetworkNativeSwapSupported(fromChainId)

The function is used consistently across the codebase in similar contexts (useLoadTokens.ts, UniversalSwap/helpers.ts) for the same purpose - checking EVM network native swap support. The condition and its usage context remain identical, only the access method has changed as part of the refactoring.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for previous implementations to compare behavior
rg -A 3 "isEvmNetworkNativeSwapSupported" --type ts

Length of output: 485


Script:

#!/bin/bash
# Search for UniversalSwapHelper class and its implementation
ast-grep --pattern 'class UniversalSwapHelper {
  $$$
  isEvmNetworkNativeSwapSupported($_) {
    $$$
  }
  $$$
}'

# Search for any other similar EVM network check implementations
rg "isEvmNetwork.*Supported" --type ts -A 3

Length of output: 2152


Script:

#!/bin/bash
# Check git history for the specific line
git log -p src/hooks/useTokenFee.ts | grep -A 5 -B 5 "isEvmNetwork.*Supported"

Length of output: 3410

src/pages/UniversalSwap/helpers.ts (1)

395-396: ⚠️ Potential issue

Verify the conflicting swap logic for Cosmos-based tokens

In the isAllowAlphaIbcWasm function, when both fromToken and toToken are Cosmos-based, the function returns true, allowing swaps between Cosmos tokens:

// cosmos -> cosmos
if (toToken.cosmosBased && fromToken.cosmosBased) return true;

However, in the isAllowIBCWasm function, when both fromToken and toToken are Cosmos-based, the function returns false, preventing swaps between Cosmos tokens:

// cosmos -> cosmos
if (fromTokenIsCosmos && toTokenIsCosmos) return false;

Please verify if this discrepancy is intentional to ensure consistent swap behavior across the application.

src/pages/UniversalSwap/helpers.ts Show resolved Hide resolved
@haunv3 haunv3 merged commit 61d2606 into main Oct 23, 2024
4 of 5 checks passed
@haunv3 haunv3 deleted the fix/inj-tia-new-msg branch October 23, 2024 09:18
@coderabbitai coderabbitai bot mentioned this pull request Oct 24, 2024
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