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): bridge gas handler #2437

Merged
merged 151 commits into from
May 9, 2024
Merged

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Apr 3, 2024

  • Estimate bridge fee based on queried gas data per chain
  • Calculate max bridgeable gas token amount when clicking on "Max" button in Bridge card

Summary by CodeRabbit

  • New Features
    • Enhanced gas estimation functionality for smoother transaction experiences.
    • Improved balance calculations and display across components for better usability.
    • Updated token balance formatting and parsing for clearer information presentation.
    • Introduced customizable amount display options in the formatAmount function.
    • Enhanced balance parsing accuracy in the getParsedBalance function.
    • Improved error handling in trimTrailingZeroesAfterDecimal function with a null check.

c5c5373907e264c51e5ecff483109e7fd51bd0ee: synapse-interface preview link
9f821054c2a0e7de9cf3a8018d4876fb16de1a17: synapse-interface preview link
e15a75b265652178ea1afe3aaead255335167ee5: synapse-interface preview link
d70382f7691d259f8446daa81d3583b4f47583a1: synapse-interface preview link
540b2de71e0b02b041801932a22c79b690d4d476: synapse-interface preview link
b35a29219d02cf93fb9c05bd2839b9b5861e3d7f: synapse-interface preview link
4a9de4f38e5459746e2fb787f98aeb796d126b76: synapse-interface preview link
e1c2c88b6e5f3d6647f2c1156b45055420eab1be: synapse-interface preview link
7a2118a12b6099f95dcb127f3c2fc5def33a0fac: synapse-interface preview link
5ff6b401985f7caeeceb4d036174534cac082e65: synapse-interface preview link
e525c4b05d22186d77dc130d8015e9146562bac8: synapse-interface preview link
e8ac51e0ee53fe65aab3ad9474a0182c9869e7aa: synapse-interface preview link
f0ca424b903daccbdc604e1fd6ff97821b0602c0: synapse-interface preview link
3529e569eaa5f14f9d4cda93919ffe22e590d400: synapse-interface preview link
77bd85c69cc045b2785ed6232ae845b7f7ad385b: synapse-interface preview link
c1c223e0cf469131845b8800d80ca532fb3830ff: synapse-interface preview link
32cdb869a4da652a05d3c3848d091af5a65b5db8: synapse-interface preview link
359fcd40dbd66f0eb26f5fa74c3fa93954ee23a1: synapse-interface preview link
f15a03bc5fed35297b8fe227ec2beae18327624a: synapse-interface preview link
18324c503edec53ecddc805b0ae9e7f6d4b3e4df: synapse-interface preview link
ee098e8e637f8b50451e9e47418f5e8e231ce253: synapse-interface preview link
57c4effb1616d367365827f4013b505febfbfdfb: synapse-interface preview link
88493736622554ee99af4bd3e9ff1e0bd23e47d6: synapse-interface preview link
6bf3367ba39de2dfa0580400ec48c478e45f97fd: synapse-interface preview link
a96bb5b3b0e17d15aee19cf7ffd378f7cc16c185: synapse-interface preview link
22c835a8d91162756f8cd884291984bd8475410e: synapse-interface preview link
037d9a5631a1a823ee97602cd1837aa13c432203: synapse-interface preview link
0d3470d3450319576ccfea633cca0f6e79c4dff6: synapse-interface preview link
a5f2718ef09db9b802b2cbc8bc19575ad0e6ff8b: synapse-interface preview link
ca0129536980f8a2ee145967c70127b3123b9366: synapse-interface preview link
c107d0e7fda8fe6b532a6dffb4507fe5f3d8b58b: synapse-interface preview link
954b9b2315b9e4df95d3f975e7b16187bafb6ae1: synapse-interface preview link
664539d425245479d7c8dc3c6aa9c6af28beef58: synapse-interface preview link
f3fb5aa3747a7818a04b312198b0740092458c75: synapse-interface preview link
88c7effe6f5c28c90f0773fd8385c746cdb832de: synapse-interface preview link
46877df0a6677878e0d8ccd84f16054e0de99f42: synapse-interface preview link
289b13a71ef27a1d59b18d725db0d25191f527a1: synapse-interface preview link
2e5413271f163e103564798ad732381478c92326: synapse-interface preview link
58932a671bf84d1edcb960a578671a32c173b718: synapse-interface preview link
0443afbd049ff1d324f3f228b15d372da78bd1d2: synapse-interface preview link
ab309b742d5c8eda1efa2f3b97a217b14816a4b1: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Apr 3, 2024

Walkthrough

The recent changes encompass improvements across various components in the synapse-interface package, introducing new functions, adjusting imports, refining balance calculations, and enhancing user interaction with gas-related functionality.

Changes

File Path Summary
.../PortfolioTokenAsset.tsx
.../StateManagedBridge/InputContainer.tsx
Import modifications, addition of useGasEstimator hook, and balance calculation adjustments.
.../StateManagedSwap/SwapInputContainer.tsx Introduces new imports for formatting functions, updates JSX structure, and revises balance handling logic.
.../SelectSpecificTokenButton.tsx Updates balance display using getParsedBalance and formatAmount functions.
.../utils/formatAmount.ts Enhances formatAmount function with customizable formatting options.
.../utils/getParsedBalance.ts Refines balance parsing using trimTrailingZeroesAfterDecimal.
.../utils/trimTrailingZeroesAfterDecimal.ts Adds null check for input parameter in trimTrailingZeroesAfterDecimal function.

Poem

🐰🌟
In the realm where code does weave,
New functions bloom, balances perceive.
Gas estimations, bridges span,
Tokens dance at a rabbit's plan.
Bytes and bits in harmony align,
In the digital meadows, changes refine.
🌟🐰


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.

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

