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

feat(synapse-interface): use origin user address for getting bridge quotes #2969

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Aug 5, 2024

Description
A clear and concise description of the features you're adding in this pull request.

Additional context
Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • New Features

    • Enhanced state management in the bridge component by integrating user-specific information, improving user context in operations.
    • Updated gas estimation functionalities to consider user addresses, allowing for more personalized and accurate gas limit calculations.
  • Bug Fixes

    • Ensured that the functionality for estimating bridge gas limits operates correctly with the user's address, enhancing reliability.

fd8c3bf: synapse-interface preview link
b5a648e: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

This update enhances the functionality of the StateManagedBridge component and associated gas estimation methods by incorporating user-specific information. Key functions now accept parameters like originUserAddress and userAddress, allowing for more personalized interactions in the bridging process and gas estimations. These changes aim to improve the overall user context and interactivity within the application.

Changes

File Change Summary
.../state-managed-bridge/index.tsx Added originUserAddress as a parameter to enhance user-specific processing in StateManagedBridge.
.../utils/hooks/useGasEstimator.ts Updated getBridgeQuote and queryEstimatedBridgeGasLimit to accept user address parameters for better gas estimations.

Poem

🐇 In the realm of bridges, where users play,
A sprinkle of context brightens the way.
With addresses in hand, we hop and we cheer,
Enhancing our journey, bringing users near!
So leap with delight, for this change is sweet,
A bridge for all bunnies, now more complete! 🌟


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

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The changes focus on adding the originUserAddress parameter to the synapseSDK.allBridgeQuotes function call to improve the accuracy of bridge quotes by considering the user's address.

  • File: packages/synapse-interface/pages/state-managed-bridge/index.tsx
    • Added originUserAddress parameter to synapseSDK.allBridgeQuotes function call.
  • File: packages/synapse-interface/utils/hooks/useGasEstimator.ts
    • Added userAddress parameter to getBridgeQuote function and updated function calls accordingly.

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

cloudflare-workers-and-pages bot commented Aug 5, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: f3ae14a
Status: ✅  Deploy successful!
Preview URL: https://1195fdc1.sanguine-fe.pages.dev
Branch Preview URL: https://feat-fe-bridge-quote-origin.sanguine-fe.pages.dev

View logs

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 (2)
packages/synapse-interface/utils/hooks/useGasEstimator.ts (1)

154-166: Function calls to getBridgeQuote do not match the new signature

The function getBridgeQuote now requires an additional userAddress parameter. However, the current calls to this function do not include this new parameter.

  • File: packages/synapse-interface/utils/hooks/useGasEstimator.ts
    • Line: 154
    • Current Call:
      const bridgeQuote = await getBridgeQuote(
        synapseSDK,
        fromChainId,
        toChainId,
        fromToken,
        toToken,
      );
    • Expected Call:
      const bridgeQuote = await getBridgeQuote(
        synapseSDK,
        fromChainId,
        toChainId,
        fromToken,
        toToken,
        amount,
        userAddress,
      );

Please update the function calls to include the userAddress parameter.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

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

Scripts executed

The following scripts were executed for the analysis:

Script:

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

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

Length of output: 69


Script:

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

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

Length of output: 1437

packages/synapse-interface/pages/state-managed-bridge/index.tsx (1)

166-169: Function calls to getAndSetBridgeQuote need updating

The function getAndSetBridgeQuote is called without parameters in several places, which does not match the new signature that includes the originUserAddress parameter. Please update the following instances to include the required parameter:

  • packages/synapse-interface/pages/state-managed-bridge/index.tsx:
    • Line 1: getAndSetBridgeQuote()
    • Line 2: getAndSetBridgeQuote()
    • Line 3: getAndSetBridgeQuote()
    • Line 4: getAndSetBridgeQuote()
Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

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

Scripts executed

The following scripts were executed for the analysis:

Script:

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

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

Length of output: 75


Script:

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

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

Length of output: 2932

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6b4f1ed and ba8e1b4.

Files selected for processing (2)
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx (1 hunks)
  • packages/synapse-interface/utils/hooks/useGasEstimator.ts (2 hunks)
Additional comments not posted (1)
packages/synapse-interface/utils/hooks/useGasEstimator.ts (1)

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

The code changes are approved.

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

Verification successful

All function calls to queryEstimatedBridgeGasLimit match the new signature.

The function queryEstimatedBridgeGasLimit is only called within its own file, and all calls use the correct new signature.

  • packages/synapse-interface/utils/hooks/useGasEstimator.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

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

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

Length of output: 83


Script:

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

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

Length of output: 91


Script:

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

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

Length of output: 1060


Script:

#!/bin/bash
# Description: Verify all function calls to `queryEstimatedBridgeGasLimit` match the new signature across the entire codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg 'queryEstimatedBridgeGasLimit'

Length of output: 255

Copy link

codecov bot commented Aug 5, 2024

Bundle Report

Changes will increase total bundle size by 7.73MB ⬆️

Bundle name Size Change
sdk-router-@synapsecns/sdk-router-cjs 117.19kB 0 bytes
sdk-router-@synapsecns/sdk-router-esm 254.83kB 0 bytes
synapse-interface-client-array-push 7.46MB 7.46MB ⬆️
synapse-interface-server-cjs 1.38MB 48 bytes ⬆️
synapse-interface-edge-server-array-push 83 bytes 0 bytes
widget-cjs-esm 273.3kB 0 bytes
widget-esm-cjs 275.25kB 275.25kB ⬆️

Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.71254%. Comparing base (175e0cd) to head (f3ae14a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2969         +/-   ##
===================================================
- Coverage   25.71434%   25.71254%   -0.00180%     
===================================================
  Files            771         771                 
  Lines          55576       55576                 
  Branches          82          82                 
===================================================
- Hits           14291       14290          -1     
  Misses         39801       39801                 
- Partials        1484        1485          +1     
Flag Coverage Δ
packages 90.55118% <ø> (-0.09843%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChiTimesChi ChiTimesChi force-pushed the feat/fe-bridge-quote-origin-user-address branch from ba8e1b4 to f3ae14a Compare August 5, 2024 19:04
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This PR enhances the bridge quote functionality by incorporating the user's address in the useGasEstimator hook, improving the accuracy of gas limit calculations.

  • Updated getBridgeQuote function in useGasEstimator.ts to include userAddress parameter
  • Added originUserAddress option to synapseSDK.bridgeQuote call for personalized quotes
  • Refactored queryEstimatedBridgeGasLimit to pass user address to getBridgeQuote
  • Ensured consistency with changes made in state-managed-bridge/index.tsx

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ba8e1b4 and f3ae14a.

Files selected for processing (1)
  • packages/synapse-interface/utils/hooks/useGasEstimator.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/utils/hooks/useGasEstimator.ts

@ChiTimesChi ChiTimesChi merged commit 5e61cf3 into master Aug 6, 2024
20 checks passed
@ChiTimesChi ChiTimesChi deleted the feat/fe-bridge-quote-origin-user-address branch August 6, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants