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

Deposit/Withdraw fixes #3662

Merged
merged 4 commits into from
Aug 4, 2024
Merged

Deposit/Withdraw fixes #3662

merged 4 commits into from
Aug 4, 2024

Conversation

jonator
Copy link
Member

@jonator jonator commented Aug 3, 2024

What is the purpose of the change:

  • Change check for loading supported assets
  • getTimeoutHeight: avoid using destination address for finding chain by bech32prefix, as that could match with chains that share the same prefix and therefore the wrong chain could be used to get timeout height

Copy link

vercel bot commented Aug 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 3, 2024 7:24pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Aug 3, 2024 7:24pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Aug 3, 2024 7:24pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Aug 3, 2024 7:24pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Aug 3, 2024 7:24pm

@jonator jonator requested a review from a team August 3, 2024 14:00
Copy link
Contributor

coderabbitai bot commented Aug 3, 2024

Walkthrough

Recent updates enhance how the loading state of supported assets is determined in the useBridgesSupportedAssets function, broadening the criteria to include any asset that is either nil or loading. This adjustment improves asynchronous state management. Additionally, changes to the SkipBridgeProvider class strengthen error handling for various route availability messages, making the bridge functionality more robust.

Changes

Files Change Summary
packages/web/components/bridge/... Simplified loading state checks in useBridgesSupportedAssets to consider any asset that is nil or loading.
packages/bridge/src/skip/... Enhanced error handling in SkipBridgeProvider by adding checks for multiple error messages related to route availability.
packages/bridge/src/axelar/... Modified getTimeoutHeight method to use chainId instead of depositAddress for timeout height calculations.
packages/bridge/src/ibc/... Adjusted getTimeoutHeight to use chainId instead of params.toAddress.
packages/bridge/src/interface.ts Changed getTimeoutHeight parameter from destinationAddress to chainId, enhancing clarity in the interface.
packages/bridge/src/squid/... Updated createCosmosTransaction to include toChainId, improving transaction handling.
packages/server/src/queries/complex/... Adjusted getTimeoutHeight to require chainId and removed destinationAddress.
packages/utils/src/chain-utils.ts Added documentation warning about identical bech32 prefixes across different chains.
packages/web/server/api/routers/... Updated getTimeoutHeight to accept a params object for better flexibility in parameter handling.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant Component
    participant API

    User->>Component: Initiates loading of assets
    Component->>API: Request supported assets
    API-->>Component: Returns supportedAssetsResults
    alt If any asset is nil or loading
        Component->>User: Show loading state
    else
        Component->>User: Display loaded assets
    end
Loading
sequenceDiagram
    participant BridgeProvider
    participant ErrorHandler

    BridgeProvider->>ErrorHandler: Check message for route availability
    alt If message includes "no single-tx routes found" or "no routes found"
        ErrorHandler->>BridgeProvider: Throw BridgeQuoteError
    else
        ErrorHandler->>BridgeProvider: Continue processing
    end

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f7e77f8 and b62b7fb.

Files selected for processing (8)
  • packages/bridge/src/axelar/index.ts (1 hunks)
  • packages/bridge/src/ibc/index.ts (1 hunks)
  • packages/bridge/src/interface.ts (1 hunks)
  • packages/bridge/src/skip/index.ts (2 hunks)
  • packages/bridge/src/squid/index.ts (3 hunks)
  • packages/server/src/queries/complex/get-timeout-height.ts (1 hunks)
  • packages/utils/src/chain-utils.ts (1 hunks)
  • packages/web/server/api/routers/bridge-transfer.ts (4 hunks)
Files skipped from review due to trivial changes (1)
  • packages/utils/src/chain-utils.ts
Files skipped from review as they are similar to previous changes (1)
  • packages/bridge/src/skip/index.ts
Additional comments not posted (9)
packages/server/src/queries/complex/get-timeout-height.ts (1)

12-12: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to getTimeoutHeight match the new signature.

packages/bridge/src/ibc/index.ts (1)

149-149: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to getTimeoutHeight match the new signature.

Verification successful

Verification Successful: Function getTimeoutHeight Usage Matches New Signature