cloudflare-workers-and-pages bot commented Apr 3, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0cbe497
Status: ✅  Deploy successful!
Preview URL: https://b315b7e5.sanguine-fe.pages.dev
Branch Preview URL: https://fe-bridge-gas.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.03296%. Comparing base (f1f61b0) to head (0cbe497).
Report is 2 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2437         +/-   ##
===================================================
+ Coverage   39.93190%   47.03296%   +7.10106%     
===================================================
  Files            183         384        +201     
  Lines          14685       29339      +14654     
  Branches          80          80                 
===================================================
+ Hits            5864       13799       +7935     
- Misses          8062       14089       +6027     
- Partials         759        1451        +692     
Flag Coverage Δ
packages 90.38652% <ø> (ø)
promexporter ?

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.

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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 1ad45a3 and 6d12c41.
Files selected for processing (6)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (5 hunks)
  • packages/synapse-interface/contexts/BackgroundListenerProvider.tsx (2 hunks)
  • packages/synapse-interface/slices/gasDataSlice.ts (1 hunks)
  • packages/synapse-interface/store/reducer.ts (2 hunks)
  • packages/synapse-interface/utils/calculateGasFeeInGwei.ts (1 hunks)
  • packages/synapse-interface/utils/hooks/useFetchGasDataOnInterval.ts (1 hunks)
Additional Context Used
GitHub Check Runs (1)
lint failure (4)

packages/synapse-interface/utils/calculateGasFeeInGwei.ts: [failure] 5-5:
There must be a newline after the description of the JSDoc block

Additional comments not posted (2)
packages/synapse-interface/contexts/BackgroundListenerProvider.tsx (1)

22-22: LGTM! The integration of useFetchGasDataOnInterval within BackgroundListenerProvider ensures that gas data is fetched at regular intervals, enhancing the application's functionality.

packages/synapse-interface/store/reducer.ts (1)

47-47: LGTM! Adding the gasData slice to the main reducer is correctly implemented and enables centralized management of gas data within the application's state.

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 Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 6d12c41 and 9758112.
Files selected for processing (1)
  • packages/synapse-interface/utils/calculateGasFeeInGwei.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/utils/calculateGasFeeInGwei.ts

Copy link

cloudflare-workers-and-pages bot commented Apr 3, 2024

Deploying sanguine with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0cbe497
Status: ✅  Deploy successful!
Preview URL: https://b37f9952.sanguine.pages.dev
Branch Preview URL: https://fe-bridge-gas.sanguine.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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 9758112 and c01109f.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (6 hunks)
  • packages/synapse-interface/utils/hooks/useFetchGasDataOnInterval.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx
  • packages/synapse-interface/utils/hooks/useFetchGasDataOnInterval.ts

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 cc9f96d and bc5eca7.
Files selected for processing (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
Additional comments not posted (7)
packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (7)

1-1: Ensure lodash imports are used efficiently.


29-29: The import of MiniMaxButton is redundant as it is not used in the file.


31-31: Ensure the new import of useGasEstimator is utilized effectively in the component logic.

Verification successful

The verification process has confirmed that the useGasEstimator hook is indeed imported and utilized within the InputContainer.tsx file. The hook is not only imported but also invoked, as indicated by the script output showing the destructuring assignment from the hook's return value. This aligns with the initial review comment's concern about ensuring the hook's effective use in the component logic.

Effective usage of useGasEstimator in InputContainer.tsx confirmed.

  • The hook is both imported and used within the component, which satisfies the requirement of the review comment.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `useGasEstimator` hook in the file.

# Test: Search for the hook usage. Expect: At least one occurrence of the hook being used effectively.
rg --type typescript $'useGasEstimator' packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx

Length of output: 149



Script:

#!/bin/bash
# Description: Verify the usage of `useGasEstimator` hook in the file.

# Test: Search for the hook usage. Expect: At least one occurrence of the hook being used effectively.
rg 'useGasEstimator' packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx

Length of output: 188


46-46: Validate the handling of decimals to ensure it correctly supports both single values and mappings by chain ID.

Verification successful

The attempt to verify the handling of the decimals variable in the InputContainer.tsx file was unsuccessful due to a technical issue with the rg command, which did not recognize the file type 'typescript'. This prevented the script from executing properly and retrieving the necessary information to confirm whether the code correctly handles decimals as both single values and mappings by chain ID.

To resolve this and properly verify the handling of decimals, I will adjust the script to correctly search within TypeScript files.


The revised script successfully retrieved the relevant lines of code from InputContainer.tsx that handle the decimals variable. The output shows two lines:

  1. const { addresses, decimals } = fromToken || {}
  2. const tokenDecimals = isNumber(decimals) ? decimals : decimals?.[fromChainId]

From this output, it is evident that the code is designed to handle decimals both as a single numeric value and as an object mapping by chain ID. The conditional check isNumber(decimals) ? decimals : decimals?.[fromChainId] ensures that if decimals is a number, it is used directly; otherwise, it attempts to access a property using fromChainId, which implies handling of an object map.

This confirms that the handling of decimals in the InputContainer.tsx file supports both single values and mappings by chain ID as intended. Therefore, the original review comment has been verified as accurate.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of `decimals` for different scenarios.

# Test: Search for the usage of `decimals` in conditional checks. Expect: Proper checks for both single values and mappings.
rg --type typescript $'decimals' packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx

Length of output: 142



Script:

#!/bin/bash
# Description: Re-verify the handling of `decimals` for different scenarios.

# Adjusting the command to correctly handle TypeScript files.
rg 'decimals' packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx --type-add 'typescript:*.ts,*.tsx' --type typescript

Length of output: 272


66-90: Refactor onMaxBalance for better error handling and readability.


96-104: Refactor the connectedStatus calculation for better readability.


162-163: Ensure the logic for disabling the MiniMaxButton is correct and concise.

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

Out of diff range and nitpick comments (1)
packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (1)

Line range hint 38-169: Consider refactoring InputContainer to improve readability and maintainability. The component handles multiple responsibilities, which could be separated into smaller components or custom hooks.

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between bc5eca7 and 429a023.
Files selected for processing (5)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
Additional comments not posted (1)
packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx (1)

4-16: The implementation of MaxButton using dynamic class names and conditional rendering based on isHidden looks good.

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

Out of diff range and nitpick comments (2)
packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (2)

162-162: Clarify the disabling logic for AvailableBalance to ensure it's intuitive and correct.

Consider adding a comment explaining the conditions under which AvailableBalance is disabled for better maintainability.


166-166: Ensure the visibility logic for MaxButton is correct and intuitive.

Consider adding a comment explaining the conditions under which MaxButton is hidden for better maintainability.

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 429a023 and 1d36a72.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
Additional comments not posted (5)
packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (5)

1-1: Ensure lodash imports are used efficiently.


29-29: The import of MiniMaxButton is redundant as it is not used in the file.


47-47: Validate the handling of decimals when it's not a number.

Verification successful

The search results from the corrected script provide extensive usage of the decimals variable across various files in the codebase. The handling of decimals when it's not a number is consistently checked with conditions that handle both numeric and object types, where decimals could be a mapping of chain IDs to decimal values.

In the specific context of the InputContainer.tsx file, the line:

const tokenDecimals = isNumber(decimals) ? decimals : decimals?.[fromChainId]

is a valid and safe way to handle decimals when it's not a number. This pattern of checking whether decimals is a number or an object (possibly undefined) and then appropriately accessing the value is mirrored in other parts of the codebase as well.

Given this consistent handling and the specific implementation in InputContainer.tsx, the handling of decimals when it's not a number is verified to be correct and consistent with the broader codebase practices.

  • File: packages/synapse-interface/utils/hooks/useGasEstimator.ts
    • Line: Exact line number where similar handling is implemented.
  • File: packages/synapse-interface/pages/state-managed-bridge/index.tsx
    • Line: Similar usage pattern observed.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of non-numeric `decimals` in other parts of the codebase.

# Test: Search for usage of `decimals` and check for numeric checks.
rg --type tsx --type ts $'decimals'

Length of output: 62



Script:

#!/bin/bash
# Description: Re-verify the handling of non-numeric `decimals` in the codebase.

# Corrected Test: Search for usage of `decimals` and check for numeric checks.
rg --type-add 'tsx:*.{tsx,ts}' --type 'tsx' 'decimals'

Length of output: 123183


71-95: Refactor onMaxBalance for better error handling and readability.


101-109: Refactor the connectedStatus calculation for better readability.

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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1d36a72 and a350cf9.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx

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

Out of diff range and nitpick comments (1)
packages/synapse-interface/components/Portfolio/components/SearchBar.tsx (1)

67-67: Ensure consistent conditional rendering syntax for clarity.

Consider using a consistent approach for conditional rendering to improve readability. For example, using ternary operators consistently or separating conditions into well-named variables can make the code easier to understand.

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between a350cf9 and 744c42e.
Files selected for processing (8)
  • packages/synapse-interface/components/Portfolio/components/PortfolioAssetActionButton.tsx (1 hunks)
  • packages/synapse-interface/components/Portfolio/components/SearchBar.tsx (1 hunks)
  • packages/synapse-interface/components/Portfolio/components/ViewSearchAddressBanner.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/BridgeWarnings.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (5 hunks)
Files skipped from review due to trivial changes (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioAssetActionButton.tsx
  • packages/synapse-interface/components/Portfolio/components/ViewSearchAddressBanner.tsx
  • packages/synapse-interface/components/StateManagedBridge/BridgeWarnings.tsx
Files skipped from review as they are similar to previous changes (3)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
Additional comments not posted (1)
packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (1)

30-30: Ensure consistent use of import paths.

Consider using absolute paths (e.g., '@/utils/hooks/useGasEstimator') for consistency and to avoid potential issues during refactoring.

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 744c42e and 11f31ee.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx

* formatAmount util function, use rounded shortened values in Bridge/Swap Input

* Update Bridge/Swap page with parsed / formatted balances

* Clean imports
@github-actions github-actions bot added size/l and removed size/m labels May 8, 2024
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: 1

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 11f31ee and f274044.
Files selected for processing (7)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (5 hunks)
  • packages/synapse-interface/components/ui/SelectSpecificTokenButton.tsx (3 hunks)
  • packages/synapse-interface/utils/formatAmount.ts (1 hunks)
  • packages/synapse-interface/utils/getParsedBalance.ts (1 hunks)
  • packages/synapse-interface/utils/trimTrailingZeroesAfterDecimal.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
  • packages/synapse-interface/utils/trimTrailingZeroesAfterDecimal.ts
Additional comments not posted (3)
packages/synapse-interface/utils/getParsedBalance.ts (1)

1-11: The implementation of getParsedBalance function looks correct and efficient.

packages/synapse-interface/components/ui/SelectSpecificTokenButton.tsx (1)

Line range hint 13-100: The implementation of SelectSpecificTokenButton and its sub-components is correct and follows best practices for React components.

packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (1)

73-97: Ensure that the onMaxBalance function handles all edge cases correctly, especially with asynchronous operations and state updates.

Verification successful

The onMaxBalance function is indeed present in the InputContainer.tsx file as described in the review comment. The function is defined as an asynchronous callback and is used in an onClick event, which aligns with the expected behavior for handling asynchronous operations and state updates within a React component. Additionally, the function is also present in another component (SwapInputContainer.tsx), suggesting a pattern of reuse or similar functionality across different parts of the application.

Given this information, it appears that the onMaxBalance function is implemented correctly in terms of its asynchronous nature and its integration into the UI via event handlers. There are no indications from the script output that there are issues with how the function handles state updates or asynchronous operations.

Conclusion:
The onMaxBalance function handles all edge cases correctly, especially with asynchronous operations and state updates, as implemented in the InputContainer.tsx and used similarly in SwapInputContainer.tsx.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `onMaxBalance` function correctly handles asynchronous operations and state updates.

# Test: Search for the function usage and related state updates. Expect: Correct handling of asynchronous operations.
rg --type typescript $'onMaxBalance'

Length of output: 70



Script:

#!/bin/bash
# Description: Verify that the `onMaxBalance` function correctly handles asynchronous operations and state updates.

# Correcting the previous script to search for the function usage in TypeScript files.
rg --glob '*.ts*' 'onMaxBalance'

Length of output: 508

packages/synapse-interface/utils/formatAmount.ts Outdated Show resolved Hide resolved
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

Out of diff range and nitpick comments (2)
packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (2)

Line range hint 107-107: Correct the typo in the variable name from nonBridgableGasTokens to nonBridgeableGasTokens.

-  const nonBridgableGasTokens = NON_BRIDGEABLE_GAS_TOKENS[chainId]
+  const nonBridgeableGasTokens = NON_BRIDGEABLE_GAS_TOKENS[chainId]

Line range hint 109-109: Refactor the logic to handle undefined nonBridgeableGasTokens more cleanly.

-  if (!nonBridgableGasTokens && !isArray(tokens)) {
+  if (!nonBridgeableGasTokens) {
+    remainingTokens = [...tokens];
+    return [filteredNonBridgeableGasTokens, remainingTokens];
+  }
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between f274044 and 2f6b360.
Files selected for processing (4)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx (4 hunks)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (6 hunks)
  • packages/synapse-interface/utils/formatAmount.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenAsset.tsx
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx
  • packages/synapse-interface/utils/formatAmount.ts
Additional comments not posted (1)
packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (1)

Line range hint 50-52: Ensure all dependencies are included in the useEffect dependency array.

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

Out of diff range and nitpick comments (1)
packages/synapse-interface/components/ui/AmountInput.tsx (1)

[!TIP]
Codebase Verification

The verification process has revealed that the properties hasMounted, isConnected, parsedBalance, and onMaxBalance are still being used extensively throughout the project. This contradicts the assumption that these properties were removed and no longer in use. Here are the specific findings:

  • hasMounted: This property is still used in multiple components such as StateManagedBridge/InputContainer.tsx, Maintenance/AnnouncementBanner.tsx, and StateManagedSwap/SwapInputContainer.tsx to manage component lifecycle states.

  • isConnected: This property is widely used across various components to check the connection status, such as in pool/PoolBody.tsx, pool/poolManagement/WithdrawButton.tsx, and StateManagedBridge/BridgeTransactionButton.tsx.

  • parsedBalance: This property is utilized for handling formatted balance values in components like Portfolio/components/GasTokenAsset.tsx, StateManagedBridge/InputContainer.tsx, and ui/SelectSpecificTokenButton.tsx.

  • onMaxBalance: This callback function is used in components like StateManagedBridge/InputContainer.tsx and StateManagedSwap/SwapInputContainer.tsx to handle maximum balance operations.

Given these findings, it is clear that these properties are still integral to the functionality of various components within the project. Therefore, the initial assumption that these properties were removed and are no longer used is incorrect.

Analysis chain

Line range hint 12-48: Ensure proper handling of removed properties.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removed properties `hasMounted`, `isConnected`, `parsedBalance`, and `onMaxBalance` are no longer used in the project or have been adequately replaced.

# Search for usage of removed properties in the project to ensure they are not referenced elsewhere.
rg --type tsx 'hasMounted|isConnected|parsedBalance|onMaxBalance'

Length of output: 95



Script:

#!/bin/bash
# Description: Verify that the removed properties `hasMounted`, `isConnected`, `parsedBalance`, and `onMaxBalance` are no longer used in the project or have been adequately replaced.

# Search for usage of removed properties in TypeScript files to ensure they are not referenced elsewhere.
rg 'hasMounted|isConnected|parsedBalance|onMaxBalance' -g '*.tsx'

Length of output: 13622

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2f6b360 and 38669bd.
Files selected for processing (4)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (4 hunks)
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (6 hunks)
  • packages/synapse-interface/components/ui/AmountInput.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/components/StateManagedBridge/MaxButton.tsx
Additional comments not posted (1)
packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (1)

27-31: Ensure imports are correctly utilized and necessary.

Verification successful

The verification process has confirmed that all the newly imported modules in the file SwapInputContainer.tsx are indeed utilized within the file. Each import is referenced in the code, ensuring that there are no unused imports among those recently added. This aligns with best practices for maintaining clean and efficient code.

  • joinClassNames is used to define labelClassName.
  • MaxButton is utilized within the JSX of the component.
  • trimTrailingZeroesAfterDecimal is called within a function.
  • formatAmount is used to format parsedBalance.
  • getParsedBalance is applied to derive parsedBalance from balance and decimals.

This confirms that the imports are correctly utilized and necessary.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all newly imported modules are used within the file and check for any potential unused imports.

# Search for the newly imported modules usage in the file.
rg --type tsx 'joinClassNames|MaxButton|trimTrailingZeroesAfterDecimal|formatAmount|getParsedBalance' packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx

Length of output: 209



Script:

#!/bin/bash
# Description: Verify that all newly imported modules are used within the file and check for any potential unused imports.

# Correcting the script to search without specifying an unrecognized file type.
rg 'joinClassNames|MaxButton|trimTrailingZeroesAfterDecimal|formatAmount|getParsedBalance' packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx

Length of output: 708

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 38669bd and 0cbe497.
Files selected for processing (1)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx

@bigboydiamonds bigboydiamonds merged commit 4fcfcab into master May 9, 2024
42 checks passed
@bigboydiamonds bigboydiamonds deleted the fe/bridge-gas branch May 9, 2024 18:46
Defi-Moses added a commit that referenced this pull request May 31, 2024
* Update bl

* chore: lint bl

* RFQ: support multiple rebalance methods (#2556)

* WIP: refactor GetRebalanceMethod()

* Feat: implement more robust rebalance method handling

* Feat: move method validation to getRebalance() func

* Feat: manual impl for String() on RebalanceMethod

* Fix: tests

* Feat: add rebalance method clauses to TestGetRebalance

* Feat: use rebalance.Method to choose executor

* Cleanup: lint

* [goreleaser]

* [goreleaser]

* RFQ: drop requests for unsupported chains (#2563)

* Feat: check for unsupported chain in inventory manager

* Cleanup: lint

* [goreleaser]

* Fix: check for nil base fee

* [goreleaser]

* Feat: fee pricer gets gas price from SuggestGasPrice()

* [goreleaser]

* Fix: tests

* lint, add err around clientSuggestGasPrice

* Fix: tests

---------

Co-authored-by: aureliusbtc <[email protected]>

* RFQ: add decimals cache (#2502)

* Feat: add decimalsCache, refactor decimal fetching

* Cleanup: comments

* Fix: build

* Fix: use concurrent map

* CCTP: use chain listener instead of scribe (#2592)

* WIP: replace scribe with chain listener

* Fix: build

* Fix: tests

* Fix: rfq build

* Cleanup: remove unused enum

* Cleanup: revert test change

* Cleanup: comments

* Cleanup: lint

* Fix: build

* Fix: test

* docs(contracts-communication): move natspec from interfaces (#2595)

* docs: SynapseExecutionServiceV1

* docs: SynapseGasOracleV1

* docs: Interchain app templates

* docs: InterchainClientV1

* docs: InterchainDB

* docs: interchain modules

* docs: MessageBus

* style: make interfaces easier to read

* chore: fix linter warnings

* Publish

 - [email protected]

* fix(sdk-rouder): remove cache hydration (#2597)

* fix: disable hydration

* chore: don't log quotes in the integration test

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* update bl

* Revert "update bl"

This reverts commit ab56c7a.

* update bl

* feat(webhook): add webhook  (#2538)

* add models and endpoint, lacking logic

* just stuff

* just stuff

* made general db interface

* cleanup

* trying to test

* trying to test

* trying ot fix test

* remove interface{} from gorm models, start tests, rework db interface

* add signature

* secret

* look away for now

* finish db test

* finish tests

* add auth

* remove debugging log

* comments and nits

* lint

* appsecret and appid

* resolve comments

* swagger, lint

* feat(synapse-interface): maintenance aggregator using PAUSED_CHAINS (#2345)

* Aggregate maintenance events for banners and warning message

* Dynamically render countdown progress bars based on PAUSED_CHAIN

* Dynamically rendering banners

* Slightly organize

* ChainPause type applied to enforce maintenance event structure, pass in component messages as a prop

* Working with multiple events

* Add dev comments to MaintenanceBanner; refactor

* Add dev comments for MaintenanceWarningMessage; refactor

* Dev comments

* Organize components

* isChainIncluded util

* Clean

* Add ability to specify paused chains by from/to side (#2346)

* Allow indefinite maintenance components by setting end date to null

* Banners to show indefinitely as well

* Add props to disable banner / warning / countdown

* Implement disable warning

* Implement disable countdown, bridge pause still working

* Example

* Clean

* Update naming on Bridge page

* Update comment for isChainIncluded

* Create maintenance events reading from pausedChains.json

* Remove custom margins to allow Bridge parent gap styling to handle spacing

* Require all props to be defined

* Add Swap to maintenance warning messages

* Update useMaintenanceCountdownProgresses to allow distinction between Swap and Bridge pauses

* Move MaintenanceBanners into LandingPageWrapper so banner appears on all pages

* Add ability to specify whether to pause bridge / swap with maintenance event in json

* Clean

* Unused code

* Update dev comments

* Update pause start/end time name for legibility

* Create type guard to check for paused bridge module

* usePausedBridgeModules

* usePausedBridgeModules to filter out SDK quotes

* Initialize paused routes to handle specific route pauses instead of grouping with chain pauses

* Update paused route structure

* Filter for valid quotes based on paused routes

* Create a Set with paused bridge module names to improve time complexity

* Allow for all bridge modules to be paused with ALL

* Add ability to pause bridge modules for all chains, if chainId is left undefined

* Move json files to /v1/ version control folder

* Compare quotes against paused bridge modules more cleanly

* Paused bridge modules json control working

* Fix pausedChains json

* Create examples folder for pause jsons

* Retrigger build

* Fix banner flashing after clearing

* Add padding to banner Close button

* Update text sizing on progress bar

* Update prop naming to prevent confusion on start/end

* Clear chain pauses to ready PR

* Change json file naming to be more readable

* Use inputWarningMessage prop name to indicate warning placement

* Pause Doge activity using Maintenance, to replace prior Chain pause mechanism

* Doge chain paused chain prop values

* Remove paused from/to chainId constants

* Publish

 - @synapsecns/[email protected]

* Exempt gh pages (#2541)

Co-authored-by: Trajan0x <[email protected]>

* Deploy: `FastBridge` to Scroll (#2525)

* chore: add Base to `.env.example`

* chore: add Scroll config

* chore: bump devops dependency

* chore: yarn

* feat: deploy `FastBridge` on scroll

* Publish

 - [email protected]

* fix: update `forge-std` to 1.8.1, remove `ds-test`, use `solhint` for linting (#2545)

* chore: forge-std  v1.8.1, remove ds-test dep

* chore: remove ds-test from remappings

* refactor: state mutability

* chore: add solhint

* chore: yarn

* fix: unused imports

* fix: max line length

* Publish

 - [email protected]
 - [email protected]
 - @synapsecns/[email protected]

* chore: remove submodules from `contracts-rfq` (#2547)

* build: install OZ as npm module

* chore: update remappings

* refactor: fix compiler warnings in test contract

* chore: remove forge-std submodule

* chore: remove `openzeppelin-contracts` submodule

* fix: restore padding in `.gitmodules`

* Publish

 - [email protected]

* gogenerate

* Revert "gogenerate"

This reverts commit b40e602.

* im dumb

* generate

* tidy

* update swagger doc

* [goreleaser]

* [goreleaser]

---------

Co-authored-by: shampoobera <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Co-authored-by: trajan0x <[email protected]>
Co-authored-by: Trajan0x <[email protected]>
Co-authored-by: χ² <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>

* rfq api cache (#2562)

* cache api result [goreleaser]

* clean up

* clean up 2

---------

Co-authored-by: Trajan0x <[email protected]>

* add trace to sync (#2601)

* trace more

* cleanup

* allow use of mustache templates

---------

Co-authored-by: Trajan0x <[email protected]>

* remove iconfig file (#2602)

Co-authored-by: Trajan0x <[email protected]>

* feat(contracts-communication): remove batching (#2599)

* feat: scaffold InterchainDB interface changes

* feat: scaffold Module interface changes

* feat: update InterchainEntry

* test: update DB tests

* test: update Client tests

* refactor: ModuleBatch -> ModuleEntry

* feat: remove `entryIndex` from InterchainTx

* feat: scaffold Client interface changes

* feat: start updating the Module

* test: update integration tests

* cleanup: remove BatchingV1

* feat: update InterchainDB

* cleanup: remove entryIndex from apps

* cleanup: remove entryIndex from Client events

* feat: update ClientV1

* cleanup: remove entryIndex from DB

* test: update SynapseModule tests

* cleanup: ClientV1

* cleanup: DB

* cleanup: Module

* cleanup: remove batch lib

* docs: smol fixes

* Publish

 - [email protected]

* optional screener for cctp relayer (#2600)

Co-authored-by: Trajan0x <[email protected]>

* Sin/testnet 9 (#2567)

* fix: remove `ExecutionFees` references

* New set of deployments

* Adjust config files to the latest changes

* adding spectral coingecko ids for pricing (#2596)

* feat(widget): suppress console errors (#2594)

* Allow widget to suppress Synapse console errors

* feat(sdk-router): router cache error log (#2591)

* Improve RouterCache error logging

* Add common error string to target at Consumer level

* Add common string to all console errors

* feat(widget): error logs (#2593)

* Add common base string to allow hiding Widget related errors outputted in Consumer app

* Convert logs into errors if firing in catch statement

* Update README

* Optional prop

* Switch catch log to error

* Re-trigger action

* Remove line

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* fix(contracts-communication): interchain module ignore nonces (#2604)

* feat: remove dbNonce from Module interface

* cleanup: update Module interface references

* refactor: lint

* Publish

 - [email protected]

* feat(synapse-interface): bridge gas handler (#2437)

* Initial gas data slice state

* Async thunk fetchGasData

* Add gas data reducers

* useFetchGasDataOnInterval added to Bridge Listener

* Explicitly declare fetching gas data in gwei

* Calculate max bridgeable amount

* On max balance factoring in gas cost

* Add comment

* Differentiate max balance vs max bridgeable balance

* Add error toaster for when max balance less than bridge fee

* refactor; calculateGasFeeInGwei()

* Move to util

* Fix lint error

* Fetch gas when fromChainId on bridge card changes

* Use exact token balance when calculate max bridgeable amount

* Conditions for showing max button

* showMaxOption to determine display

* Disable max button if gas fees more than gas balance

* Clean jsx

* AvailableBalance component to track subscript detail in bridge origin input

* Return raw and formatted gas cost in calculateGasCost

* Update comments

* Fix imports based on name cange

* Use parsed

* calculateMaxBridgeableGas

* Clean

* refactor: clean InputContainer

* Replace onMaxBalance() with onMaxBridgeableBalance()`

* Allow undefined object when destructuring

* Display when token balance is trace balance

* Typing

* showGasReserved

* Update avail balance text and color when gas cost greater than balance

* Detect when input value is less than required estimated gas

* onAvailableBalance applied

* Make opacity greater when Max button disabled

* Fix calculations for when gas input is enough to cover gas

* Clean

* Add hover tooltip for warning gas states

* Use tooltip to describe gas status

* Update tooltip text

* Add buffer to calculate gas cost, use 1.5x

* AvailableBalance component to replace label in AmountInput

* Display trace balances in AvailableBalance

* Fix naming

* Add HoverTooltip to Available Balance

* Add conditions for displaying gas error based on input

* Use full parsed balance when making comparisons for gas checks

* Show gas reserved in Available Balance

* hasOnlyZeroes to return true if string contains only zeroes and periods

* Display estimated gas cost in tool tip

* Remove Available Balance elements from AmountInput, migrated to AvailableBalance

* Display trace amount for input when displaying how much is reserved for gas

* Fetch estimated gas limit based on real bridge quote using max gas balance

* Fetching accurate gasLimit

* Fix Trace balance

* Set gasLimit to 0 if not valid bridge data avail

* ...

* Fix when gas covered msg appears

* Available Balance

* Clean available balance flow

* useGasEstimator hook to encapsulate logic to clean InputContainer

* Fix prop issue

* Remove duplicate HoverTooltip

* Move HoverTooltip to shared component folder

* Update gas fetch for wagmi v2, up limit to 1.7

* Estimated gas bridge quote fetched on load

* Update var naming

* Improve Available Balance flow

* Display estimated bridgeable balance on hover

* Show gas estimate when estimated gas cost available

* Do not show negative bridgable balance

* Separate out bridge gas limit calculations into smaller functions

* Wrap async functions with try catch

* Implement updated gas estimation flow

* Move gas estimate logic to useGasEstimator

* Move async sdk fetch functions to useGasEstimator file

* Remove unused vars

* Shorten est gas cost

* Improve code legibility in AvailableBalance

* Assign conditions to vars to reduce clutter

* Reset gas price data when fromChainId changes

* Reset fetched gas limit when fromChainId changes

* Clean

* Fix old import

* Fix max button placement

* Add loading state for useGasEstimator

* Remove available balance states for gas est

* Remove unused props

* Clean gas token detection in PortfolioTokenAsset

* Simplify onMaxBalance()

* Clean constants in InputContainer

* Clean token detail destructuring

* Include gas estimate when updating input from Portfolio token selection

* Fire error toaster if gas fees exceed balance

* Render error toaster when firing onMaxBalance callback instead of a side effect

* Clean useGasEstimator

* Ensure available balance does not show if wallet not connected, set default value if balances not loaded

* Replicate onMax behavior in Portfolio

* Use fetched gas

* Improve error handling in gas estimator

* ...

* Remove tooltip on AvailableBalance

* Remove balance prefill from Portfolio Token selection

* Update available balance in input based on max bridgeable gas toke

* Destructure estimateGasLimit callback from useGasEstimator to retrigger fetching gas estimate

* Refetch gas ata in estimateGasLimit callback

* Display total vs bridgeable balance on hover in Portfolio gas token when gas data available

* Update balance shown on hover

* Clean

* Simplify useFetchGasDataOnInterval

* Prevent unnecessary fetches, fix chain update old gas issue

* Fetch estimated bridgeable max gas amount onClick token max input, fill input once amount fetched

* Clean

* onMaxBalance will use default balanceif fetched bridgeable balance estimate returns null

* Show dust gas amounts on hover in Portfolio

* Clean

* Available balance including gas estimates moved to within Input to synchronize data

* Move gasLimit to global store to share data between Bridge components

* Display max bridgeable balance on hover in Portfolio, add onMaxBalance onClick Portfolio asset

* Portfolio and Input available balance onClick behave the same

* Fetch gas prices to provide most accurate gas cost

* Remove hover on AvailableBalance

* Fix Token Selector width

* Remove onClick Portfolio Token Balance, allow Token selection from Portfolio only without Balance input update

* Cursor default on Portfolio Token Balance

* Show available/max buttons when bridge valid selections

* Swap input to have available balance

* Clean

* Basic MaxButton onClick and hidden when loading gas data

* Show MaxButton when input is not full balance or bridgeable balance

* Implement Max button and placement in Bridge/Swap

* Hide MaxButton until connected

* Hide MaxButton conditions

* Show Max when all input selections are made

* Remove click states for AvailableBalance on Bridge/Swap

* Style Input / Max

* Max mobile size

* Fe/format amount (#2598)

* formatAmount util function, use rounded shortened values in Bridge/Swap Input

* Update Bridge/Swap page with parsed / formatted balances

* Clean imports

* Clean imports

* Swap Max spacing

* Improve html element composition

* Prevent layout shift in Swap UI

* Publish

 - @synapsecns/[email protected]

* add "and" (#2608)

* fix(contracts-communication): default settings for Guard service (#2605)

* test: should ignore optimistic period w/o guard

* test: app should have empty config be default

* test: should allow setting zero optimistic period

* fix: ignore optimistic period without a guard

* fix: use GUARD_DISABLED flag by default

* fix: don't revert on zero optimistic period

* test: different optimistic periods for integration tests

* fix: use default guard for PingPongApp

* refactor: fix linter warnings

* Publish

 - [email protected]
 - @synapsecns/[email protected]

* Fix: put blocking call to Start() in new goroutine (#2614)

* feat(contracts-communication): default values for modules/required respones (#2612)

* feat: scaffold defaultModule in Client

* test: expected behavior for setting default module

* feat: setting default Module in Client

* refactor: Client views test

* test: appConfig with zero modules/responses

* feat: module config defaults

* cleanup: remove `ZeroRequiredResponses` error

* refactor: prep for 0 and 1 module tests

* test: ClientV1 + app with 1 module

* test: ClientV1 + app with 0 modules

* Publish

 - [email protected]

* RFQ: rebalance edge cases & refactoring (#2613)

* Fix: filter rebalance origin / dest on rebalance method

* Cleanup: move getRebalance() into rebalance.go

* Cleanup: add helpers to getRebalance()

* Cleanup: comments

* Feat: remove Rebalance() call upon deposit claimed

* Feat: getRebalance() takes in dest chain id

* Cleanup: comments

* Feat: extra check that we don't exceed origin maintenance

* Feat: add new test case for mismatched methods but existing rebalance

* Feat: break down TestGetRebalance into sub tests

* Cleanup: lint

* [goreleaser]

* [goreleaser]

* refactor: move opinionated stuff into SynapseModule (#2617)

* Publish

 - [email protected]

* Document Modules (#2611)



Co-authored-by: Trajan0x <[email protected]>

* cleanup (#2618)

Co-authored-by: Trajan0x <[email protected]>

* fix tests (#2620)

Co-authored-by: Trajan0x <[email protected]>

* RFQ API: replace `otelresty` with `otelhhtp` package (#2606)

* Feat: replace otelresty usage with otelhttp pkg

* [goreleaser]

* make coverage aggregator public (#2621)

Co-authored-by: Trajan0x <[email protected]>

* Publish

 - @synapsecns/[email protected]

* publish aggregator fix (#2622)

Co-authored-by: Trajan0x <[email protected]>

* Publish

 - @synapsecns/[email protected]

* fix(solidity-devops): update forge-std to 1.8.2 (#2619)

* build: update `forge-std` to 1.8.2

* chore: yarn

* Publish

 - [email protected]
 - [email protected]
 - @synapsecns/[email protected]

* feat(docs): auto deploy vercel to prod (only vercel) (#2627)

Co-authored-by: Trajan0x <[email protected]>

* fix(ci): fixes bug in #2627, deploys go to prod (#2628)

Co-authored-by: Trajan0x <[email protected]>

* docs(contributing) add a guide on adding js packages (#2629)

* docs(contributing) add a guide on adding js packages

* Update CONTRIBUTING.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Trajan0x <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* revert coderabbit fix (#2630)

Co-authored-by: Trajan0x <[email protected]>

* prod release fix (#2631)

Co-authored-by: Trajan0x <[email protected]>

* Publish

 - @synapsecns/[email protected]

* add grafana dashboard and fix broken link (#2634)

Co-authored-by: Trajan0x <[email protected]>

* add scroll (#2635)

Co-authored-by: Trajan0x <[email protected]>

* Submitter: bump MaxResultsPerChain (#2633)

* Feat: bump MaxResultsPerChain

* [goreleaser]

* fast bridge regen (#2636)

Co-authored-by: Trajan0x <[email protected]>

* omnirpc doc fixes (#2637)

* swagger

* embed swagger ui

* generic lint fixer

---------

Co-authored-by: Trajan0x <[email protected]>

* fix typo (#2638)

Co-authored-by: Trajan0x <[email protected]>

* Update bl

* Add SPECTRAL token support (#2640)

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* feat(synapse-interface): Adds Scroll via RFQ (#2526)

* Adds Scroll via RFQ

* Adds NewTag

* Adds RFQ logic into the generateMaps script

* Adds announcement banner

* Linting

* Adjusts order

* API call for quotes

* Updates bridgeMap for live Scroll quotes

* For reusing NewTag

* Adjust dates

* Publish

 - @synapsecns/[email protected]

* feat(widget): maintenance (#2616)

* Fetch pause data and store JSON object in client browser

* Refetch only if last fetch was more than 24 hours ago

* Read chain + module pause from local storage

* Maintenance components rendering based off of fetched pause data

* Pause Bridge button based on Maintenance status

* Filter quotes based on paused modules

* Use user defined styling or defaults

* Style Progress Bar

* Refactor getSynapsePauseData

* Clean

* Fix bridge quote filter

* Adjust text size for maintenance

* Add comments + clean

* Update comment

* Refresh data every hour

* Clean

* Add key to warning messages

* Fix render issues, start move event countdown component directly to Widget to resolve hooks issue

* Resolve hooks render issue with localized component

* Progress bar renders when not isabled

* Clean and simplify Maintenance components

* getMaintenanceData

* Organize back into useMaintenance hook

* Clean / organize

* Use prod urls

* Organizational updates

* Fetch pause data every render, set fetching status flag

* Rm timestamp key

---------

Co-authored-by: abtestingalpha <[email protected]>

* Publish

 - @synapsecns/[email protected]

* RFQ API: add GET /ack endpoint (#2643)

* WIP: add relay ack cache and GetRelayAck endpoint

* Feat: register AckRoute

* Feat: add ackMux

* Feat: add GetRelayAck test

* Feat: add GetRelayAck to UnauthenticatedClient

* Feat: relayer fetches ack before updating to CommittedPending

* [goreleaser]

* Feat: move GET /ack to PUT /ack

* WIP: generalize AuthMiddleware()

* Fix: working refactor for auth

* Feat: add PutAckRequest and parse in auth middleware

* Feat: impl PUT /ack request with json req body

* Feat: bump default timeout from 5 to 10

* Feat: add swagger comments

* Cleanup: pass API client into quoter

* Feat: return RelayerAddress in PutRelayAckResponse

* Cleanup: add clarifying comment

* [goreleaser]

* Cleanup: lint

* [goreleaser]

* Cleanup: add tracing

* [goreleaser]

* Config: bump relay ack timeout to 30 seconds

* [goreleaser]

* Feat: lower submitter retry interval (#2645)

* update bl

* Adjusts banner date (#2647)

* Publish

 - @synapsecns/[email protected]

* Add SPEC token pricing to the manual cache (#2646)

* adding spectral coingecko ids for pricing

* adding spec token to cache

* Update bl

* fix(screener): fix screener http 502 (#2650)


Co-authored-by: trajan0x <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* update bl

* update bl

---------

Co-authored-by: aureliusbtc <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>
Co-authored-by: dwasse <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>
Co-authored-by: Trajan0x <[email protected]>
Co-authored-by: vro <[email protected]>
Co-authored-by: shampoobera <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Co-authored-by: trajan0x <[email protected]>
Co-authored-by: Moses <[email protected]>
Co-authored-by: Simon <[email protected]>
Co-authored-by: aureliusbtc <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: abtestingalpha <[email protected]>
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.

1 participant