The function calls to getTimeoutHeight have been verified and they match the new signature across the codebase.

  • packages/web/server/api/routers/bridge-transfer.ts
  • packages/stores/src/account/base.ts
  • packages/server/src/queries/complex/get-timeout-height.ts
  • packages/bridge/src/interface.ts
  • packages/bridge/src/skip/__tests__/skip-bridge-provider.spec.ts
  • packages/bridge/src/squid/__tests__/squid-bridge-provider.spec.ts
  • packages/bridge/src/ibc/index.ts
  • packages/bridge/src/axelar/index.ts
  • packages/bridge/src/ibc/__tests__/ibc-bridge-provider.spec.ts
  • packages/bridge/src/axelar/__tests__/axelar-bridge-provider.spec.ts
  • packages/bridge/src/skip/index.ts
  • packages/bridge/src/squid/index.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getTimeoutHeight` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type js -A 5 $'getTimeoutHeight'

Length of output: 36


Script:

#!/bin/bash
# Description: Verify the definition and all usages of the `getTimeoutHeight` function in the codebase.

# Search for the definition of the `getTimeoutHeight` function
rg --type js -A 5 'function getTimeoutHeight'

# Search for the usage of the `getTimeoutHeight` function
rg --type js -A 5 'getTimeoutHeight('

Length of output: 172


Script:

#!/bin/bash
# Description: Verify the definition and all usages of the `getTimeoutHeight` function in the codebase.

# Search for the definition of the `getTimeoutHeight` function
rg --type js -A 5 'function getTimeoutHeight'

# Search for the usage of the `getTimeoutHeight` function
rg --type js -A 5 'getTimeoutHeight\('

Length of output: 88


Script:

#!/bin/bash
# Description: Verify the presence of the `getTimeoutHeight` function in the codebase.

# Search for any occurrences of the `getTimeoutHeight` function name
rg 'getTimeoutHeight'

Length of output: 2246


Script:

#!/bin/bash
# Description: Verify the function calls to `getTimeoutHeight` match the new signature by inspecting the context around the occurrences.

# Extract and display the context around the occurrences of `getTimeoutHeight`
rg 'getTimeoutHeight' -A 5 -B 5

Length of output: 17479

packages/web/server/api/routers/bridge-transfer.ts (4)

456-456: Verify the usage of the new parameter structure.

Ensure that the new params object passed to getTimeoutHeight correctly includes all necessary properties.

Verification successful

The new parameter structure is correctly handled.

The getTimeoutHeight function and its usages correctly include all necessary properties in the params object.

  • Function definition: packages/server/src/queries/complex/get-timeout-height.ts
  • Usages: packages/web/server/api/routers/bridge-transfer.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new parameter structure in the `getTimeoutHeight` function.

# Test: Search for the `getTimeoutHeight` function definition and usage. Expect: Correct handling of the new `params` object.
rg --type typescript -A 5 $'getTimeoutHeight'

Length of output: 79


Script:

#!/bin/bash
# Description: Verify the usage of the new parameter structure in the `getTimeoutHeight` function.

# Test: Search for the `getTimeoutHeight` function definition and usage. Expect: Correct handling of the new `params` object.
rg --type-add 'ts:*.ts' --type-add 'tsx:*.tsx' -t ts -t tsx -A 5 'getTimeoutHeight'

Length of output: 9942


497-497: Verify the usage of the new parameter structure.

Ensure that the new params object passed to getTimeoutHeight correctly includes all necessary properties.


81-81: Verify the usage of the new parameter structure.

Ensure that the new params object passed to getTimeoutHeight correctly includes all necessary properties.


332-332: Verify the usage of the new parameter structure.

Ensure that the new params object passed to getTimeoutHeight correctly includes all necessary properties.

packages/bridge/src/squid/index.ts (2)

498-498: Verify the usage of the new toChainId parameter.

Ensure that the new toChainId parameter is correctly handled and does not introduce any issues.

Verification successful

The toChainId parameter is correctly handled within the createCosmosTransaction method.

  • The toChainId parameter is used to retrieve the timeoutHeight by calling this.ctx.getTimeoutHeight with chainId: toChainId.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `toChainId` parameter in the `createCosmosTransaction` method.

# Test: Search for the `createCosmosTransaction` method definition and usage. Expect: Correct handling of the new `toChainId` parameter.
rg --type typescript -A 5 $'createCosmosTransaction'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the usage of the new `toChainId` parameter in the `createCosmosTransaction` method.

# Test: Search for the `createCosmosTransaction` method definition and usage. Expect: Correct handling of the new `toChainId` parameter.
rg --type ts -A 5 'createCosmosTransaction'

Length of output: 2968


Script:

#!/bin/bash
# Description: Verify the usage of the new `toChainId` parameter within the `createCosmosTransaction` method implementation.

# Test: Search for the usage of `toChainId` within the `createCosmosTransaction` method implementation in `packages/bridge/src/squid/index.ts`.
rg --type ts -A 20 'async createCosmosTransaction' packages/bridge/src/squid/index.ts

Length of output: 604


Script:

#!/bin/bash
# Description: Verify the usage of the new `toChainId` parameter within the `createCosmosTransaction` method implementation.

# Test: Search for the complete implementation of the `createCosmosTransaction` method in `packages/bridge/src/squid/index.ts`.
rg --type ts -A 50 'async createCosmosTransaction' packages/bridge/src/squid/index.ts

Length of output: 1488


274-274: Verify the usage of the new toChainId parameter.

Ensure that the new toChainId parameter is correctly handled and does not introduce any issues.

packages/bridge/src/axelar/index.ts (1)

571-571: Verify the usage of the new toChain.chainId.toString() parameter.

Ensure that the new toChain.chainId.toString() parameter is correctly handled and does not introduce any issues.

Verification successful

Verified the usage of the new toChain.chainId.toString() parameter.

The toChain.chainId.toString() parameter is correctly handled within the createCosmosTransaction method in packages/bridge/src/axelar/index.ts. There are no apparent issues with this usage.

  • packages/bridge/src/axelar/index.ts:
    • Line 571: chainId: toChain.chainId.toString(),
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `toChain.chainId.toString()` parameter in the `createCosmosTransaction` method.

# Test: Search for the `createCosmosTransaction` method definition and usage. Expect: Correct handling of the new `toChain.chainId.toString()` parameter.
rg --type typescript -A 5 $'createCosmosTransaction'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the usage of the new `toChain.chainId.toString()` parameter in the `createCosmosTransaction` method.

# Test: Search for the `createCosmosTransaction` method definition and usage. Expect: Correct handling of the new `toChain.chainId.toString()` parameter.
rg --type ts -A 5 $'createCosmosTransaction'

Length of output: 2968


Script:

#!/bin/bash
# Description: Verify the usage of the new `toChain.chainId.toString()` parameter in the `createCosmosTransaction` method within the `axelar` module.

# Test: Search for the usage of `toChain.chainId.toString()` within the `createCosmosTransaction` method in `packages/bridge/src/axelar/index.ts`.
rg --type ts -A 10 'toChain.chainId.toString()' packages/bridge/src/axelar/index.ts

Length of output: 398


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>.
    • 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.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

@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

Outside diff range, codebase verification and nitpick comments (1)
packages/bridge/src/interface.ts (1)

15-16: Ensure all getTimeoutHeight function calls match the new signature

The following instances need to be updated to match the new function signature that expects an object with a chainId property:

  • packages/stores/src/account/base.ts

    • Update the function call to pass an object:
      const timeoutHeight = await this.getTimeoutHeight({ chainId });
  • packages/server/src/queries/complex/get-timeout-height.ts

    • Update the function definition to accept an object:
      export async function getTimeoutHeight({
        chainList,
        chainId,
      }: {
        chainList: Chain[];
        chainId: string;
      }): Promise<bigint> {
        // function body
      }

Please make these changes to ensure consistency with the new function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to getTimeoutHeight match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getTimeoutHeight` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type ts -A 5 $'getTimeoutHeight'

Length of output: 9895


Script:

#!/bin/bash
# Description: Verify all function calls to `getTimeoutHeight` match the new signature.

# Check function calls in the identified files
rg --type ts 'getTimeoutHeight\(' -A 2 packages/web/server/api/routers/bridge-transfer.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/server/src/queries/complex/get-timeout-height.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/stores/src/account/base.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/skip/index.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/squid/index.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/squid/__tests__/squid-bridge-provider.spec.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/skip/__tests__/skip-bridge-provider.spec.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/ibc/index.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/axelar/index.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/axelar/__tests__/axelar-bridge-provider.spec.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/bridge/src/ibc/__tests__/ibc-bridge-provider.spec.ts

Length of output: 2195


Script:

#!/bin/bash
# Description: Verify all function calls to `getTimeoutHeight` match the new signature in specific files.

# Check function calls in the identified files
rg --type ts 'getTimeoutHeight\(' -A 2 packages/stores/src/account/base.ts
rg --type ts 'getTimeoutHeight\(' -A 2 packages/server/src/queries/complex/get-timeout-height.ts

Length of output: 516

@jonator jonator merged commit d57d4de into stage Aug 4, 2024
31 checks passed
@jonator jonator deleted the jonator/fixes branch August 4, 2024 22:10
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.

2 participants